Beispiel #1
0
        public async Task GetByIdAsync_GetDestinationPreviewQuery_Has_Correct_Data()
        {
            // Arrange
            var mockMediator        = new Mock <IMediator>();
            var mockMapper          = new Mock <IMapper>();
            var mockResponseFactory = new Mock <IResponseFactory>();
            var mockApiSettings     = new Mock <IOptionsSnapshot <ApiSettings> >();

            mockApiSettings.SetupGet(x => x.Value).Returns(ApiSettings);
            var sut           = new DestinationsController(mockMediator.Object, mockMapper.Object, mockResponseFactory.Object, mockApiSettings.Object);
            var destinationId = 1;

            // Act
            await sut.GetDestinationByIdAsync(destinationId, default(CancellationToken));

            // Assert
            mockMediator.Verify(x => x.Send(It.Is <GetDestinationPreviewQuery>(d => d.Id == destinationId), It.IsAny <CancellationToken>()));
        }
Beispiel #2
0
        public async Task GetByIdAsync_Returns_OK_200_Result()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.Send(It.IsAny <GetDestinationPreviewQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(Destination);
            var mockMapper          = new Mock <IMapper>();
            var mockResponseFactory = new Mock <IResponseFactory>();
            var mockApiSettings     = new Mock <IOptionsSnapshot <ApiSettings> >();

            mockApiSettings.SetupGet(x => x.Value).Returns(ApiSettings);
            var sut           = new DestinationsController(mockMediator.Object, mockMapper.Object, mockResponseFactory.Object, mockApiSettings.Object);
            var destinationId = 1;

            // Act
            var result = await sut.GetDestinationByIdAsync(destinationId, default(CancellationToken));

            // Assert
            var response = result.Should().BeOfType <OkObjectResult>().Subject;

            response.StatusCode.Should().Equals(200);
        }