Beispiel #1
0
        public void Allocate_Should_Return_Null_When_SelectedCampaign_Is_Null()
        {
            var mockUserHasher = MockUserHasher.Get();
            VariationAllocator variationResolver = GetVariationResolver(mockUserHasher);
            var selectedVariation = variationResolver.Allocate(null, null, MockUserId);

            Assert.Null(selectedVariation);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #2
0
        public void Allocate_Should_Return_Null_When_InValid_CampaignKey_Is_Provided()
        {
            var            mockUserHasher   = MockUserHasher.Get();
            var            campaignResolver = GetCampaignResolver(mockUserHasher);
            UserStorageMap userStorageMap   = null;
            var            selectedCampaign = campaignResolver.Allocate(GetAccountSettings(status: "RUNNING"), userStorageMap, MockCampaignKey + MockCampaignKey, MockUserId);

            Assert.Null(selectedCampaign);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #3
0
        public void Allocate_Should_Return_Null_When_Valid_UserStorageMap_With_Valid_Campaign_Is_Given_And_Campaign_Is_Not_Running()
        {
            var            mockUserHasher   = MockUserHasher.Get();
            var            campaignResolver = GetCampaignResolver(mockUserHasher);
            UserStorageMap userStorageMap   = new UserStorageMap(MockUserId, MockCampaignKey, MockVariationName);
            var            selectedCampaign = campaignResolver.Allocate(GetAccountSettings(status: "NOT_RUNNING"), userStorageMap, MockCampaignKey, MockUserId);

            Assert.Null(selectedCampaign);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #4
0
        public void Allocate_Should_Return_Null_When_Valid_UserStorageMap_With_InValid_Variation_Is_Given()
        {
            var mockUserHasher = MockUserHasher.Get();
            VariationAllocator variationResolver = GetVariationResolver(mockUserHasher);
            UserStorageMap     userStorageMap    = new UserStorageMap(MockUserId, MockCampaignKey, MockVariationName + MockVariationName);
            var selectedVariation = variationResolver.Allocate(userStorageMap, GetCampaign(MockCampaignKey), MockUserId);

            Assert.Null(selectedVariation);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #5
0
        public void Allocate_Should_Return_Null_When_Valid_UserProfileMap_With_InValid_Campaign_Is_Given()
        {
            var            mockUserHasher    = MockUserHasher.Get();
            var            campaignAllocator = GetCampaignResolver(mockUserHasher);
            UserProfileMap userProfileMap    = new UserProfileMap(MockUserId, MockCampaignTestKey + MockCampaignTestKey, MockVariationName);
            var            selectedCampaign  = campaignAllocator.Allocate(GetAccountSettings(), userProfileMap, MockCampaignTestKey, MockUserId);

            Assert.Null(selectedCampaign);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #6
0
        public void Allocate_Should_Not_Compute_Hash_When_Valid_UserProfileMap_With_Valid_Variation_Is_Given()
        {
            var mockUserHasher = MockUserHasher.Get();
            VariationAllocator variationResolver = GetVariationResolver(mockUserHasher);
            UserProfileMap     userProfileMap    = new UserProfileMap(MockUserId, MockCampaignTestKey, MockVariationName);
            var selectedVariation = variationResolver.Allocate(userProfileMap, GetCampaign(MockCampaignTestKey), MockUserId);

            Assert.NotNull(selectedVariation);
            Assert.Equal(MockVariationName, selectedVariation.Name);

            mockUserHasher.Verify(mock => mock.ComputeBucketValue(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <double>()), Times.Never);
        }
Beispiel #7
0
 internal static Mock <IBucketService> GetUserHasher()
 {
     return(MockUserHasher.Get());
 }
Beispiel #8
0
 internal static void SetupComputeBucketValue(Mock <IBucketService> mockUserHasher, int returnVal, double outHashValue)
 {
     MockUserHasher.SetupComputeBucketValue(mockUserHasher, returnVal, outHashValue);
 }
Beispiel #9
0
 internal static void SetupCompute(Mock <IBucketService> mockUserHasher, int returnVal)
 {
     MockUserHasher.SetupCompute(mockUserHasher, returnVal);
 }
Beispiel #10
0
 private CampaignAllocator GetCampaignResolver(Mock <IBucketService> mockUserHasher = null)
 {
     mockUserHasher = mockUserHasher ?? MockUserHasher.Get();
     return(new CampaignAllocator(mockUserHasher.Object));
 }
Beispiel #11
0
 private VariationAllocator GetVariationResolver(Mock <IBucketService> mockUserHasher = null)
 {
     mockUserHasher = mockUserHasher ?? MockUserHasher.Get();
     return(new VariationAllocator(mockUserHasher.Object));
 }