public void GetAllAsync_Has_Route_Attribute() { // 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); // Act var attributes = sut.GetAttributesOn(x => x.GetAllDestinationsAsync( It.IsAny <PagingOptions>(), It.IsAny <SortOptions>(), It.IsAny <SearchOptions>(), It.IsAny <CancellationToken>())).OfType <RouteAttribute>().SingleOrDefault(); // Assert attributes.Should().NotBeNull(); attributes.Name.Should().Be("GetAllDestinationsAsync"); }
public void GetAllAsync_Has_ProducesResponse_Atttribute_With_Correct_Return_Type() { // 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 expectedTyped = typeof(IEnumerable <DestinationPreviewDto>); // Act var attributes = sut.GetAttributesOn(x => x.GetAllDestinationsAsync( It.IsAny <PagingOptions>(), It.IsAny <SortOptions>(), It.IsAny <SearchOptions>(), It.IsAny <CancellationToken>())).OfType <ProducesResponseTypeAttribute>(); // Assert attributes.Should().NotBeNull(); attributes.Count().Should().BeGreaterThan(0); attributes.Select(x => x.Type == expectedTyped).Should().NotBeNull(); }