public async Task ThrowDuplicateException_WhenLectorSubjectExists() { var request = new CreateLectorSubjectCommand { LectorId = 1, LessonTypeId = 1, SubjectId = 1 }; var handler = new CreateLectorSubjectCommandHandler(Context); var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(LectorSubject))); }
public async Task CreateLectorSubject() { var request = new CreateLectorSubjectCommand { LectorId = 1, LessonTypeId = 2, SubjectId = 2 }; var handler = new CreateLectorSubjectCommandHandler(Context); var result = await handler.Handle(request, CancellationToken.None); Assert.IsTrue(Context.LectorSubjects.Where(x => x.Id == result).Count() == 1); }