示例#1
0
        public async Task PromotionsSearch_AuthorizationSuccess_ReturnPromotionSearchResult()
        {
            //Arrange
            var promotionSearchResult = new PromotionSearchResult
            {
                Results = TestPromotions.ToList()
            };

            _mockAuthorization.Setup(x => x.AuthorizeAsync(It.IsAny <ClaimsPrincipal>(), It.IsAny <object>(), It.IsAny <IEnumerable <IAuthorizationRequirement> >())).ReturnsAsync(AuthorizationResult.Success());
            _mockPromotionSearch.Setup(x => x.SearchPromotionsAsync(It.IsAny <PromotionSearchCriteria>())).ReturnsAsync(promotionSearchResult);

            //Act
            var actual = await _controller.PromotionsSearch(new PromotionSearchCriteria());

            var result = actual.ExtractFromOkResult();

            //Assert
            result.Should().NotBeNull();
        }
示例#2
0
        public async Task GetPromotionById_AuthorizationFailed_ReturnUnauthorized()
        {
            //Arrange
            _mockAuthorization.Setup(x => x.AuthorizeAsync(It.IsAny <ClaimsPrincipal>(), It.IsAny <object>(), It.IsAny <IEnumerable <IAuthorizationRequirement> >())).ReturnsAsync(AuthorizationResult.Failed());
            _mockPromotion.Setup(x => x.GetPromotionsByIdsAsync(It.IsAny <string[]>())).ReturnsAsync(TestPromotions.ToArray());

            //Act
            var actual = await _controller.GetPromotionById("");

            //Assert
            actual.Value.Should().BeNull();
        }
示例#3
0
        public async Task GetPromotionById_AuthorizationSuccess_ReturnPromotion()
        {
            //Arrange
            _mockAuthorization.Setup(x => x.AuthorizeAsync(It.IsAny <ClaimsPrincipal>(), It.IsAny <object>(), It.IsAny <IEnumerable <IAuthorizationRequirement> >())).ReturnsAsync(AuthorizationResult.Success());
            _mockPromotion.Setup(x => x.GetPromotionsByIdsAsync(It.IsAny <string[]>())).ReturnsAsync(TestPromotions.ToArray());

            //Act
            var actual = await _controller.GetPromotionById("");

            var result = actual.ExtractFromOkResult();

            //Assert
            result.Should().NotBeNull();
        }