public WhenResumingAnApprenticeshipFixture(PaymentStatus paymentStatus)
        {
            var fixture = new Fixture();

            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            Now = DateTime.UtcNow;

            CurrentDateTime = new Mock <ICurrentDateTime>();
            CurrentDateTime.Setup(x => x.UtcNow).Returns(Now);
            PauseDate         = Now;
            EndDate           = Now;
            UnitOfWorkContext = new UnitOfWorkContext();

            Cohort = new CommitmentsV2.Models.Cohort()
                     .Set(c => c.Id, 111)
                     .Set(c => c.EmployerAccountId, 222)
                     .Set(c => c.ProviderId, 333);

            UserInfo = fixture.Create <UserInfo>();

            Apprenticeship = fixture.Build <CommitmentsV2.Models.Apprenticeship>()
                             .With(s => s.Cohort, Cohort)
                             .With(s => s.PaymentStatus, paymentStatus)
                             .With(s => s.PauseDate, PauseDate)
                             .Without(s => s.EndDate)
                             .Without(s => s.DataLockStatus)
                             .Without(s => s.EpaOrg)
                             .Without(s => s.ApprenticeshipUpdate)
                             .Without(s => s.Continuation)
                             .Without(s => s.PreviousApprenticeship)
                             .Create();
        }
Esempio n. 2
0
            public WhenCohortIsCreatedTestFixture()
            {
                UnitOfWorkContext = new UnitOfWorkContext();

                ReservationId = _autoFixture.Create <Guid>();
                UserInfo      = _autoFixture.Create <UserInfo>();

                var cohort = new CommitmentsV2.Models.Cohort();

                cohort.SetValue(x => x.ProviderId, _autoFixture.Create <long>());

                ContinuedApprenticeship = new CommitmentsV2.Models.Apprenticeship();
                ContinuedApprenticeship.SetValue(x => x.Id, _autoFixture.Create <long>());
                ContinuedApprenticeship.SetValue(x => x.Cohort, cohort);
                ContinuedApprenticeship.SetValue(x => x.CommitmentId, cohort.Id);
                ContinuedApprenticeship.SetValue(x => x.FirstName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.LastName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.DateOfBirth, _autoFixture.Create <DateTime>());
                ContinuedApprenticeship.SetValue(x => x.Uln, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.EndDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.CourseCode, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.CourseName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.ProgrammeType, _autoFixture.Create <ProgrammeType>());
                ContinuedApprenticeship.SetValue(x => x.EmployerRef, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.ProviderRef, _autoFixture.Create <string>());

                Request = new CommitmentsV2.Models.ChangeOfPartyRequest();
                Request.SetValue(x => x.Apprenticeship, ContinuedApprenticeship);
                Request.SetValue(x => x.ApprenticeshipId, ContinuedApprenticeship.Id);
                Request.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                Request.SetValue(x => x.Price, _autoFixture.Create <int?>());
                Request.SetValue(x => x.OriginatingParty, _autoFixture.Create <Party>());
            }
Esempio n. 3
0
        public void CreateCohort()
        {
            Exception = null;

            try
            {
                Cohort = new CommitmentsV2.Models.Cohort(Provider.UkPrn,
                                                         AccountLegalEntity.AccountId,
                                                         AccountLegalEntity.Id,
                                                         TransferSender?.Id,
                                                         CreatingParty,
                                                         Message,
                                                         UserInfo);

                Cohort.TransferSender = TransferSender;
            }
            catch (ArgumentException ex)
            {
                Exception = ex;
            }
            catch (Exception ex)
            {
                Exception = ex;
            }
        }
