Esempio n. 1
0
        public async Task Then_GetEpaOrganisationData(string type)
        {
            var epaoId = _autoFixture.Create <string>();

            await MergeController.ConfirmEpao(type, epaoId, null);

            _mockApiClient.Verify(c => c.GetEpaOrganisation(epaoId), Times.Once());
        }
        public void And_ModelIsValid_Then_RedirectToMergeOverview(string type)
        {
            SetUpGetMergeRequest();

            var viewModel = _autoFixture.Create <ConfirmEpaoViewModel>();

            var result = MergeController.ConfirmEpao(type, viewModel) as RedirectToActionResult;

            result.ActionName.Should().Be(nameof(MergeController.MergeOverview));
        }
        public void And_ModelIsInvalid_Then_ReturnView(string type)
        {
            MergeController.ModelState.AddModelError("Error", "Error message");

            var viewModel = _autoFixture.Create <ConfirmEpaoViewModel>();

            var result = MergeController.ConfirmEpao(type, viewModel) as ViewResult;

            result.Model.Should().BeEquivalentTo(viewModel);
        }
        public void And_ModelIsValid_Then_UpdateMergeRequest(string type)
        {
            SetUpGetMergeRequest();

            var viewModel = _autoFixture.Build <ConfirmEpaoViewModel>()
                            .With(vm => vm.MergeOrganisationType, type)
                            .Create();

            MergeController.ConfirmEpao(type, viewModel);

            if (type == "primary")
            {
                _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>(r => r.PrimaryEpao.Id == viewModel.EpaoId)), Times.Once);
            }
            else if (type == "secondary")
            {
                _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>(r => r.SecondaryEpao.Id == viewModel.EpaoId)), Times.Once);
            }
        }