public async Task CspReport()
        {
            var dataController = new DataControllerBuilder()
                                 .Build();
            var appSettings = new AppSettings()
            {
                Csp = this.BuildCsp()
            };

            var cspReportRequest = new CspReportRequest()
            {
                CspReport = new CspReport()
                {
                    BlockedUri         = "/CspReport",
                    DocumentUri        = appSettings.Csp.Report,
                    OriginalPolicy     = "self",
                    EffectiveDirective = "self",
                    Referrer           = "self",
                    ViolatedDirective  = "script-src",
                    StatusCode         = 200
                }
            };

            var actionResult = await dataController.CspReport(cspReportRequest);

            actionResult.Should().NotBeNull("because the default response from HomeController is a valid result.");
            actionResult.Should().BeAssignableTo <OkResult>("because the default response from HomeController is a valid OkResult.");
        }
Beispiel #2
0
        public async Task GetDefaultBlogPageTest(int maxResults)
        {
            var controller = new DataControllerBuilder().Build();

            var blogElements = await controller.GetBlogPage("201901", maxResults);

            blogElements.Should().NotBeNull();
        }
Beispiel #3
0
        public async Task WithPairingServiceNoPairings()
        {
            var dataController = new DataControllerBuilder()
                                 .WithPairingService(new PairingServiceBuilder().WithNoPairings().Build())
                                 .Build();

            var result = await dataController.Pairing(1, 1);

            result.Should().NotBeNull(ResultEmptyList);
        }
        public async Task WithNullMainContentService()
        {
            var controller = new DataControllerBuilder()
                             .WithMainContentService(null)
                             .Build();

            var result = await controller.GetBlogPage("201901", 1);

            result.Should().NotBeNull(ResultEmptyList);
        }
        public async Task WithNullMainContentService()
        {
            var controller = new DataControllerBuilder()
                             .WithMainContentService(null)
                             .Build();
            var reason = "because it should return default empty MainContent data.";
            var result = await controller.GetMainContent(Language.English);

            result.Should().NotBeNull(reason);
        }
Beispiel #6
0
        public async Task WithPairingServiceNoSelectOptions()
        {
            var dataController = new DataControllerBuilder()
                                 .WithPairingService(new PairingServiceBuilder().WithNoSelectOptions().Build())
                                 .Build();

            var result = await dataController.Currencies();

            result.Should().NotBeNull(ResultEmptyList);
        }
        public async Task WithValidLanguageMainContentService()
        {
            var controller = new DataControllerBuilder()
                             .WithMainContentService(
                new MainContentServiceBuilder()
                .WithLanguageMainContent(this.mainContentBuilder.Build(), Language.English)
                .Build())
                             .Build();
            var reason = "because it should return english data when language is unknown.";
            var result = await controller.GetMainContent(Language.English);

            result.Should().NotBeNull(reason);
        }
Beispiel #8
0
        public void WithNullPairingService()
        {
            var dataController = new DataControllerBuilder()
                                 .WithPairingService(null)
                                 .Build();

            IEnumerable <Pairing> result  = null;
            Func <Task>           pairing = async() => result = await dataController.Pairing(1, 1);

            pairing.Should().NotThrow <NullReferenceException>("because it should return default empty Pairing data.");

            result.Should().NotBeNull(ResultEmptyList)
            .And.BeEmpty(ResultEmptyList);
        }
Beispiel #9
0
        public async Task PostBlogElementNoServiceTest()
        {
            var blogElement = new BlogElementBuilder().Build();
            var controller  = new DataControllerBuilder()
                              .WithBlogContentService(null)
                              .Build();

            var result = await controller.PostBlog(new BlogElementRequest()
            {
                BlogElement = blogElement
            });

            result.Should().BeFalse();
        }
Beispiel #10
0
        public async Task GetBlogContentNullTest()
        {
            var blogElement    = new BlogElementBuilder().Build();
            var contentService = new BlogContentServiceBuilder()
                                 .WithBlogElement(blogElement)
                                 .Build();
            var controller = new DataControllerBuilder()
                             .WithBlogContentService(null)
                             .Build();

            var result = await controller.GetBlogContent(0);

            result.Should().NotBeNull();
        }
        public async Task WithMainContentService()
        {
            var controller = new DataControllerBuilder()
                             .WithMainContentService(
                new MainContentServiceBuilder()
                .WithLanguageMainContent(
                    new MainContentBuilder().Build(),
                    Language.English)
                .Build())
                             .Build();

            var result = await controller.GetBlogPage("201901", 1);

            result.Should().NotBeNull(ResultEmptyList);
        }
Beispiel #12
0
        public async Task PostNullBlogElementTest()
        {
            var blogElement    = new BlogElementBuilder().Build();
            var contentService = new MainContentServiceBuilder()
                                 .Build();
            var controller = new DataControllerBuilder()
                             .WithMainContentService(contentService)
                             .Build();

            var result = await controller.PostBlog(new BlogElementRequest()
            {
                BlogElement = null
            });

            result.Should().BeFalse();
        }
Beispiel #13
0
        public async Task WithPairingServicePairings()
        {
            var pairings = new List <Pairing>();

            pairings.Add(new Pairing());

            var dataController = new DataControllerBuilder()
                                 .WithPairingService(new PairingServiceBuilder()
                                                     .WithPairings(pairings)
                                                     .Build())
                                 .Build();

            var result = await dataController.Pairing(1, 1);

            result.Should().NotBeNull(ResultEmptyList);
            result.Should().BeEquivalentTo(pairings, "because the PairingService returns the injected data.");
        }
Beispiel #14
0
        public async Task WithPairingServiceSelectOptions()
        {
            var selectOptions = new List <SelectOption>();

            selectOptions.Add(new SelectOption());

            var dataController = new DataControllerBuilder()
                                 .WithPairingService(new PairingServiceBuilder()
                                                     .WithSelectOptions(selectOptions)
                                                     .Build())
                                 .Build();

            var result = await dataController.Currencies();

            result.Should().NotBeNull(ResultEmptyList);
            result.Should().BeEquivalentTo(selectOptions, "because the PairingService returns the injected data.");
        }
Beispiel #15
0
        public async Task PostBlogElementTest(bool saveStatus, bool expected)
        {
            var blogElement    = new BlogElementBuilder().Build();
            var contentService = new BlogContentServiceBuilder()
                                 .WithSaveStatus(saveStatus)
                                 .Build();
            var controller = new DataControllerBuilder()
                             .WithBlogContentService(contentService)
                             .Build();

            var result = await controller.PostBlog(new BlogElementRequest()
            {
                BlogElement = blogElement
            });

            result.Should().Be(expected);
        }
Beispiel #16
0
        public async Task GetBlogPageTest()
        {
            var blogElement    = new BlogElementBuilder().Build();
            var contentService = new BlogContentServiceBuilder()
                                 .WithBlogElements(new List <BlogElement>()
            {
                blogElement
            })
                                 .Build();
            var controller = new DataControllerBuilder()
                             .WithBlogContentService(contentService)
                             .Build();

            var blogElements = await controller.GetBlogPage("201901", 0);

            blogElements.Should().NotBeEmpty();
            blogElements.First().Should().Be(blogElement);
        }