Esempio n. 4
0
 public UpdateDraftApprenticeshipValidationTestsFixture WithEmployerCohort()
 {
     Cohort = new CommitmentsV2.Models.Cohort {
         WithParty = Party.Employer, ProviderId = 1
     };
     return(this);
 }
        public EditEndDateRequestCommandHandlerTestsFixture()
        {
            Party             = Party.Employer;
            UnitOfWorkContext = new UnitOfWorkContext();
            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);
            var fixture = new Fixture();

            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            var Cohort = new CommitmentsV2.Models.Cohort()
                         .Set(c => c.Id, 111)
                         .Set(c => c.EmployerAccountId, 222)
                         .Set(c => c.ProviderId, 333)
                         .Set(c => c.AccountLegalEntity, new AccountLegalEntity());
            var Apprenticeship = fixture.Build <CommitmentsV2.Models.Apprenticeship>()
                                 .With(s => s.Cohort, Cohort)
                                 .With(s => s.PaymentStatus, PaymentStatus.Completed)
                                 .With(s => s.EndDate, DateTime.UtcNow)
                                 .With(s => s.CompletionDate, DateTime.UtcNow.AddDays(10))
                                 .With(s => s.StartDate, DateTime.UtcNow.AddDays(-10))
                                 .Without(s => s.DataLockStatus)
                                 .Without(s => s.EpaOrg)
                                 .Without(s => s.ApprenticeshipUpdate)
                                 .Without(s => s.Continuation)
                                 .Without(s => s.PreviousApprenticeship)
                                 .Create();

            Db.Apprenticeships.Add(Apprenticeship);

            Db.SaveChanges();

            ApprenticeshipId = Apprenticeship.Id;

            var authenticationService = new Mock <IAuthenticationService>();

            authenticationService.Setup(x => x.GetUserParty()).Returns(() => Party);

            var lazyProviderDbContext = new Lazy <ProviderCommitmentsDbContext>(() => Db);

            var newEndDate = Apprenticeship.EndDate.Value.AddDays(1);

            Command = new EditEndDateRequestCommand
            {
                ApprenticeshipId = Apprenticeship.Id,
                EndDate          = newEndDate,
                UserInfo         = new UserInfo()
            };

            Handler = new EditEndDateRequestCommandHandler(lazyProviderDbContext,
                                                           Mock.Of <ICurrentDateTime>(),
                                                           authenticationService.Object,
                                                           Mock.Of <ILogger <EditEndDateRequestCommandHandler> >());
        }
        public void LastMessageReflectsTheLastAddedMessage()
        {
            const string testMessage = "TestMessage";
            var          cohort      = new CommitmentsV2.Models.Cohort();

            cohort.Messages.Add(new CommitmentsV2.Models.Message {
                Text = testMessage
            });
            Assert.AreEqual(testMessage, cohort.LastMessage);
        }
Esempio n. 7
0
 public WhenSendingCohortToOtherPartyTestsFixture()
 {
     Now               = DateTime.UtcNow;
     AutoFixture       = new Fixture();
     Party             = Party.None;
     Message           = AutoFixture.Create <string>();
     UserInfo          = AutoFixture.Create <UserInfo>();
     UnitOfWorkContext = new UnitOfWorkContext();
     Cohort            = new CommitmentsV2.Models.Cohort().Set(c => c.Id, 111).Set(x => x.ProviderId, 1);
 }
        public void DraftApprenticeshipCountReflectsTheNumberOfDraftApprenticeships(int count)
        {
            var cohort = new CommitmentsV2.Models.Cohort();

            for (var i = 0; i < count; i++)
            {
                cohort.Apprenticeships.Add(new DraftApprenticeship());
            }

            Assert.AreEqual(count, cohort.DraftApprenticeshipCount);
        }
        public WhenUpdatingCompletionDateFixture()
        {
            Now = DateTime.UtcNow;
            UnitOfWorkContext = new UnitOfWorkContext();

            Cohort = new CommitmentsV2.Models.Cohort()
                     .Set(c => c.Id, 111)
                     .Set(c => c.EmployerAccountId, 222)
                     .Set(c => c.ProviderId, 333);
            Apprenticeship = new CommitmentsV2.Models.Apprenticeship {
                Cohort = Cohort, PaymentStatus = PaymentStatus.Completed
            };
        }
Esempio n. 10
0
            public WhenCohortIsSetFixture()
            {
                var autoFixture = new Fixture();

                UnitOfWorkContext = new UnitOfWorkContext();

                _cohort = new CommitmentsV2.Models.Cohort();
                _cohort.SetValue(x => x.Id, autoFixture.Create <long>());
                _cohort.SetValue(x => x.ProviderId, autoFixture.Create <long>());
                _cohort.SetValue(x => x.EmployerAccountId, autoFixture.Create <long>());

                _changeOfPartyRequest = autoFixture.Create <CommitmentsV2.Models.ChangeOfPartyRequest>();
            }
Esempio n. 11
0
        public WhenApprovingCohortFixture()
        {
            Now               = DateTime.UtcNow;
            AutoFixture       = new Fixture();
            Party             = Party.None;
            Message           = AutoFixture.Create <string>();
            UserInfo          = AutoFixture.Create <UserInfo>();
            UnitOfWorkContext = new UnitOfWorkContext();

            Cohort = new CommitmentsV2.Models.Cohort()
                     .Set(c => c.Id, 111)
                     .Set(c => c.EmployerAccountId, 222)
                     .Set(c => c.ProviderId, 333);
        }
