示例#1
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();
        }
示例#2
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();
        }