Exemple #1
0
        public async void ProposalsFunctionalityTest()
        {
            _token = await _accountManagementService.SignIn(TestingObjectProvider.Instance.Login);

            Assert.NotNull(_token);

            var proposal = TestingObjectProvider.Instance.Proposal;

            var restServiceMock = new Mock <IRestService>();

            restServiceMock.Setup(s => s.ExecuteGetAction <List <Proposal> >(
                                      It.IsAny <string>(),
                                      It.IsAny <string>(),
                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <Proposal>()
            {
                proposal
            });

            restServiceMock.Setup(s => s.ExecutePostAction <ActivationMessage>(
                                      It.IsAny <string>(),
                                      It.IsAny <ActivationMessage>(),
                                      It.IsAny <string>(),
                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(true);

            restServiceMock.Setup(s => s.ExecutePutAction <Proposal>(
                                      It.IsAny <string>(),
                                      It.IsAny <Proposal>(),
                                      It.IsAny <string>(),
                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(true);

            var options = ServiceProvider.Instance.Resolve <IOptions <AppSettings> >();
            var proposalManagementService =
                new ProposalsManagementService(restServiceMock.Object, options)
            {
                RequestUri           = RequestUriHelper.ProposalsUri,
                ActivationRequestUri = RequestUriHelper.ProposalsUri
            };

            Assert.NotNull(_proposalsManagementService.CreateProposal(proposal, _token.Jwt).Result);
            Assert.True(_proposalsManagementService.DeleteProposal(proposal, _token.Jwt).Result);
            Assert.True(_proposalsManagementService.UpdateProposal(proposal, _token.Jwt).Result);
            Assert.NotNull(proposalManagementService.RequestUri);
            Assert.NotNull(proposalManagementService.ActivationRequestUri);
            Assert.True(proposalManagementService.SendActivationEmail(proposal.Id, _token.Jwt).Result);
            Assert.NotNull(proposalManagementService.GetProposal(proposal.Id, _token.Jwt).Result);
        }
        public async Task <IActionResult> Edit(Proposal proposal, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(proposal));
            }

            if (await _proposalsManagementService.UpdateProposal(proposal, CurrentCookiesToken, cancellationToken))
            {
                return(Json(new { success = true }));
            }

            CheckUnexpectedErrors();
            return(PartialView(proposal));
        }
 public void TestOfUpdatingProposal()
 {
     Assert.True(_proposalsManagementService.UpdateProposal(_testingProposal, _token.Jwt).Result);
 }