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(); }
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(); }