예제 #1
0
        public void Evidence_POST_RemoveFile()
        {
            WebAppTest(client =>
            {
                // prep this test by adding a file to remove
                var cloudName = System.Guid.NewGuid().ToString();
                var detail    = NewCocDetail("form123");

                detail.Evidence.Files.Add(new EvidenceFile {
                    Name = "UploadedFile.pdf", CloudName = cloudName
                });
                ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail);

                // now remove it
                var response = client.Get(CocActions.Evidence(detail.Id))
                               .Form <EvidenceFile>(1)
                               .SubmitName(CocButtons.RemoveFile, client);

                ExecutorStub.Executed <RemoveEvidenceFile>(0).ShouldBeEquivalentTo(new RemoveEvidenceFile
                {
                    FormId    = "form123",
                    CloudName = cloudName,
                });

                response.ActionResultOf <RedirectResult>().Url.Should().Be(CocActions.Evidence("form123"));
            });
        }
예제 #2
0
        public void Evidence_POST_ErrorsAreDisplayed()
        {
            WebAppTest(client =>
            {
                ExecutorStub.SetupCommand <AddEvidence, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); });

                var response = client.Get(CocActions.Evidence("form123")).Form <Evidence>(1)
                               .SubmitName("", client, r => r.SetExpectedResponse(HttpStatusCode.OK));

                response.Doc.Find(".validation-summary-errors").Should().NotBeNull();
            });
        }
예제 #3
0
        public void Evidence_GET_PopulatesExistingDetails()
        {
            WebAppTest(client =>
            {
                var detail = NewCocDetail("form123");
                ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail);

                var response = client.Get(CocActions.Evidence(detail.Id));

                ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection {
                    FormId = detail.Id, Section = Sections.Evidence
                });
                response.Doc.Form <Evidence>(1).GetConfirm(m => m.SendingByPost).Should().Be(detail.Evidence.SendingByPost);
                response.Doc.Document.Body.TextContent.Should().Contain("No files uploaded");
            });
        }
예제 #4
0
        public void Evidence_POST_PopulatesEvidence()
        {
            WebAppTest(client =>
            {
                var response = client.Get(CocActions.Evidence("form123")).Form <Evidence>(1)
                               .SelectConfirm(m => m.SendingByPost, true)
                               .SubmitName("", client);

                ExecutorStub.Executed <AddEvidence>(0).ShouldBeEquivalentTo(new AddEvidence
                {
                    FormId   = "form123",
                    Evidence = new Evidence {
                        SendingByPost = true
                    },
                });

                response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace();
            });
        }
예제 #5
0
        public void Evidence_POST_UploadFile()
        {
            WebAppTest(client =>
            {
                var response = client.Get(CocActions.Evidence("form123"));

                response = response.Form <Evidence>(1)
                           .AddFile("UploadedFile.pdf", Encoding.ASCII.GetBytes("uploaded content"))
                           .SubmitName(CocButtons.UploadFile, client);

                ExecutorStub.Executed <AddEvidenceFile>(0).ShouldBeEquivalentTo(new AddEvidenceFile
                {
                    FormId   = "form123",
                    Filename = "UploadedFile.pdf",
                    Content  = Encoding.ASCII.GetBytes("uploaded content"),
                });

                response.ActionResultOf <RedirectResult>().Url.Should().Be(CocActions.Evidence("form123"));
            });
        }