コード例 #1
0
        public async Task ThrowDuplicateException_WhenLectorSubjectNameExists()
        {
            var request = new UpdateLectorSubjectCommand
            {
                Id           = 1,
                LectorId     = 1,
                SubjectId    = 2,
                LessonTypeId = 1
            };

            var handler = new UpdateLectorSubjectCommandHandler(Context);

            var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None));

            Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(LectorSubject)));
        }
コード例 #2
0
        public async Task UpdateLectorSubject()
        {
            var request = new UpdateLectorSubjectCommand
            {
                Id           = 1,
                LectorId     = 1,
                LessonTypeId = 2,
                SubjectId    = 1
            };

            var handler = new UpdateLectorSubjectCommandHandler(Context);

            await handler.Handle(request, CancellationToken.None);

            Assert.IsTrue(Context.LectorSubjects.Where(x => x.Id == request.Id &&
                                                       x.LectorId == request.LectorId &&
                                                       x.LessonTypeId == request.LessonTypeId &&
                                                       x.SubjectId == request.SubjectId).Count() == 1);
        }