コード例 #1
0
        public void Then_The_ActualEndDate_Is_Not_Updated(Status status)
        {
            var dbActualEndDate      = DateTime.Now.AddDays(-1);
            var paymentActualEndDate = DateTime.Now.AddDays(-2);
            var commitment           = new CommitmentModel
            {
                EmployerAccountId    = 12345,
                ApprenticeName       = "Mr Test Tester",
                ApprenticeshipId     = 88775544,
                ActualEndDate        = paymentActualEndDate,
                StartDate            = DateTime.Today,
                PlannedEndDate       = DateTime.Today.AddMonths(12),
                MonthlyInstallment   = 10m,
                CompletionAmount     = 100m,
                NumberOfInstallments = 12
            };

            var employerCommitment = new EmployerCommitment(new CommitmentModel {
                Id = 65421, Status = status, ActualEndDate = dbActualEndDate
            });

            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsTrue(actual);
            Assert.AreEqual(dbActualEndDate, employerCommitment.ActualEndDate);
        }
コード例 #2
0
        public void Then_If_It_Is_An_Existing_Commitment_And_The_Allowed_Updated_Values_Are_Changed_True_Is_Retruned()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                EmployerAccountId    = 12345,
                ApprenticeName       = "Mr Test Tester",
                ApprenticeshipId     = 88775544,
                ActualEndDate        = DateTime.Today.AddMonths(11),
                StartDate            = DateTime.Today,
                PlannedEndDate       = DateTime.Today.AddMonths(12),
                MonthlyInstallment   = 10m,
                CompletionAmount     = 100m,
                NumberOfInstallments = 12
            };
            var employerCommitment = new EmployerCommitment(new CommitmentModel {
                Id = 65421
            });

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsTrue(actual);
            Assert.AreEqual(commitment.ApprenticeName, employerCommitment.ApprenticeName);
            Assert.AreEqual(commitment.ApprenticeshipId, employerCommitment.ApprenticeshipId);
            Assert.AreEqual(commitment.StartDate, employerCommitment.StartDate);
            Assert.AreEqual(commitment.PlannedEndDate, employerCommitment.PlannedEndDate);
            Assert.AreEqual(commitment.MonthlyInstallment, employerCommitment.MonthlyInstallment);
            Assert.AreEqual(commitment.CompletionAmount, employerCommitment.CompletionAmount);
            Assert.AreEqual(commitment.NumberOfInstallments, employerCommitment.NumberOfInstallments);
        }
コード例 #3
0
        public async Task Then_The_Commitment_Is_Not_Stored_If_The_Registration_Check_Fails()
        {
            //Arrange
            _commitmentModel = new CommitmentModel
            {
                ApprenticeshipId  = ExpectedApprenticeshipId,
                EmployerAccountId = ExpectedEmployerAccountId,
                ActualEndDate     = null,
                Id = 3322,
                CompletionAmount = 100
            };
            _paymentMapper.Setup(x =>
                                 x.MapToCommitment(It.Is <PaymentCreatedMessage>(c =>
                                                                                 c.EmployerAccountId.Equals(ExpectedEmployerAccountId))))
            .Returns(_commitmentModel);
            _employerCommitment = new EmployerCommitment(_commitmentModel);
            _employerCommitmentRepostiory.Setup(x => x.Get(ExpectedEmployerAccountId, ExpectedApprenticeshipId))
            .ReturnsAsync(_employerCommitment);
            _handler = new Application.Commitments.Handlers.StoreCommitmentHandler(_employerCommitmentRepostiory.Object, _logger.Object, _paymentMapper.Object, new Mock <ITelemetry>().Object, new Apprenticeship.Mapping.ApprenticeshipMapping(), _queueServiceMock.Object);

            //Act
            await _handler.Handle(_message, _allowProjectionQueueName);

            //Assert
            _queueServiceMock.Verify(v => v.SendMessageWithVisibilityDelay(It.Is <PaymentCreatedMessage>(m => m == _message), It.Is <string>(s => s == _allowProjectionQueueName)), Times.Never);
            _employerCommitmentRepostiory.Verify(x => x.Store(It.IsAny <EmployerCommitment>()), Times.Never());
        }
コード例 #4
0
        public void Then_If_It_Is_A_New_Commitment_With_An_AcutalEndDate_Then_False_Is_Returned()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                Id            = 554433,
                ActualEndDate = DateTime.Today
            };
            var employerCommitment = new EmployerCommitment(new CommitmentModel());

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsFalse(actual);
        }
コード例 #5
0
        public void Then_If_No_EmployerAccountId_Has_Been_Supplied_False_Is_Returned()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                EmployerAccountId = 0,
                ApprenticeName    = "Mr Test Tester"
            };
            var employerCommitment = new EmployerCommitment(new CommitmentModel());

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsFalse(actual);
        }
コード例 #6
0
        public void Then_If_It_Is_A_New_Commitment_And_An_ActualEndDate_Has_Been_Supplied_False_Is_Returned()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                EmployerAccountId = 12345,
                ApprenticeName    = "Mr Test Tester",
                ActualEndDate     = DateTime.Today
            };
            var employerCommitment = new EmployerCommitment(new CommitmentModel());

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsFalse(actual);
        }
