예제 #1
0
        public async Task EditActivityAsync_CorrectUpdateOnContext(
            string teacher, string room, string subject, string classGroup)
        {
            using var context = PrepareData.GetDbContext(); var activity = context.Activities.Include(a => a.Slot).FirstOrDefault();
            int id          = activity.Id;
            int slot        = activity.Slot.Index;
            var activityDTO = new ActivityEditDTO()
            {
                Id         = id,
                ClassGroup = classGroup,
                Room       = room,
                Slot       = slot,
                Subject    = subject,
                Teacher    = teacher
            };
            var service = new ActivitiesService(context);
            var value   = await service.EditActivityAsync(activity.Id, activityDTO);

            var activityToCheck = GetActivities(context).FirstOrDefault(
                a =>
                a.Id == id &&
                a.Teacher.Name == teacher &&
                a.Room.Name == room &&
                a.Subject.Name == subject &&
                a.ClassGroup.Name == classGroup
                );

            Assert.True(value.IsRight);
            Assert.NotNull(activityToCheck);
        }
예제 #2
0
        public async Task EditActivityAsync_WhenActivityDTOIsNull_CheckErrorOccured()
        {
            using var context = PrepareData.GetDbContext(); var service = new ActivitiesService(context);
            var value = await service.EditActivityAsync(1, null);

            Assert.True(value.IsLeft);
        }
예제 #3
0
        public async Task EditActivityAsync_WhenOneOfValuesIsOccupied_CheckErrorOccured(
            string teacher, string room, string subject, string classGroup)
        {
            using var context = PrepareData.GetDbContext(); var activityDTO = GetDTOToEdit(teacher, room, subject, classGroup, context);
            var service = new ActivitiesService(context);
            var value   = await service.EditActivityAsync(activityDTO.Id, activityDTO);

            Assert.True(value.IsLeft);
        }