public void IsSubscribed_ShouldReturnFalse_WhenUserDoesNotHavePermissionOnTheSubscription() { // Arrange var subscription = new SubscriptionBuilder() .Build(); var subscriptionCollection = new[] { subscription }; mockDataService.Setup(ds => ds.IsSubscribed( subscription.PortalId, subscription.UserId, subscription.SubscriptionTypeId, subscription.ObjectKey, It.IsAny <int>(), It.IsAny <int>())).Returns(SubscriptionDataReaderMockHelper.CreateSubscriptionReader(subscriptionCollection)); subscriptionSecurityController .Setup(ssc => ssc.HasPermission(It.IsAny <Subscription>())).Returns(false); //Act var isSubscribed = subscriptionController.IsSubscribed(subscription); // Assert Assert.AreEqual(false, isSubscribed); }
public void DeleteSubscriptionType_ShouldCallDeleteSubscriptionDataService_WhenSubscriptionExists() { // Arrange var subscription = new SubscriptionBuilder() .Build(); mockDataService.Setup(ds => ds.IsSubscribed( subscription.PortalId, subscription.UserId, subscription.SubscriptionTypeId, subscription.ObjectKey, It.IsAny <int>(), It.IsAny <int>())).Returns(SubscriptionDataReaderMockHelper.CreateSubscriptionReader(new [] { subscription })); mockDataService.Setup(ds => ds.DeleteSubscription(It.IsAny <int>())).Verifiable(); //Act subscriptionController.DeleteSubscription(subscription); //Assert mockDataService.Verify(ds => ds.DeleteSubscription(It.IsAny <int>()), Times.Once); }