public async Task ReturnSubjectDto_WhenSubjectExists() { var handler = new GetSubjectQueryHandler(Context); var result = await handler.Handle(new GetSubjectQuery { Id = 1 }, CancellationToken.None); Assert.IsInstanceOf(typeof(SubjectDto), result); }
public async Task ThrowNotFoundException_WhenSubjectIsNotExists() { var notExistingSubjectId = 1000; var handler = new GetSubjectQueryHandler(Context); var exception = Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(new GetSubjectQuery { Id = notExistingSubjectId }, CancellationToken.None)); Assert.AreEqual(exception.Message, ExceptionMessagesBuilderHelper.GetNotFoundExceptionMessage(nameof(Subject), notExistingSubjectId)); }