public async Task Then_the_learner_is_added_to_the_data_store()
        {
            // Arrange
            var submissionData = _fixture.Create <SubmissionData>();

            submissionData.SetSubmissionDate(_fixture.Create <DateTime>());
            submissionData.SetLearningData(new LearningData(true));
            submissionData.LearningData.SetHasDataLock(true);
            submissionData.SetRawJson(_fixture.Create <string>());
            submissionData.LearningData.SetStartDate(_fixture.Create <DateTime>());
            submissionData.LearningData.SetIsInLearning(true);
            submissionData.LearningData.SetIsStopped(new LearningStoppedStatus(true, _fixture.Create <DateTime>()));

            var testLearner =
                _fixture.Build <LearnerModel>()
                .With(l => l.SubmissionData, submissionData)
                .Create();

            // Act
            await _sut.Add(testLearner);

            await _dbContext.SaveChangesAsync();

            // Assert
            _dbContext.Learners.Count().Should().Be(1);

            var storedLearner = _dbContext.Learners.Single();

            storedLearner.Id.Should().Be(testLearner.Id);
            storedLearner.ApprenticeshipIncentiveId.Should().Be(testLearner.ApprenticeshipIncentiveId);
            storedLearner.ApprenticeshipId.Should().Be(testLearner.ApprenticeshipId);
            storedLearner.Ukprn.Should().Be(testLearner.Ukprn);
            storedLearner.ULN.Should().Be(testLearner.UniqueLearnerNumber);
            storedLearner.SubmissionFound.Should().BeTrue();
            storedLearner.SubmissionDate.Should().Be(testLearner.SubmissionData.SubmissionDate);
            storedLearner.LearningFound.Should().Be(testLearner.SubmissionData.LearningData.LearningFound);
            storedLearner.HasDataLock.Should().BeTrue();
            storedLearner.StartDate.Should().Be(testLearner.SubmissionData.LearningData.StartDate);
            storedLearner.InLearning.Should().BeTrue();
            storedLearner.RawJSON.Should().Be(testLearner.SubmissionData.RawJson);
            storedLearner.LearningStoppedDate.Should().Be(testLearner.SubmissionData.LearningData.StoppedStatus.DateStopped);
            storedLearner.LearningResumedDate.Should().BeNull();
        }
Esempio n. 2
0
        public async Task Then_the_learner_is_returned_if_exists()
        {
            var submissionData = _fixture.Create <SubmissionData>();

            submissionData.SetSubmissionDate(_fixture.Create <DateTime>());
            submissionData.SetLearningData(new LearningData(true));
            submissionData.LearningData.SetHasDataLock(true);
            submissionData.SetRawJson(_fixture.Create <string>());

            var testLearner =
                _fixture.Build <LearnerModel>()
                .With(l => l.SubmissionData, submissionData)
                .Create();

            // Act
            await _sut.Add(testLearner);

            await _dbContext.SaveChangesAsync();

            // Act
            var result = await _sut.Get(testLearner.Id);

            // Assert
            result.Id.Should().Be(testLearner.Id);
            result.ApprenticeshipIncentiveId.Should().Be(testLearner.ApprenticeshipIncentiveId);
            result.ApprenticeshipId.Should().Be(testLearner.ApprenticeshipId);
            result.Ukprn.Should().Be(testLearner.Ukprn);
            result.UniqueLearnerNumber.Should().Be(testLearner.UniqueLearnerNumber);
            result.SubmissionData.Should().NotBeNull();
            result.SubmissionData.SubmissionDate.Should().Be(testLearner.SubmissionData.SubmissionDate);
            result.SubmissionData.LearningData.LearningFound.Should().Be(testLearner.SubmissionData.LearningData.LearningFound);
            result.SubmissionData.LearningData.HasDataLock.Should().BeTrue();
            result.SubmissionData.LearningData.StartDate.Should().BeNull();
            result.SubmissionData.LearningData.IsInlearning.Should().BeNull();
            result.SubmissionData.LearningData.StoppedStatus.LearningStopped.Should().BeFalse();
            result.SubmissionData.RawJson.Should().Be(testLearner.SubmissionData.RawJson);
        }