Ejemplo n.º 1
0
            public void CreateBusinessChannelOverrideWithCorrectClaimsCallsCorrectMethods()
            {

                //Arrange
                var businessChannelOverrideId = 0;
                var distributorCommission = 10;
                var eviivoCommission = 10;
                var isVisible = false;
                var businessId = 1;
                var channelId = 1;
                var commissionDisplay = "test commission display";

                var businessChannelOverrideDto = new BusinessChannelOverrideDto()
                {
                    Id = businessChannelOverrideId,
                    BusinessId = businessId,
                    ChannelId = channelId,
                    Commission = distributorCommission + eviivoCommission,
                    RevenueShare = eviivoCommission,
                    DisplayCommission = commissionDisplay,
                    IsVisible = isVisible
                };

                var claimManager = MockRepository.GenerateMock<IClaimManager>();
                var distributionManager = MockRepository.GenerateMock<IDistributionManager>();

                claimManager.Stub(cm => claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType.VISIBLE_BUSINESS_CHANNEL_OVERRIDE)).Return(true);
                claimManager.Stub(cm => claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType.EDIT_BUSINESS_CHANNEL_OVERRIDE)).Return(true);
                distributionManager.Stub(dm => dm.CreateBusinessChannelOverride(Arg<BusinessChannelOverride>.Is.Anything, Arg<bool>.Is.Equal(true), Arg<bool>.Is.Equal(true)));

                adminService.ClaimManager = claimManager;
                adminService.DistributionManager = distributionManager;

                //Act
                adminService.ModifyBusinessChannelOverride(businessChannelOverrideDto);

                //Assert
                claimManager.AssertWasCalled(cm => cm.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType.VISIBLE_BUSINESS_CHANNEL_OVERRIDE));
                claimManager.AssertWasCalled(cm => cm.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType
                                                                               .EDIT_BUSINESS_CHANNEL_OVERRIDE));
                distributionManager.AssertWasCalled(dm => dm.CreateBusinessChannelOverride(Arg<BusinessChannelOverride>.Is.Anything, Arg<bool>.Is.Equal(true), Arg<bool>.Is.Equal(true)));

            }
Ejemplo n.º 2
0
            public void CreateBusinessChannelOverrideWithNoClainsRaiseException()
            {

                //Arrange
                var businessChannelOverrideId = 0;
                var distributorCommission = 10;
                var eviivoCommission = 10;
                var isVisible = false;
                var businessId = 1;
                var channelId = 1;
                var commissionDisplay = "test commission display";

                var businessChannelOverrideDto = new BusinessChannelOverrideDto()
                {
                    Id = businessChannelOverrideId,
                    BusinessId = businessId,
                    ChannelId = channelId,
                    Commission = distributorCommission + eviivoCommission,
                    RevenueShare = eviivoCommission,
                    DisplayCommission = commissionDisplay,
                    IsVisible = isVisible
                };

                var claimManager = MockRepository.GenerateMock<IClaimManager>();
                var distributionManager = MockRepository.GenerateMock<IDistributionManager>();

                claimManager.Stub(cm => claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType.VISIBLE_BUSINESS_CHANNEL_OVERRIDE)).Return(false);
                claimManager.Stub(cm => claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                           ClaimType.EDIT_BUSINESS_CHANNEL_OVERRIDE)).Return(false);

                adminService.ClaimManager = claimManager;
                adminService.DistributionManager = distributionManager;

                //Act
                adminService.ModifyBusinessChannelOverride(businessChannelOverrideDto);

                //Assert in ExpectedException
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Create, Modify or delete a business channel override
        /// </summary>
        /// <param name="businessChannelOverrideDto">Business channel override to create/modify/delete</param>
        public void ModifyBusinessChannelOverride(BusinessChannelOverrideDto businessChannelOverrideDto)
        {
            BusinessChannelOverride businessChannelOverride = Mapper.Map<BusinessChannelOverride>(businessChannelOverrideDto);
            
            var modifyVisible =
                claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                    ClaimType.VISIBLE_BUSINESS_CHANNEL_OVERRIDE);
            var modifyCommissions =
                claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                    ClaimType.EDIT_BUSINESS_CHANNEL_OVERRIDE);

            var modifyCancellations = claimManager.DoesClaimExistForUser(ClaimsPrincipal.Current.Identity.Name,
                                                                         ClaimType.MODIFY_OPTIN_CHANNEL_CANCEL_POLICY);
            
            //if there's no permission we reject the call
            if (!modifyVisible && !modifyCommissions && !modifyCancellations)
            {
                throw new AccessDeniedException(ErrorFactory.CreateAndLogError(Errors.SRVEX20001, "AdminService.ModifyBusinessChannelOverride", "User should have the proper claims to modify the channel override data."));
            }

            if (businessChannelOverride.Id > 0)
            {
                distributionManager.ModifyBusinessChannelOverride(businessChannelOverride, modifyVisible, modifyCommissions);
            }
            else
            {
                distributionManager.CreateBusinessChannelOverride(businessChannelOverride, modifyVisible, modifyCommissions);
            }
        }