Ejemplo n.º 1
0
        public void InputviewEngines_InstanceOfOrDefault_ThrowsInvalidOperationExceptionIfMoreThanOnceInstance()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;

            viewEngines.Add(new TestViewEngine());
            viewEngines.Add(Mock.Of <IViewEngine>());
            viewEngines.Add(new TestViewEngine());

            // Act & Assert
            Assert.Throws <InvalidOperationException>(() => viewEngines.InstanceOfOrDefault <TestViewEngine>());
        }
Ejemplo n.º 2
0
        public void InputviewEngines_InstanceOfOrDefault_ReturnsNullIfNoInstance()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;

            viewEngines.Add(Mock.Of <IViewEngine>());
            viewEngines.Add(typeof(TestViewEngine));

            // Act
            var formatter = viewEngines.InstanceOfOrDefault <TestViewEngine>();

            // Assert
            Assert.Null(formatter);
        }
Ejemplo n.º 3
0
        public void InputviewEngines_InstanceOfOrDefault_ReturnsInstanceOfIInputFormatterIfOneExists()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;

            viewEngines.Add(Mock.Of <IViewEngine>());
            viewEngines.Add(typeof(TestViewEngine));
            var testEngine = new TestViewEngine();

            viewEngines.Add(testEngine);

            // Act
            var formatter = viewEngines.InstanceOfOrDefault <TestViewEngine>();

            // Assert
            Assert.NotNull(formatter);
            Assert.IsType <TestViewEngine>(formatter);
            Assert.Same(testEngine, formatter);
        }
        public void InputviewEngines_InstanceOfOrDefault_ReturnsInstanceOfIInputFormatterIfOneExists()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;
            viewEngines.Add(Mock.Of<IViewEngine>());
            viewEngines.Add(typeof(TestViewEngine));
            var testEngine = new TestViewEngine();
            viewEngines.Add(testEngine);

            // Act
            var formatter = viewEngines.InstanceOfOrDefault<TestViewEngine>();

            // Assert
            Assert.NotNull(formatter);
            Assert.IsType<TestViewEngine>(formatter);
            Assert.Same(testEngine, formatter);
        }
        public void InputviewEngines_InstanceOfOrDefault_ReturnsNullIfNoInstance()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;
            viewEngines.Add(Mock.Of<IViewEngine>());
            viewEngines.Add(typeof(TestViewEngine));

            // Act
            var formatter = viewEngines.InstanceOfOrDefault<TestViewEngine>();

            // Assert
            Assert.Null(formatter);
        }
        public void InputviewEngines_InstanceOfOrDefault_ThrowsInvalidOperationExceptionIfMoreThanOnceInstance()
        {
            // Arrange
            var viewEngines = new MvcOptions().ViewEngines;
            viewEngines.Add(new TestViewEngine());
            viewEngines.Add(Mock.Of<IViewEngine>());
            viewEngines.Add(new TestViewEngine());

            // Act & Assert
            Assert.Throws<InvalidOperationException>(() => viewEngines.InstanceOfOrDefault<TestViewEngine>());
        }