Exemplo n.º 1
0
        public void Should_return_null_when_getting_view_location_with_no_view_source_provider()
        {
            // Given
            var locator = new DefaultViewLocator(new IViewSourceProvider[] { });

            // When
            var result = locator.GetViewLocation("viewName", Enumerable.Empty <string>());

            // Then
            result.ShouldBeNull();
        }
Exemplo n.º 2
0
        public void Should_return_null_when_getting_view_location_with_empty_view_null()
        {
            // Given
            var locator = new DefaultViewLocator(new[] { A.Fake <IViewSourceProvider>() });

            // When
            var result = locator.GetViewLocation(string.Empty, Enumerable.Empty <string>());

            // Then
            result.ShouldBeNull();
        }
Exemplo n.º 3
0
        public void Should_return_null_when_getting_view_location_with_null_supported_view_engine_extensions()
        {
            // Given
            var locator = new DefaultViewLocator(new[] { A.Fake <IViewSourceProvider>() });

            // When
            var result = locator.GetViewLocation("viewName", null);

            // Then
            result.ShouldBeNull();
        }
Exemplo n.º 4
0
        public void Should_suppress_exceptions_thrown_by_view_source_provider()
        {
            // Given
            var viewSourceProvider = A.Fake <IViewSourceProvider>();

            A.CallTo(() => viewSourceProvider.LocateView(A <string> .Ignored, A <IEnumerable <string> > .Ignored)).Throws(new Exception());

            var locator = new DefaultViewLocator(new[] { viewSourceProvider });

            // When
            var result = locator.GetViewLocation("view name", new[] { "html" });

            // Then
            result.ShouldBeNull();
        }
Exemplo n.º 5
0
        public void Should_return_view_location_result_from_source_provider_when_view_could_be_found()
        {
            // Given
            var viewSourceProvider = A.Fake <IViewSourceProvider>();
            var viewLocationResult = new ViewLocationResult(null, string.Empty, null);
            var locator            = new DefaultViewLocator(new[] { viewSourceProvider });

            A.CallTo(() => viewSourceProvider.LocateView(A <string> .Ignored, A <IEnumerable <string> > .Ignored)).Returns(viewLocationResult);

            // When
            var result = locator.GetViewLocation("view name", new[] { "html" });

            // Then
            result.ShouldBeSameAs(viewLocationResult);
        }
Exemplo n.º 6
0
        public void Should_call_locateview_with_view_name_on_view_source_provider()
        {
            // Given
            const string viewname = "view name";

            var viewSourceProviders = new[] {
                A.Fake <IViewSourceProvider>()
            };

            A.CallTo(() => viewSourceProviders[0].LocateView(viewname, Enumerable.Empty <string>())).Returns(null);

            var locator = new DefaultViewLocator(viewSourceProviders);

            // When
            locator.GetViewLocation(viewname, new[] { "html" });

            // Then
            A.CallTo(() => viewSourceProviders[0].LocateView(viewname, A <IEnumerable <string> > .Ignored)).MustHaveHappened();
        }
Exemplo n.º 7
0
        public void Should_call_locateview_with_supported_view_engine_extensions_on_view_source_provider()
        {
            // Given
            const string viewname = "view name";

            var expectedViewEngineExtensions = new[] { "html" };

            var viewSourceProviders = new[] {
                A.Fake <IViewSourceProvider>()
            };

            A.CallTo(() => viewSourceProviders[0].LocateView(A <string> .Ignored, Enumerable.Empty <string>())).Returns(null);

            var locator = new DefaultViewLocator(viewSourceProviders);

            // When
            locator.GetViewLocation(viewname, new[] { "html" });

            // Then)
            A.CallTo(() => viewSourceProviders[0].LocateView(A <string> .Ignored,
                                                             A <IEnumerable <string> > .That.IsSameSequenceAs(expectedViewEngineExtensions))).MustHaveHappened();
        }