Exemplo n.º 1
0
        public async Task ItShouldReturnTheChallengeForm()
        {
            var downloadedFormHtml = "<html><form action='' method='post' /></html>";
            var mappedFormHtml     = "<html><form action='/api/challenge/id'  method='post' /></html>";


            MockSiteConnector.Setup(c => c.Download(It.IsAny <Uri>()))
            .ReturnsAsync(downloadedFormHtml);

            MockFormMapper.Setup(x => x.UpdateForm(
                                     It.IsAny <SupportServiceResourceKey>(),
                                     It.IsAny <SupportServiceResourceKey>(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>()
                                     ))
            .Returns(mappedFormHtml);

            var actual = await Unit.GetChallengeForm(
                SupportServiceResourceKey.EmployerAccountFinance,
                SupportServiceResourceKey.EmployerAccountFinanceChallenge,
                "id",
                "http://tempuri.org/challenge/form");

            Assert.IsFalse(string.IsNullOrWhiteSpace(actual));
            Assert.IsTrue(actual.Contains("<html"));
            Assert.IsTrue(actual.Contains("<form"));
        }
        public async Task ItShouldReceiveAFormResponseOnFail()
        {
            var mappedFormHtml = "<form action='/api/challenge/id'  method='post' />";

            MockFormMapper.Setup(x => x.UpdateForm(
                                     It.IsAny <SupportServiceResourceKey>(),
                                     It.IsAny <SupportServiceResourceKey>(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>()
                                     ))
            .Returns(mappedFormHtml);


            MockSiteConnector
            .Setup(x => x.Upload <string>(It.IsAny <Uri>(), It.IsAny <IDictionary <string, string> >()))
            .ReturnsAsync(mappedFormHtml);

            MockSiteConnector.SetupGet(x => x.LastCode).Returns(HttpStatusCode.OK);

            var result = await Unit.SubmitChallenge(_id, _submittedFormData);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.HasRedirect);
            Assert.IsNull(result.RedirectUrl);
            Assert.AreEqual(mappedFormHtml, result.Page);
        }