コード例 #1
0
        public async Task Update_Progression(User user, Subject subject, Concept concept, Concept newConcept)
        {
            var context = TestSetup.SetupContext();

            var progression = new Progression
            {
                UserId    = user.Id,
                User      = user,
                SubjectId = subject.Id,
                Subject   = subject,
                ConceptId = concept.Id,
                Concept   = concept
            };

            var expected = new Progression
            {
                UserId    = user.Id,
                User      = user,
                SubjectId = subject.Id,
                Subject   = subject,
                ConceptId = newConcept.Id,
                Concept   = newConcept
            };

            await context.Users.AddAsync(user);

            await context.Subjects.AddAsync(subject);

            await context.Concepts.AddRangeAsync(concept, newConcept);

            await context.Progressions.AddAsync(progression);

            await context.SaveChangesAsync();

            var service = new ProgressionService(context);
            var result  = await service.Update(user, subject, newConcept);

            var storedResult = context.Progressions.FirstOrDefault();

            result.Should().BeTrue();
            storedResult.Should().NotBeNull().And.BeEquivalentTo(expected, TestSetup.IgnoreTimestamps <Progression>());
        }