public async Task ThrowDuplicateException_WhenSpecialityCodeExists() { var request = new CreateSpecialityCommand { Code = 101, Name = "Test Speciality 3" }; var handler = new CreateSpecialityCommandHandler(Context); var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(Speciality), "Code", request.Code)); }
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 ThrowDuplicateException_WhenGroupNameExists() { var request = new CreateGroupCommand { Name = "Group 1", SpecialityId = 1, StudentsCount = 10, EducationalDegreeId = 1, Year = 1 }; var handler = new CreateGroupCommandHandler(Context); var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(Group), "Name", request.Name)); }
public async Task ThrowsDuplicateException_WhenEmailExists() { var request = new UpdateLectorCommand { Id = 1, AcademicDegreeId = 1, AcademicRankId = 1, Email = "*****@*****.**", FirstName = "Name 1", LastName = "LastName 1", Patronymic = "Patronymic 1", PhoneNumber = "+0000000000" }; var handler = new UpdateLectorCommandHandler(Context); var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(Lector), "Email", request.Email)); }
public async Task ThrowDuplicateException_WhenEmailExists() { var passwordHasherMock = new Mock <IPasswordHasher>(); var passwordGeneratorMock = new Mock <IPasswordGenerator>(); var request = new CreateLectorCommand { Email = "*****@*****.**", AcademicDegreeId = 1, AcademicRankId = 1, FirstName = "Name 3", LastName = "LastName 3", Patronymic = "Patronymic 3", PhoneNumber = "+3333333333" }; var handler = new CreateLectorCommandHandler(Context, passwordHasherMock.Object, passwordGeneratorMock.Object); var exception = Assert.ThrowsAsync <DuplicateException>(async() => await handler.Handle(request, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDuplicateExceptionMessage(nameof(Lector), "Email", request.Email)); }