Esempio n. 12
0
        public UpdateDraftApprenticeshipValidationTestsFixture()
        {
            var autoFixture = new Fixture();

            UnitOfWorkContext          = new UnitOfWorkContext();
            DraftApprenticeshipDetails = new DraftApprenticeshipDetails
            {
                TrainingProgramme = new SFA.DAS.CommitmentsV2.Domain.Entities.TrainingProgramme("TEST", "TEST", ProgrammeType.Framework, DateTime.MinValue, DateTime.MaxValue)
            };
            SetupMinimumNameProperties();
            Cohort = new CommitmentsV2.Models.Cohort {
                EditStatus = EditStatus.ProviderOnly, ProviderId = 1
            };
            CurrentDateTime          = new CurrentDateTime(new DateTime(2019, 04, 01, 0, 0, 0, DateTimeKind.Utc));
            AcademicYearDateProvider = new AcademicYearDateProvider(CurrentDateTime);
            UserInfo = autoFixture.Create <UserInfo>();
        }
Esempio n. 13
0
            public UpdatingDraftApprenticeshipTestFixture(Party modifyingParty)
            {
                UnitOfWorkContext = new UnitOfWorkContext();

                ModifyingParty = modifyingParty;
                Cohort         = new CommitmentsV2.Models.Cohort
                {
                    WithParty  = modifyingParty,
                    ProviderId = 1
                };

                UserInfo = new UserInfo
                {
                    UserId          = "user-1",
                    UserDisplayName = "Tester",
                    UserEmail       = "*****@*****.**"
                };
            }
 public WhenCompletingApprenticeshipFixture()
 {
     _fixture           = new Fixture();
     _completionDate    = _fixture.Create <DateTime>();
     _unitOfWorkContext = new UnitOfWorkContext();
     _cohort            = new CommitmentsV2.Models.Cohort
     {
         Id = 234,
         EmployerAccountId = 234,
         ProviderId        = 234
     };
     _apprenticeship = new CommitmentsV2.Models.Apprenticeship
     {
         Id        = 64,
         Cohort    = _cohort,
         StartDate = new DateTime(2020, 1, 1)
     };
 }
            private void CreateCohort()
            {
                Cohort = new CommitmentsV2.Models.Cohort {
                    EditStatus = EditStatus.ProviderOnly, ProviderId = 1
                };

                for (var i = 0; i < CohortSize; i++)
                {
                    var draftApprenticeship = new DraftApprenticeship
                    {
                        Id            = i + 1,
                        FirstName     = _autoFixture.Create <string>(),
                        LastName      = _autoFixture.Create <string>(),
                        ReservationId = Guid.NewGuid()
                    };

                    Cohort.Apprenticeships.Add(draftApprenticeship);
                }
            }
        public void UpdateDraftApprenticeship_WithInvalidInput_ShouldThrowException()
        {
            var fixtures = new CohortTestFixtures();

            // arrange
            var originalDraft        = fixtures.Create();
            var modifiedDraft        = fixtures.UpdatePropertiesWithNewValues(originalDraft);
            var modifiedDraftDetails = fixtures.ToApprenticeshipDetails(modifiedDraft, Party.Provider);

            modifiedDraftDetails.StartDate = modifiedDraftDetails.EndDate.Value.AddMonths(1);

            var c = new CommitmentsV2.Models.Cohort {
                WithParty = Party.Provider, ProviderId = 1
            };

            c.Apprenticeships.Add(originalDraft);

            // Act
            Assert.Throws <DomainException>(() => c.UpdateDraftApprenticeship(modifiedDraftDetails, Party.Provider, fixtures.UserInfo));
        }
        public void UpdateDraftApprenticeship_WithValidInput_ShouldUpdateExistingDraftApprenticeship()
        {
            var fixtures = new CohortTestFixtures();

            // arrange
            var originalDraft        = fixtures.Create();
            var modifiedDraft        = fixtures.UpdatePropertiesWithNewValues(originalDraft);
            var modifiedDraftDetails = fixtures.ToApprenticeshipDetails(modifiedDraft, Party.Provider);

            var c = new CommitmentsV2.Models.Cohort {
                WithParty = Party.Provider, ProviderId = 1
            };

            c.Apprenticeships.Add(originalDraft);

            // Act
            c.UpdateDraftApprenticeship(modifiedDraftDetails, Party.Provider, fixtures.UserInfo);

            // Assert
            var savedDraft = c.DraftApprenticeships.Single(a => a.Id == modifiedDraft.Id);

            fixtures.AssertSameProperties(modifiedDraft, savedDraft);
        }
        public void LastMessageIsNullWhenNoMessagesExist()
        {
            var cohort = new CommitmentsV2.Models.Cohort();

            Assert.AreEqual(null, cohort.LastMessage);
        }