コード例 #7
0
        public void Then_The_Values_Are_Mapped_And_Updated_If_Valid()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                Id                       = 554433,
                ApprenticeName           = "Tester",
                ApprenticeshipId         = 774411,
                CompletionAmount         = 5432m,
                CourseLevel              = 3,
                CourseName               = "Test"
                , EmployerAccountId      = 55443,
                FundingSource            = FundingSource.Transfer,
                LearnerId                = 12345,
                MonthlyInstallment       = 10m,
                NumberOfInstallments     = 10,
                PlannedEndDate           = DateTime.Today.AddMonths(12),
                StartDate                = DateTime.Today,
                ProviderId               = 443322,
                ProviderName             = "Test Provider",
                SendingEmployerAccountId = 12233
            };
            var employerCommitment = new EmployerCommitment(new CommitmentModel());

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsTrue(actual);
            Assert.AreEqual(commitment.ActualEndDate, employerCommitment.ActualEndDate);
            Assert.AreEqual(commitment.ApprenticeName, employerCommitment.ApprenticeName);
            Assert.AreEqual(commitment.ApprenticeshipId, employerCommitment.ApprenticeshipId);
            Assert.AreEqual(commitment.CompletionAmount, employerCommitment.CompletionAmount);
            Assert.AreEqual(commitment.CourseLevel, employerCommitment.CourseLevel);
            Assert.AreEqual(commitment.CourseName, employerCommitment.CourseName);
            Assert.AreEqual(commitment.EmployerAccountId, employerCommitment.EmployerAccountId);
            Assert.AreEqual(commitment.FundingSource, employerCommitment.FundingSource);
            Assert.AreEqual(commitment.LearnerId, employerCommitment.LearnerId);
            Assert.AreEqual(commitment.MonthlyInstallment, employerCommitment.MonthlyInstallment);
            Assert.AreEqual(commitment.NumberOfInstallments, employerCommitment.NumberOfInstallments);
            Assert.AreEqual(commitment.PlannedEndDate, employerCommitment.PlannedEndDate);
            Assert.AreEqual(commitment.StartDate, employerCommitment.StartDate);
            Assert.AreEqual(commitment.ProviderId, employerCommitment.ProviderId);
            Assert.AreEqual(commitment.ProviderName, employerCommitment.ProviderName);
            Assert.AreEqual(commitment.SendingEmployerAccountId, employerCommitment.SendingEmployerAccountId);
        }
コード例 #8
0
        public void Then_If_The_AcutalEndDate_ApprenticeshipName_Or_ApprenticeshipId_Have_Not_Changed_False_Is_Returned()
        {
            //Arrange
            var commitment = new CommitmentModel
            {
                Id = 554433,
                EmployerAccountId = 12345,
                ApprenticeName    = "Tester",
                ApprenticeshipId  = 774411,
                ActualEndDate     = DateTime.Today
            };
            var employerCommitment = new EmployerCommitment(commitment);

            //Act
            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsFalse(actual);
        }
コード例 #9
0
        public void Then_The_Status_Is_NotChange_For_An_Existing_Record(Status?status)
        {
            var commitment = new CommitmentModel
            {
                EmployerAccountId    = 12345,
                ApprenticeName       = "Mr Test Tester",
                ApprenticeshipId     = 88775544,
                StartDate            = DateTime.Today,
                PlannedEndDate       = DateTime.Today.AddMonths(12),
                MonthlyInstallment   = 10m,
                CompletionAmount     = 100m,
                NumberOfInstallments = 12
            };

            var employerCommitment = new EmployerCommitment(new CommitmentModel {
                Id = 65421, Status = status, ApprenticeshipId = 88775544
            });

            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsTrue(actual);
            Assert.AreEqual(status, employerCommitment.Status);
        }
コード例 #10
0
        public void Then_The_Status_Is_LiveOrWaitingToStart_For_A_New_Record()
        {
            var commitment = new CommitmentModel
            {
                EmployerAccountId    = 12345,
                ApprenticeName       = "Mr Test Tester",
                ApprenticeshipId     = 88775544,
                StartDate            = DateTime.Today,
                PlannedEndDate       = DateTime.Today.AddMonths(12),
                MonthlyInstallment   = 10m,
                CompletionAmount     = 100m,
                NumberOfInstallments = 12
            };

            var employerCommitment = new EmployerCommitment(new CommitmentModel {
                Id = 0
            });

            var actual = employerCommitment.RegisterCommitment(commitment);

            //Assert
            Assert.IsTrue(actual);
            Assert.AreEqual(Status.LiveOrWaitingToStart, employerCommitment.Status);
        }
コード例 #11
0
        public void Arrange()
        {
            _message = new PaymentCreatedMessage
            {
                EmployerAccountId = ExpectedEmployerAccountId,
                ApprenticeshipId  = ExpectedApprenticeshipId,
                EarningDetails    = new EarningDetails()
            };
            _commitmentModel = new CommitmentModel
            {
                EmployerAccountId = ExpectedEmployerAccountId,
                CompletionAmount  = 100
            };

            _employerCommitment = new EmployerCommitment(_commitmentModel);

            _employerCommitmentRepostiory = new Mock <IEmployerCommitmentRepository>();

            _logger = new Mock <ILog>();

            _paymentMapper = new Mock <IPaymentMapper>();
            _paymentMapper.Setup(x =>
                                 x.MapToCommitment(It.Is <PaymentCreatedMessage>(c =>
                                                                                 c.EmployerAccountId.Equals(ExpectedEmployerAccountId))))
            .Returns(_commitmentModel);
            _employerCommitmentRepostiory.Setup(x => x.Get(ExpectedEmployerAccountId, ExpectedApprenticeshipId))
            .ReturnsAsync(_employerCommitment);

            _queueServiceMock = new Mock <IQueueService>();
            _handler          = new Application.Commitments.Handlers.StoreCommitmentHandler(
                _employerCommitmentRepostiory.Object,
                _logger.Object,
                _paymentMapper.Object,
                new Mock <ITelemetry>().Object,
                new Apprenticeship.Mapping.ApprenticeshipMapping(), _queueServiceMock.Object);
        }