public async Task Should_Return_204_When_Request_Entry_Is_Deleted() { var mediatorMock = new Mock <IMediator>(); mediatorMock .Setup(x => x.Send(It.IsAny <DeleteRequestEntryCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new DeleteRequestEntrySuccessResult()); var sut = new RequestEntryController(mediatorMock.Object); var actualResult = await sut.DeleteRequestEntryAsync(Guid.NewGuid().ToString()); actualResult.Should().BeOfType <NoContentResult>(); }
public async Task Should_Return_Single_Request_Entry() { var expectedRequestEntry = new RequestEntry("search-token", "imdbId", 100, DateTime.Now, "127.0.0.1") { Id = Guid.NewGuid().ToString() }; var mediatorMock = new Mock <IMediator>(); mediatorMock .Setup(x => x.Send(It.IsAny <GetSingleRequestEntryQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new GetSingleRequestEntrySuccessResult(expectedRequestEntry)); var sut = new RequestEntryController(mediatorMock.Object); var actualResult = await sut.GetSingleRequestEntryAsync(Guid.NewGuid().ToString()); actualResult.Should() .BeOfType <OkObjectResult>() .Which.Value.Should() .BeOfType <SingleRequestEntryResponse>(); }
public async Task Should_Return_200_With_Usage_Report() { var expectedUsageReports = new[] { new UsageReport("2021-02-21", 5), new UsageReport("2021-02-22", 10) }; var mediatorMock = new Mock <IMediator>(); mediatorMock .Setup(x => x.Send(It.IsAny <GetRequestEntriesUsageReportQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new GetRequestEntriesUsageReportSuccessResult(expectedUsageReports)); var sut = new RequestEntryController(mediatorMock.Object); var actualResult = await sut.GetRequestEntriesUsageReportAsync(new GetRequestEntriesUsageReportRequest { Timestamp = new DateTime(2021, 02, 21) }); actualResult.Should() .BeOfType <OkObjectResult>() .Which.Value.Should() .BeOfType <List <GetRequestEntriesUsageReportResponse> >(); }