本文整理匯總了C#中System.Web.Mvc.Test.MockBuildManager類的典型用法代碼示例。如果您正苦於以下問題:C# MockBuildManager類的具體用法?C# MockBuildManager怎麽用?C# MockBuildManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MockBuildManager類屬於System.Web.Mvc.Test命名空間,在下文中一共展示了MockBuildManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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."
);
}
示例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);
}
示例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>."
);
}
示例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."
);
}
示例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);
}
示例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"
);
}
示例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>."
);
}
示例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();
}
示例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);
}