public async Task EditGet_ReturnsNotFound_WhenEditRequestQueryReturnsNull() { var eventId = Guid.NewGuid(); EditRequestQuery eventSummaryQuery = null; // will be assigned from the Moq callback var mockMediator = new Mock <IMediator>(); mockMediator.Setup(x => x.SendAsync(It.IsAny <EditRequestQuery>())).ReturnsAsync(null).Callback <EditRequestQuery>(cmd => eventSummaryQuery = cmd).Verifiable(); var sut = new RequestController(mockMediator.Object); var result = await sut.Edit(eventId); var objResult = Assert.IsType <NotFoundResult>(result); objResult.StatusCode.ShouldBe(StatusCodes.Status404NotFound); }
public async Task EditGet_SendsEditRequestQueryQuery_WithCorrectArguments() { var eventId = Guid.NewGuid(); EditRequestQuery eventSummaryQuery = null; // will be assigned from the Moq callback var mockMediator = new Mock <IMediator>(); mockMediator.Setup(x => x.SendAsync(It.IsAny <EditRequestQuery>())).ReturnsAsync(null).Callback <EditRequestQuery>(cmd => eventSummaryQuery = cmd).Verifiable(); var sut = new RequestController(mockMediator.Object); await sut.Edit(eventId); mockMediator.Verify(x => x.SendAsync(It.IsAny <EditRequestQuery>()), Times.Once); eventSummaryQuery.Id.ShouldBe(eventId); }