本文整理汇总了C#中System.Web.Mvc.Test.MockBuildManager类的典型用法代码示例。如果您正苦于以下问题:C# MockBuildManager类的具体用法?C# MockBuildManager怎么用?C# MockBuildManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockBuildManager类属于System.Web.Mvc.Test命名空间,在下文中一共展示了MockBuildManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildManagerProperty
public void BuildManagerProperty() {
// Arrange
TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
MockBuildManager buildManagerMock = new MockBuildManager(null, null, null);
// Act
engine.BuildManager = buildManagerMock;
// Assert
Assert.AreEqual(engine.BuildManager, buildManagerMock);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:11,代码来源:WebFormViewEngineTest.cs
示例2: BuildManagerProperty
public void BuildManagerProperty() {
// Arrange
var engine = new TestableBuildManagerViewEngine();
var buildManagerMock = new MockBuildManager(expectedVirtualPath: null, compiledType: null);
// Act
engine.BuildManager = buildManagerMock;
// Assert
Assert.AreSame(engine.BuildManager, buildManagerMock);
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:11,代码来源:BuildManagerViewEngineTest.cs
示例3: FileExistsReturnsFalseWhenBuildManagerFileExistsReturnsFalse
public void FileExistsReturnsFalseWhenBuildManagerFileExistsReturnsFalse() {
// Arrange
var engine = new TestableBuildManagerViewEngine();
var buildManagerMock = new MockBuildManager("some path", false);
engine.BuildManager = buildManagerMock;
// Act
bool result = engine.FileExists("some path");
// Assert
Assert.IsFalse(result);
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:12,代码来源:BuildManagerViewEngineTest.cs
示例4: FileExistsReturnsTrueForExistingPath
public void FileExistsReturnsTrueForExistingPath() {
// Arrange
var engine = new TestableBuildManagerViewEngine();
var buildManagerMock = new MockBuildManager("some path", typeof(object));
engine.BuildManager = buildManagerMock;
// Act
bool result = engine.FileExists("some path");
// Assert
Assert.IsTrue(result);
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:12,代码来源:BuildManagerViewEngineTest.cs
示例5: RegisterAllAreas
public void RegisterAllAreas() {
// Arrange
string[] expectedLoadedAreas = new string[] { "AreaRegistrationTest_AreaRegistration" };
AnnotatedRouteCollection routes = new AnnotatedRouteCollection();
MockBuildManager buildManager = new MockBuildManager(new Assembly[] { typeof(AreaRegistrationTest).Assembly });
// Act
AreaRegistration.RegisterAllAreas(routes, buildManager, null);
// Assert
CollectionAssert.AreEquivalent(expectedLoadedAreas, routes._areasLoaded);
}
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:12,代码来源:AreaRegistrationTest.cs
示例6: FileExistsReturnsFalseWhenBuildManagerReturnsNull
public void FileExistsReturnsFalseWhenBuildManagerReturnsNull() {
// Arrange
TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
MockBuildManager buildManagerMock = new MockBuildManager("some path", typeof(object), null);
engine.BuildManager = buildManagerMock;
// Act
bool notFoundResult = engine.PublicFileExists(null, "some path");
// Assert
Assert.IsFalse(notFoundResult);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:12,代码来源:WebFormViewEngineTest.cs
示例7: RenderWithNullViewInstanceThrows
public void RenderWithNullViewInstanceThrows() {
// Arrange
ViewContext context = new Mock<ViewContext>().Object;
MockBuildManager buildManager = new MockBuildManager("view path", compiledType: null);
TestableBuildManagerCompiledView view = new TestableBuildManagerCompiledView(new ControllerContext(), "view path");
view.BuildManager = buildManager;
// Act & Assert
ExceptionHelper.ExpectException<InvalidOperationException>(
() => view.Render(context, new Mock<TextWriter>().Object),
"The view found at 'view path' was not created."
);
}
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:13,代码来源:BuildManagerCompiledViewTest.cs
示例8: FileExistsReturnsTrueForExistingPath
public void FileExistsReturnsTrueForExistingPath() {
// Arrange
TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
object instanceResult = new object();
MockBuildManager buildManagerMock = new MockBuildManager("some path", typeof(object), instanceResult);
engine.BuildManager = buildManagerMock;
// Act
bool foundResult = engine.PublicFileExists(null, "some path");
// Assert
Assert.IsTrue(foundResult);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:13,代码来源:WebFormViewEngineTest.cs
示例9: RenderWithUnsupportedTypeThrows
public void RenderWithUnsupportedTypeThrows() {
// Arrange
ViewContext context = new Mock<ViewContext>().Object;
MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(object), 12345);
WebFormView view = new WebFormView("view path", null);
view.BuildManager = buildManagerMock;
// Act & Assert
ExceptionHelper.ExpectException<InvalidOperationException>(
() => view.Render(context, null),
"The view at 'view path' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>."
);
}
开发者ID:ledgarl,项目名称:Samples,代码行数:13,代码来源:WebFormViewTest.cs
示例10: RenderWithNullViewInstanceThrows
public void RenderWithNullViewInstanceThrows() {
// Arrange
ViewContext context = new Mock<ViewContext>().Object;
MockBuildManager buildManager = new MockBuildManager("view path", typeof(object), null);
WebFormView view = new WebFormView("view path", null);
view.BuildManager = buildManager;
// Act & Assert
ExceptionHelper.ExpectException<InvalidOperationException>(
() => view.Render(context, null),
"The view found at 'view path' could not be created."
);
}
开发者ID:ledgarl,项目名称:Samples,代码行数:13,代码来源:WebFormViewTest.cs
示例11: FileExistsReturnsFalseWhenBuildManagerThrows404
public void FileExistsReturnsFalseWhenBuildManagerThrows404() {
// Arrange
TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
object instanceResult = new object();
MockBuildManager buildManagerMock = new MockBuildManager(new HttpException(404, "HTTP message Not Found"));
engine.BuildManager = buildManagerMock;
// Act
bool notFoundResult = engine.PublicFileExists(null, "some other path");
// Assert
Assert.IsFalse(notFoundResult);
}
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:13,代码来源:WebFormViewEngineTest.cs
示例12: RenderWithNullWriterThrows
public void RenderWithNullWriterThrows() {
// Arrange
RazorView view = new RazorView(new ControllerContext(), "~/viewPath", null, false, Enumerable.Empty<string>());
Mock<ViewContext> viewContextMock = new Mock<ViewContext>();
MockBuildManager buildManager = new MockBuildManager("~/viewPath", typeof(object));
view.BuildManager = buildManager;
// Act & Assert
ExceptionHelper.ExpectArgumentNullException(
() => view.Render(viewContextMock.Object, null),
"writer"
);
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:14,代码来源:RazorViewTest.cs
示例13: RenderWithUnsupportedTypeThrows
public void RenderWithUnsupportedTypeThrows()
{
// Arrange
ViewContext context = new Mock<ViewContext>().Object;
MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(int));
WebFormView view = new WebFormView(new ControllerContext(), "view path", null);
view.BuildManager = buildManagerMock;
// Act & Assert
Assert.Throws<InvalidOperationException>(
() => view.Render(context, null),
"The view at 'view path' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>."
);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:14,代码来源:WebFormViewTest.cs
示例14: ViewCreationConsultsSetActivator
public void ViewCreationConsultsSetActivator() {
// Arrange
object viewInstance = new object();
Mock<IViewPageActivator> activator = new Mock<IViewPageActivator>(MockBehavior.Strict);
ControllerContext controllerContext = new ControllerContext();
activator.Setup(a => a.Create(controllerContext, typeof(object))).Returns(viewInstance).Verifiable();
MockBuildManager buildManager = new MockBuildManager("view path", typeof(object));
BuildManagerCompiledView view = new TestableBuildManagerCompiledView(controllerContext, "view path", activator.Object) { BuildManager = buildManager };
// Act
view.Render(new Mock<ViewContext>().Object, new Mock<TextWriter>().Object);
// Assert
activator.Verify();
}
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:15,代码来源:BuildManagerCompiledViewTest.cs
示例15: TestableBuildManagerViewEngine
public void FileExistsQueriesBuildManagerForFilesThatPathProviderDoesNotFindWhenRunningInPrecompiledNonUpdateableApp()
{
// Arrange
string testPath = "/Path.txt";
var engine = new TestableBuildManagerViewEngine(pathProvider: CreatePathProvider("some random path"));
engine.SetIsPrecompiledNonUpdateableSite(true);
var buildManagerMock = new MockBuildManager(testPath, typeof(object));
engine.BuildManager = buildManagerMock;
// Act
bool result = engine.FileExists(testPath);
// Assert
Assert.True(result);
}
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:15,代码来源:BuildManagerViewEngineTest.cs
示例16: ViewPageActivatorDelegatesToDependencyResolverWhenActivatorResolverIsNull
public void ViewPageActivatorDelegatesToDependencyResolverWhenActivatorResolverIsNull() {
// Arrange
var viewInstance = new object();
var controllerContext = new ControllerContext();
var buildManager = new MockBuildManager("view path", typeof(object));
var dependencyResolver = new Mock<IDependencyResolver>(MockBehavior.Strict);
dependencyResolver.Setup(dr => dr.GetService(typeof(object))).Returns(viewInstance).Verifiable();
// Act
TestableBuildManagerViewEngine engine = new TestableBuildManagerViewEngine(dependencyResolver: dependencyResolver.Object);
engine.ViewPageActivator.Create(controllerContext, typeof(object));
// Assert
dependencyResolver.Verify();
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:15,代码来源:BuildManagerViewEngineTest.cs
示例17: RenderWithViewPageAndMasterRendersView
public void RenderWithViewPageAndMasterRendersView() {
// Arrange
ViewContext context = new Mock<ViewContext>().Object;
MockBuildManager buildManager = new MockBuildManager("view path", typeof(object));
Mock<IViewPageActivator> activator = new Mock<IViewPageActivator>(MockBehavior.Strict);
ControllerContext controllerContext = new ControllerContext();
StubViewPage viewPage = new StubViewPage();
activator.Setup(l => l.Create(controllerContext, typeof(object))).Returns(viewPage);
WebFormView view = new WebFormView(controllerContext, "view path", "master path", activator.Object);
view.BuildManager = buildManager;
// Act
view.Render(context, null);
// Assert
Assert.AreEqual(context, viewPage.ResultViewContext);
Assert.AreEqual("master path", viewPage.MasterLocation);
}
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:18,代码来源:WebFormViewTest.cs
示例18: SaveToCache_ReadFromCache_ReturnsNullIfTypesAreInvalid
public void SaveToCache_ReadFromCache_ReturnsNullIfTypesAreInvalid()
{
//
// SAVING
//
// Arrange
Type[] expectedTypes = new Type[]
{
typeof(object),
typeof(string)
};
TypeCacheSerializer serializer = new TypeCacheSerializer();
string cacheName = "testCache";
MockBuildManager buildManager = new MockBuildManager();
// Act
TypeCacheUtil.SaveTypesToCache(cacheName, expectedTypes, buildManager, serializer);
// Assert
MemoryStream writeStream = buildManager.CachedFileStore[cacheName] as MemoryStream;
Assert.NotNull(writeStream);
byte[] streamContents = writeStream.ToArray();
Assert.NotEqual(0, streamContents.Length);
//
// READING
//
// Arrange
MemoryStream readStream = new MemoryStream(streamContents);
buildManager.CachedFileStore[cacheName] = readStream;
// Act
List<Type> returnedTypes = TypeCacheUtil.ReadTypesFromCache(cacheName, _ => false /* all types are invalid */, buildManager, serializer);
// Assert
Assert.Null(returnedTypes);
}
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:41,代码来源:TypeCacheUtilTest.cs
示例19: GetFilteredTypesFromAssemblies_FallThrough
public void GetFilteredTypesFromAssemblies_FallThrough() {
// Arrange
Type[] expectedTypes = new Type[] {
typeof(TypeCacheValidFoo),
typeof(TypeCacheValidBar)
};
string cacheName = "testCache";
MockBuildManager buildManager = new MockBuildManager();
Predicate<Type> predicate = type => type.IsDefined(typeof(TypeCacheMarkerAttribute), true);
// Act
List<Type> returnedTypes = TypeCacheUtil.GetFilteredTypesFromAssemblies(cacheName, predicate, buildManager);
// Assert
CollectionAssert.AreEquivalent(expectedTypes, returnedTypes, "Correct types were not returned.");
MemoryStream cachedStream = buildManager.CachedFileStore[cacheName] as MemoryStream;
Assert.IsNotNull(cachedStream, "Stream was not created.");
Assert.AreNotEqual(0, cachedStream.ToArray().Length, "Data was not written correctly.");
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:21,代码来源:TypeCacheUtilTest.cs
示例20: GetFilteredTypesFromAssemblies_FallThrough
public void GetFilteredTypesFromAssemblies_FallThrough()
{
// Arrange
Type[] expectedTypes = new Type[]
{
typeof(TypeCacheValidFoo),
typeof(TypeCacheValidBar)
};
string cacheName = "testCache";
MockBuildManager buildManager = new MockBuildManager();
Predicate<Type> predicate = type => type.IsDefined(typeof(TypeCacheMarkerAttribute), true);
// Act
List<Type> returnedTypes = TypeCacheUtil.GetFilteredTypesFromAssemblies(cacheName, predicate, buildManager);
// Assert
Assert.Equal(expectedTypes, returnedTypes.ToArray());
MemoryStream cachedStream = buildManager.CachedFileStore[cacheName] as MemoryStream;
Assert.NotNull(cachedStream);
Assert.NotEqual(0, cachedStream.ToArray().Length);
}
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:23,代码来源:TypeCacheUtilTest.cs
注:本文中的System.Web.Mvc.Test.MockBuildManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论