public void InputviewEngines_InstanceOf_ThrowsInvalidOperationExceptionIfMoreThanOnceInstance() { // Arrange var viewEngines = new MvcViewOptions().ViewEngines; viewEngines.Add(new TestViewEngine()); viewEngines.Add(Mock.Of<IViewEngine>()); viewEngines.Add(new TestViewEngine()); // Act & Assert Assert.Throws<InvalidOperationException>(() => viewEngines.InstanceOf<TestViewEngine>()); }
public void InputviewEngines_InstanceOf_ThrowsInvalidOperationExceptionIfNoInstance() { // Arrange var viewEngines = new MvcViewOptions().ViewEngines; viewEngines.Add(Mock.Of <IViewEngine>()); viewEngines.Add(typeof(TestViewEngine)); // Act & Assert Assert.Throws <InvalidOperationException>(() => viewEngines.InstanceOf <TestViewEngine>()); }
public void InputviewEngines_InstanceOf_ReturnsInstanceOfIInputFormatterIfOneExists() { // Arrange var viewEngines = new MvcViewOptions().ViewEngines; viewEngines.Add(Mock.Of <IViewEngine>()); var testEngine = new TestViewEngine(); viewEngines.Add(testEngine); viewEngines.Add(typeof(TestViewEngine)); // Act var formatter = viewEngines.InstanceOf <TestViewEngine>(); // Assert Assert.NotNull(formatter); Assert.IsType <TestViewEngine>(formatter); Assert.Same(testEngine, formatter); }
public void InputviewEngines_InstanceOf_ReturnsInstanceOfIInputFormatterIfOneExists() { // Arrange var viewEngines = new MvcViewOptions().ViewEngines; viewEngines.Add(Mock.Of<IViewEngine>()); var testEngine = new TestViewEngine(); viewEngines.Add(testEngine); viewEngines.Add(typeof(TestViewEngine)); // Act var formatter = viewEngines.InstanceOf<TestViewEngine>(); // Assert Assert.NotNull(formatter); Assert.IsType<TestViewEngine>(formatter); Assert.Same(testEngine, formatter); }