47 changed files with 1154 additions and 160 deletions
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface IMvcClass |
||||
{ |
||||
string FullyQualifiedName { get; } |
||||
string Name { get; } |
||||
string Namespace { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface IMvcModelClassLocator |
||||
{ |
||||
IEnumerable<IMvcClass> GetModelClasses(IMvcProject project); |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface IMvcParserService |
||||
{ |
||||
IMvcProjectContent GetProjectContent(IMvcProject project); |
||||
} |
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface IMvcProject |
||||
{ |
||||
IProject Project { get; } |
||||
string RootNamespace { get; } |
||||
|
||||
void Save(); |
||||
MvcTextTemplateLanguage GetTemplateLanguage(); |
||||
IEnumerable<IMvcClass> GetModelClasses(); |
||||
} |
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface IMvcProjectContent |
||||
{ |
||||
IEnumerable<IMvcClass> GetClasses(); |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public interface ISelectedFolderNodeInProjectsView |
||||
{ |
||||
string Folder { get; } |
||||
IMvcProject Project { get; } |
||||
|
||||
void AddNewFile(string path); |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcClass : IMvcClass |
||||
{ |
||||
IClass c; |
||||
|
||||
public MvcClass(IClass c) |
||||
{ |
||||
this.c = c; |
||||
} |
||||
|
||||
public string FullyQualifiedName { |
||||
get { return c.FullyQualifiedName; } |
||||
} |
||||
|
||||
public string Name { |
||||
get { return c.Name; } |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { return c.Namespace; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcModelClassLocator : IMvcModelClassLocator |
||||
{ |
||||
IMvcParserService parserService; |
||||
|
||||
public MvcModelClassLocator() |
||||
: this(new MvcParserService()) |
||||
{ |
||||
} |
||||
|
||||
public MvcModelClassLocator(IMvcParserService parserService) |
||||
{ |
||||
this.parserService = parserService; |
||||
} |
||||
|
||||
public IEnumerable<IMvcClass> GetModelClasses(IMvcProject project) |
||||
{ |
||||
foreach (IMvcClass c in GetClasses(project)) { |
||||
yield return c; |
||||
} |
||||
} |
||||
|
||||
IEnumerable<IMvcClass> GetClasses(IMvcProject project) |
||||
{ |
||||
IMvcProjectContent projectContent = GetProjectContent(project); |
||||
return projectContent.GetClasses(); |
||||
} |
||||
|
||||
IMvcProjectContent GetProjectContent(IMvcProject project) |
||||
{ |
||||
return parserService.GetProjectContent(project); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcModelClassViewModel |
||||
{ |
||||
IMvcClass mvcClass; |
||||
string name; |
||||
|
||||
public MvcModelClassViewModel( |
||||
IMvcClass mvcClass) |
||||
{ |
||||
this.mvcClass = mvcClass; |
||||
GetName(); |
||||
} |
||||
|
||||
void GetName() |
||||
{ |
||||
name = String.Format("{0} ({1})", mvcClass.Name, mvcClass.Namespace); |
||||
} |
||||
|
||||
public string Name { |
||||
get { return name; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return Name; |
||||
} |
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcModelClassViewModelsForSelectedFolder |
||||
{ |
||||
ISelectedMvcFolder selectedFolder; |
||||
List<MvcModelClassViewModel> modelClasses; |
||||
|
||||
public MvcModelClassViewModelsForSelectedFolder(ISelectedMvcFolder selectedFolder) |
||||
{ |
||||
this.selectedFolder = selectedFolder; |
||||
} |
||||
|
||||
public IEnumerable<MvcModelClassViewModel> ModelClasses { |
||||
get { |
||||
if (modelClasses != null) { |
||||
return modelClasses; |
||||
} |
||||
return new MvcModelClassViewModel[0]; |
||||
} |
||||
} |
||||
|
||||
public void GetModelClasses() |
||||
{ |
||||
if (modelClasses == null) { |
||||
modelClasses = new List<MvcModelClassViewModel>(); |
||||
|
||||
foreach (IMvcClass mvcClass in GetModelClassesFromProject()) { |
||||
var modelClassViewModel = new MvcModelClassViewModel(mvcClass); |
||||
modelClasses.Add(modelClassViewModel); |
||||
} |
||||
} |
||||
} |
||||
|
||||
IEnumerable<IMvcClass> GetModelClassesFromProject() |
||||
{ |
||||
return selectedFolder.Project.GetModelClasses(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcParserService : IMvcParserService |
||||
{ |
||||
public IMvcProjectContent GetProjectContent(IMvcProject project) |
||||
{ |
||||
IProjectContent projectContent = GetProjectContentFromParser(project); |
||||
return new MvcProjectContent(projectContent); |
||||
} |
||||
|
||||
IProjectContent GetProjectContentFromParser(IMvcProject mvcProject) |
||||
{ |
||||
return ParserService.GetProjectContent(mvcProject.Project); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcProject : IMvcProject |
||||
{ |
||||
IMvcModelClassLocator modelClassLocator; |
||||
|
||||
public MvcProject(IProject project) |
||||
: this(project, new MvcModelClassLocator()) |
||||
{ |
||||
} |
||||
|
||||
public MvcProject(IProject project, IMvcModelClassLocator modelClassLocator) |
||||
{ |
||||
this.Project = project; |
||||
this.modelClassLocator = modelClassLocator; |
||||
} |
||||
|
||||
public IProject Project { get; private set; } |
||||
|
||||
public string RootNamespace { |
||||
get { return Project.RootNamespace; } |
||||
} |
||||
|
||||
public void Save() |
||||
{ |
||||
Project.Save(); |
||||
} |
||||
|
||||
public MvcTextTemplateLanguage GetTemplateLanguage() |
||||
{ |
||||
string language = Project.Language; |
||||
return MvcTextTemplateLanguageConverter.Convert(language); |
||||
} |
||||
|
||||
public IEnumerable<IMvcClass> GetModelClasses() |
||||
{ |
||||
return modelClassLocator.GetModelClasses(this); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class MvcProjectContent : IMvcProjectContent |
||||
{ |
||||
IProjectContent projectContent; |
||||
|
||||
public MvcProjectContent(IProjectContent projectContent) |
||||
{ |
||||
this.projectContent = projectContent; |
||||
} |
||||
|
||||
public IEnumerable<IMvcClass> GetClasses() |
||||
{ |
||||
foreach (IClass c in projectContent.Classes) { |
||||
yield return new MvcClass(c); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class SelectedFolderNodeInProjectsView : ISelectedFolderNodeInProjectsView |
||||
{ |
||||
DirectoryNode directoryNode; |
||||
MvcProject project; |
||||
|
||||
public SelectedFolderNodeInProjectsView(DirectoryNode directoryNode) |
||||
{ |
||||
this.directoryNode = directoryNode; |
||||
this.project = new MvcProject(directoryNode.Project); |
||||
} |
||||
|
||||
public string Folder { |
||||
get { return directoryNode.Directory; } |
||||
} |
||||
|
||||
public IMvcProject Project { |
||||
get { return project; } |
||||
} |
||||
|
||||
public void AddNewFile(string path) |
||||
{ |
||||
directoryNode.AddNewFile(path); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeMvcClass : IMvcClass |
||||
{ |
||||
public FakeMvcClass(string fullyQualifiedName) |
||||
{ |
||||
this.FullyQualifiedName = fullyQualifiedName; |
||||
} |
||||
|
||||
public FakeMvcClass(string @namespace, string name) |
||||
{ |
||||
this.Namespace = @namespace; |
||||
this.Name = name; |
||||
} |
||||
|
||||
public string FullyQualifiedName { get; set; } |
||||
public string Name { get; set; } |
||||
public string Namespace { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeMvcModelClassLocator : IMvcModelClassLocator |
||||
{ |
||||
public List<FakeMvcClass> FakeModelClasses = new List<FakeMvcClass>(); |
||||
|
||||
public void AddModelClass(string fullyQualifiedClassName) |
||||
{ |
||||
var fakeClass = new FakeMvcClass(fullyQualifiedClassName); |
||||
FakeModelClasses.Add(fakeClass); |
||||
} |
||||
|
||||
public IMvcProject ProjectPassedToGetModelClasses; |
||||
|
||||
public IEnumerable<IMvcClass> GetModelClasses(IMvcProject project) |
||||
{ |
||||
ProjectPassedToGetModelClasses = project; |
||||
return FakeModelClasses; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeMvcParserService : IMvcParserService |
||||
{ |
||||
public IMvcProject ProjectPassedToGetProjectContent; |
||||
public FakeMvcProjectContent FakeMvcProjectContent = new FakeMvcProjectContent(); |
||||
|
||||
public IMvcProjectContent GetProjectContent(IMvcProject project) |
||||
{ |
||||
ProjectPassedToGetProjectContent = project; |
||||
return FakeMvcProjectContent; |
||||
} |
||||
|
||||
public void AddModelClassToProjectContent(string fullyQualifiedClassName) |
||||
{ |
||||
FakeMvcProjectContent.AddFakeClass(fullyQualifiedClassName); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeMvcProject : IMvcProject |
||||
{ |
||||
public TestableProject FakeProject = TestableProject.CreateProject(); |
||||
|
||||
public IProject Project { |
||||
get { return FakeProject; } |
||||
} |
||||
|
||||
public string RootNamespace { get; set; } |
||||
|
||||
public bool SaveCalled; |
||||
|
||||
public void Save() |
||||
{ |
||||
SaveCalled = true; |
||||
} |
||||
|
||||
MvcTextTemplateLanguage TemplateLanguageToReturnFromGetTemplateLanguage; |
||||
|
||||
public void SetCSharpAsTemplateLanguage() |
||||
{ |
||||
TemplateLanguageToReturnFromGetTemplateLanguage = MvcTextTemplateLanguage.CSharp; |
||||
} |
||||
|
||||
public void SetVisualBasicAsTemplateLanguage() |
||||
{ |
||||
TemplateLanguageToReturnFromGetTemplateLanguage = MvcTextTemplateLanguage.VisualBasic; |
||||
} |
||||
|
||||
public MvcTextTemplateLanguage GetTemplateLanguage() |
||||
{ |
||||
return TemplateLanguageToReturnFromGetTemplateLanguage; |
||||
} |
||||
|
||||
public List<FakeMvcClass> ModelClasses = new List<FakeMvcClass>(); |
||||
|
||||
public void AddModelClassToProject(string @namespace, string name) |
||||
{ |
||||
var fakeClass = new FakeMvcClass(@namespace, name); |
||||
ModelClasses.Add(fakeClass); |
||||
} |
||||
|
||||
public int GetModelClassesCallCount; |
||||
|
||||
public IEnumerable<IMvcClass> GetModelClasses() |
||||
{ |
||||
GetModelClassesCallCount++; |
||||
return ModelClasses; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeMvcProjectContent : IMvcProjectContent |
||||
{ |
||||
public List<FakeMvcClass> FakeClasses = new List<FakeMvcClass>(); |
||||
|
||||
public IEnumerable<IMvcClass> GetClasses() |
||||
{ |
||||
return FakeClasses; |
||||
} |
||||
|
||||
public void AddFakeClass(string fullyQualifiedClassName) |
||||
{ |
||||
var fakeClass = new FakeMvcClass(fullyQualifiedClassName); |
||||
FakeClasses.Add(fakeClass); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeSelectedFolderNodeInProjectsView : ISelectedFolderNodeInProjectsView |
||||
{ |
||||
public FakeSelectedFolderNodeInProjectsView() |
||||
{ |
||||
Folder = @"d:\projects\MyMvcApp\Views\Home"; |
||||
} |
||||
|
||||
public string Folder { get; set; } |
||||
|
||||
public FakeMvcProject FakeMvcProject = new FakeMvcProject(); |
||||
|
||||
public IMvcProject Project { |
||||
get { return FakeMvcProject; } |
||||
} |
||||
|
||||
public string PathPassedToAddNewFile; |
||||
|
||||
public void AddNewFile(string path) |
||||
{ |
||||
PathPassedToAddNewFile = path; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using AspNet.Mvc.Tests.Helpers; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ModelClassLocatorTests |
||||
{ |
||||
MvcModelClassLocator locator; |
||||
FakeMvcProject fakeProject; |
||||
FakeMvcParserService fakeParserService; |
||||
|
||||
void CreateLocator() |
||||
{ |
||||
fakeProject = new FakeMvcProject(); |
||||
fakeParserService = new FakeMvcParserService(); |
||||
locator = new MvcModelClassLocator(fakeParserService); |
||||
} |
||||
|
||||
List<IMvcClass> GetModelClasses() |
||||
{ |
||||
return locator.GetModelClasses(fakeProject).ToList(); |
||||
} |
||||
|
||||
void AddModelClass(string fullyQualifiedClassName) |
||||
{ |
||||
fakeParserService.AddModelClassToProjectContent(fullyQualifiedClassName); |
||||
} |
||||
|
||||
string GetFirstModelClassName() |
||||
{ |
||||
return GetModelClasses().First().FullyQualifiedName; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModelClasses_OneModelClassInProject_ReturnModelClassWithExpectedName() |
||||
{ |
||||
CreateLocator(); |
||||
AddModelClass("MyNamespace.MyClass"); |
||||
string modelClassName = GetFirstModelClassName(); |
||||
|
||||
Assert.AreEqual("MyNamespace.MyClass", modelClassName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModelClasses_OneModelClassInProject_ReturnOneModelClass() |
||||
{ |
||||
CreateLocator(); |
||||
AddModelClass("MyNamespace.MyClass"); |
||||
int count = GetModelClasses().Count; |
||||
|
||||
Assert.AreEqual(1, count); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModelClasses_NoModelClassesInProject_GetsProjectContentFromParserService() |
||||
{ |
||||
CreateLocator(); |
||||
GetModelClasses(); |
||||
|
||||
Assert.AreEqual(fakeProject, fakeParserService.ProjectPassedToGetProjectContent); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using AspNet.Mvc.Tests.Helpers; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MvcModelClassViewModelTests |
||||
{ |
||||
FakeMvcClass fakeClass; |
||||
MvcModelClassViewModel viewModel; |
||||
|
||||
void CreateViewModel(string classNamespace, string className) |
||||
{ |
||||
fakeClass = new FakeMvcClass(classNamespace, className); |
||||
viewModel = new MvcModelClassViewModel(fakeClass); |
||||
} |
||||
|
||||
[Test] |
||||
public void Name_ClassHasNamespaceAndName_ReturnsClassNameFollowedByNamespace() |
||||
{ |
||||
CreateViewModel("ICSharpCode.Tests", "MyClass"); |
||||
string text = viewModel.Name; |
||||
|
||||
Assert.AreEqual("MyClass (ICSharpCode.Tests)", text); |
||||
} |
||||
|
||||
[Test] |
||||
public void ToString_ClassHasNamespaceAndName_ReturnsClassNameFollowedByNamespace() |
||||
{ |
||||
CreateViewModel("ICSharpCode.Tests", "MyClass"); |
||||
string text = viewModel.ToString(); |
||||
|
||||
Assert.AreEqual("MyClass (ICSharpCode.Tests)", text); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
using AspNet.Mvc.Tests.Helpers; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MvcProjectTests |
||||
{ |
||||
MvcProject project; |
||||
TestableProject testableProject; |
||||
FakeMvcModelClassLocator fakeModelClassLocator; |
||||
|
||||
void CreateProject() |
||||
{ |
||||
testableProject = TestableProject.CreateProject(); |
||||
fakeModelClassLocator = new FakeMvcModelClassLocator(); |
||||
project = new MvcProject(testableProject, fakeModelClassLocator); |
||||
} |
||||
|
||||
[Test] |
||||
public void Project_ProjectPassedToConstructor_ReturnsProjectPassedToConstructor() |
||||
{ |
||||
CreateProject(); |
||||
|
||||
IProject msbuildProject = project.Project; |
||||
|
||||
Assert.AreEqual(testableProject, msbuildProject); |
||||
} |
||||
|
||||
[Test] |
||||
public void RootNamespace_ProjectPassedToConstructorHasRootNamespace_ReturnsRootNamespace() |
||||
{ |
||||
CreateProject(); |
||||
testableProject.RootNamespace = "MyProjectNamespace"; |
||||
|
||||
string rootNamespace = project.RootNamespace; |
||||
|
||||
Assert.AreEqual("MyProjectNamespace", rootNamespace); |
||||
} |
||||
|
||||
[Test] |
||||
public void Save_ProjectPassedToConstructor_ProjectIsSaved() |
||||
{ |
||||
CreateProject(); |
||||
project.Save(); |
||||
|
||||
bool saved = testableProject.IsSaved; |
||||
|
||||
Assert.IsTrue(saved); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTemplateLanguage_ProjectIsVisualBasicProject_ReturnsVisualBasicTemplateLanguage() |
||||
{ |
||||
CreateProject(); |
||||
testableProject.SetLanguage("VBNet"); |
||||
|
||||
MvcTextTemplateLanguage language = project.GetTemplateLanguage(); |
||||
|
||||
Assert.AreEqual(MvcTextTemplateLanguage.VisualBasic, language); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTemplateLanguage_ProjectIsCSharpProject_ReturnsCSharpTemplateLanguage() |
||||
{ |
||||
CreateProject(); |
||||
testableProject.SetLanguage("C#"); |
||||
|
||||
MvcTextTemplateLanguage language = project.GetTemplateLanguage(); |
||||
|
||||
Assert.AreEqual(MvcTextTemplateLanguage.CSharp, language); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModelClasses_OneModelClassInProject_ReturnsOneModelClass() |
||||
{ |
||||
CreateProject(); |
||||
fakeModelClassLocator.AddModelClass("MyNamespace.MyClass"); |
||||
|
||||
string[] modelClasses = project |
||||
.GetModelClasses() |
||||
.Select(m => m.FullyQualifiedName) |
||||
.ToArray(); |
||||
|
||||
string[] expectedModelClasses = new string[] { |
||||
"MyNamespace.MyClass" |
||||
}; |
||||
|
||||
Assert.AreEqual(expectedModelClasses, modelClasses); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModelClasses_OneModelClassInProject_ProjectUsedToFindModelClasses() |
||||
{ |
||||
CreateProject(); |
||||
fakeModelClassLocator.AddModelClass("MyNamespace.MyClass"); |
||||
project.GetModelClasses(); |
||||
|
||||
Assert.AreEqual(project, fakeModelClassLocator.ProjectPassedToGetModelClasses); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using AspNet.Mvc.Tests.Helpers; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class SelectedFolderNodeInProjectsViewTests |
||||
{ |
||||
SelectedFolderNodeInProjectsView selectedFolderNode; |
||||
TestableProject projectForSelectedFolder; |
||||
DirectoryNode directoryNode; |
||||
ProjectNode projectNode; |
||||
|
||||
void CreateSelectedFolderNode(string folder) |
||||
{ |
||||
projectForSelectedFolder = TestableProject.CreateProject(); |
||||
projectNode = new ProjectNode(projectForSelectedFolder); |
||||
|
||||
directoryNode = new DirectoryNode(folder); |
||||
directoryNode.AddTo(projectNode); |
||||
|
||||
selectedFolderNode = new SelectedFolderNodeInProjectsView(directoryNode); |
||||
} |
||||
|
||||
[Test] |
||||
public void Folder_DirectorySpecifiedForNode_ReturnsDirectoryTakenFromDirectoryNode() |
||||
{ |
||||
string expectedFolder = @"d:\projects\MyAspMvcApp\Views\Home"; |
||||
CreateSelectedFolderNode(expectedFolder); |
||||
|
||||
string folder = selectedFolderNode.Folder; |
||||
|
||||
Assert.AreEqual(expectedFolder, folder); |
||||
} |
||||
|
||||
[Test] |
||||
public void MvcProject_DirectoryNodeHasProjectNodeAsParent_ReturnsProjectFromDirectoryNode() |
||||
{ |
||||
CreateSelectedFolderNode(@"d:\projects\MyAspMvcApp\Views\Home"); |
||||
|
||||
IProject project = selectedFolderNode.Project.Project; |
||||
|
||||
Assert.AreEqual(projectForSelectedFolder, project); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue