13 changed files with 312 additions and 43 deletions
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
// 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.IO; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class FileSystem : IFileSystem |
||||
{ |
||||
public string[] GetFiles(string path, string searchPattern) |
||||
{ |
||||
return Directory.GetFiles(path, searchPattern); |
||||
} |
||||
} |
||||
} |
@ -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 IFileSystem |
||||
{ |
||||
string[] GetFiles(string path, string searchPattern); |
||||
} |
||||
} |
@ -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 IMvcTextTemplateRepository |
||||
{ |
||||
IEnumerable<MvcControllerTextTemplate> GetMvcControllerTextTemplates(MvcTextTemplateCriteria templateCriteria); |
||||
} |
||||
} |
@ -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; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.AspNet.Mvc; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeFileSystem : IFileSystem |
||||
{ |
||||
Dictionary<string, string[]> directoryFiles = new Dictionary<string, string[]>(); |
||||
|
||||
public void AddFakeFiles(string path, string searchPattern, string[] files) |
||||
{ |
||||
string key = GetKey(path, searchPattern); |
||||
directoryFiles.Add(key, files); |
||||
} |
||||
|
||||
string GetKey(string path, string searchPattern) |
||||
{ |
||||
return path + " - " + searchPattern; |
||||
} |
||||
|
||||
public string[] GetFiles(string path, string searchPattern) |
||||
{ |
||||
string key = GetKey(path, searchPattern); |
||||
string[] files = null; |
||||
if (directoryFiles.TryGetValue(key, out files)) { |
||||
return files; |
||||
} |
||||
return new string[0]; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// 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 FakeMvcTextTemplateRepository : IMvcTextTemplateRepository |
||||
{ |
||||
public List<MvcControllerTextTemplate> ControllerTextTemplates = new List<MvcControllerTextTemplate>(); |
||||
public MvcTextTemplateCriteria TemplateCriteriaPassedToGetMvcControllerTextTemplates; |
||||
|
||||
public IEnumerable<MvcControllerTextTemplate> GetMvcControllerTextTemplates(MvcTextTemplateCriteria templateCriteria) |
||||
{ |
||||
TemplateCriteriaPassedToGetMvcControllerTextTemplates = templateCriteria; |
||||
return ControllerTextTemplates; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// 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 NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public static class MvcControllerTextTemplateCollectionAssert |
||||
{ |
||||
public static void AreEqual(IEnumerable<MvcControllerTextTemplate> expected, IEnumerable<MvcControllerTextTemplate> actual) |
||||
{ |
||||
List<string> expectedAsStrings = ConvertToStrings(expected); |
||||
List<string> actualAsStrings = ConvertToStrings(actual); |
||||
|
||||
CollectionAssert.AreEqual(expectedAsStrings, actualAsStrings); |
||||
} |
||||
|
||||
static List<string> ConvertToStrings(IEnumerable<MvcControllerTextTemplate> templates) |
||||
{ |
||||
var templatesAsStrings = new List<string>(); |
||||
foreach (MvcControllerTextTemplate template in templates) { |
||||
string templateAsString = ConvertToString(template); |
||||
templatesAsStrings.Add(templateAsString); |
||||
} |
||||
return templatesAsStrings; |
||||
} |
||||
|
||||
static string ConvertToString(MvcControllerTextTemplate template) |
||||
{ |
||||
return String.Format( |
||||
"Name: {0}, Description: {1}, AddActionMethods: {2}, FileName: {3}", |
||||
template.Name, template.Description, template.AddActionMethods, template.FileName); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue