Ejemplo n.º 1
0
        public void ShouldIncrementSavedVacancyCount(int savedAndDraftCount)
        {
            // Arrange.
            var viewModel = new SavedVacancyViewModel();

            ApprenticeshipApplicationProvider
            .Setup(mock => mock.SaveVacancy(_testCandidateId, TestVacancyId))
            .Returns(viewModel);

            UserDataProvider
            .Setup(mock => mock.Get(UserDataItemNames.SavedAndDraftCount))
            .Returns(savedAndDraftCount.ToString(CultureInfo.InvariantCulture));

            // Act.
            var response = Mediator.SaveVacancy(_testCandidateId, TestVacancyId);

            // Assert.
            UserDataProvider.Verify(mock => mock.Get(UserDataItemNames.SavedAndDraftCount), Times.Once);
            UserDataProvider.Verify(
                mock =>
                mock.Push(UserDataItemNames.SavedAndDraftCount,
                          (savedAndDraftCount + 1).ToString(CultureInfo.InvariantCulture)), Times.Once);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.SaveVacancy.Ok, true);
            response.ViewModel.Should().Be(viewModel);
        }
Ejemplo n.º 2
0
        public void ShouldSetSavedVacancyCountToZero(string savedAndDraftCount)
        {
            // Arrange.
            var viewModel = new SavedVacancyViewModel();

            ApprenticeshipApplicationProvider
            .Setup(mock => mock.DeleteSavedVacancy(_testCandidateId, TestVacancyId))
            .Returns(viewModel);

            UserDataProvider
            .Setup(mock => mock.Get(UserDataItemNames.SavedAndDraftCount))
            .Returns(savedAndDraftCount);

            // Act.
            var response = Mediator.DeleteSavedVacancy(_testCandidateId, TestVacancyId);

            // Assert.
            UserDataProvider.Verify(mock => mock.Get(UserDataItemNames.SavedAndDraftCount), Times.Once);
            UserDataProvider.Verify(mock => mock.Push(UserDataItemNames.SavedAndDraftCount, "0"), Times.Once);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.DeleteSavedVacancy.Ok, true);
            response.ViewModel.Should().Be(viewModel);
        }