public void SaveUserMap_Should_Call_Save_With_Provided_Map()
        {
            var mockUserProfileService = Mock.GetUserProfileService();
            UserProfileAdapter userProfileServiceAdapter = new UserProfileAdapter(mockUserProfileService.Object);

            userProfileServiceAdapter.SaveUserMap(MockUserId, MockCampaignTestKey, MockVariationName);
            mockUserProfileService.Verify(mock => mock.Save(It.IsAny <UserProfileMap>()), Times.Once);
            mockUserProfileService.Verify(mock => mock.Save(It.Is <UserProfileMap>(val => Verify(val))), Times.Once);
        }
예제 #2
0
 internal VWO(AccountSettings settings, IValidator validator, IUserProfileService userProfileService, ICampaignAllocator campaignAllocator, IVariationAllocator variationAllocator, bool isDevelopmentMode)
 {
     this._settings           = settings;
     this._validator          = validator;
     this._userProfileService = new UserProfileAdapter(userProfileService);
     this._campaignAllocator  = campaignAllocator;
     this._variationAllocator = variationAllocator;
     this._isDevelopmentMode  = isDevelopmentMode;
 }
        public void GetUserMap_Should_Return_Null_When_LookUp_Returns_InValid_Map()
        {
            var mockUserProfileService = Mock.GetUserProfileService();

            Mock.SetupLookup(mockUserProfileService, returnValue: null);
            UserProfileAdapter userProfileServiceAdapter = new UserProfileAdapter(mockUserProfileService.Object);
            var result = userProfileServiceAdapter.GetUserMap(MockCampaignTestKey, MockUserId);

            Assert.Null(result);
        }
        public void SaveUserMap_Should_Call_Save_With_Provided_Map_And_Should_Not_Throw_Exception_When_Service_Throws_Exception()
        {
            var mockUserProfileService = Mock.GetUserProfileService();

            Mock.SetupSave(mockUserProfileService, new Exception("Test Method Exception."));
            UserProfileAdapter userProfileServiceAdapter = new UserProfileAdapter(mockUserProfileService.Object);

            userProfileServiceAdapter.SaveUserMap(MockUserId, MockCampaignTestKey, MockVariationName);
            mockUserProfileService.Verify(mock => mock.Save(It.IsAny <UserProfileMap>()), Times.Once);
            mockUserProfileService.Verify(mock => mock.Save(It.Is <UserProfileMap>(val => Verify(val))), Times.Once);
        }
        public void GetUserMap_Should_Return_Null_When_LookUp_Throws_Execption()
        {
            var mockUserProfileService = Mock.GetUserProfileService();

            Mock.SetupLookup(mockUserProfileService, new Exception("Test Method Exception"));
            UserProfileAdapter userProfileServiceAdapter = new UserProfileAdapter(mockUserProfileService.Object);
            var result = userProfileServiceAdapter.GetUserMap(MockCampaignTestKey, MockUserId);

            Assert.Null(result);

            mockUserProfileService.Verify(mock => mock.Lookup(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            mockUserProfileService.Verify(mock => mock.Lookup(It.Is <string>(val => MockUserId.Equals(val)), It.Is <string>(val => MockCampaignTestKey.Equals(val))), Times.Once);
        }
        public void GetUserMap_Should_Match_And_Return_Profile_Data_When_LookUp_Returns_Valid_Map()
        {
            var mockUserProfileService = Mock.GetUserProfileService();

            Mock.SetupLookup(mockUserProfileService, GetUserProfileMap());
            UserProfileAdapter userProfileServiceAdapter = new UserProfileAdapter(mockUserProfileService.Object);
            var result = userProfileServiceAdapter.GetUserMap(MockCampaignTestKey, MockUserId);

            Assert.NotNull(result);
            Assert.Equal(MockUserId, result.UserId);
            Assert.Equal(MockCampaignTestKey, result.CampaignTestKey);
            Assert.Equal(MockVariationName, result.VariationName);
        }