Ejemplo n.º 1
0
        public async Task ThrowNotFoundException_WhenLectorSubjectIsNotExists()
        {
            var request = new DeleteLectorSubjectCommand
            {
                Id = 100
            };

            var handler = new DeleteLectorSubjectCommandHandler(Context);

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

            Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetNotFoundExceptionMessage(nameof(LectorSubject), request.Id));
        }
Ejemplo n.º 2
0
        public async Task ThrowDeleteFailureException_WhenLessonWithLectorSubjectExists()
        {
            var request = new DeleteLectorSubjectCommand
            {
                Id = 2
            };

            var handler = new DeleteLectorSubjectCommandHandler(Context);

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

            Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetDeleteFailureExceptionMessage(nameof(LectorSubject), request.Id, "This record is used in lesson(s)"));
        }
Ejemplo n.º 3
0
        public async Task DeleteLectorSubject()
        {
            var request = new DeleteLectorSubjectCommand
            {
                Id = 1
            };

            var handler = new DeleteLectorSubjectCommandHandler(Context);

            var result = await handler.Handle(request, CancellationToken.None);

            Assert.IsFalse(Context.LectorSubjects.Any(x => x.Id == request.Id));
        }