public static Settings GetSettings(long accountId, string sdkKey) { if (accountId == DemoApp.Defaults.AccountId) { return(GetSettingsFile("DemoSettingsFile")); } return(VWO.GetSettings(accountId, sdkKey)); }
public void GetSettings_Should_Return_Settings_When_Validation_Is_Success() { var mockApiCaller = Mock.GetApiCaller <Settings>(); AppContext.Configure(mockApiCaller.Object); var mockValidator = Mock.GetValidator(); VWO.Configure(mockValidator.Object); var result = VWO.GetSettings(MockAccountId, MockSdkKey); Assert.NotNull(result); mockValidator.Verify(mock => mock.GetSettings(It.IsAny <long>(), It.IsAny <string>()), Times.Once); mockValidator.Verify(mock => mock.GetSettings(It.Is <long>(val => MockAccountId == val), It.Is <string>(val => MockSdkKey.Equals(val))), Times.Once); mockApiCaller.Verify(mock => mock.ExecuteAsync(It.IsAny <ApiRequest>()), Times.Never); }
public void GetVariation_Should_Return_Desired_Output(string campaignTestKey, string userId, bool expectedPartOfCampaign, string expectedVariationName) { AppContext.Configure(new FileReaderApiCaller("Campaign50percVariation50-50")); VWO.Configure(new Validator()); var settings = VWO.GetSettings(123456, "sampleSdkKey"); Assert.NotNull(settings); Assert.Equal(123456, settings.AccountId); Assert.Equal("sampleSdkKey", settings.SdkKey); var vwoClient = VWO.Instantiate(settings, isDevelopmentMode: true); var getVariationResponse = vwoClient.GetVariation(campaignTestKey, userId); if (expectedPartOfCampaign) { Assert.NotNull(getVariationResponse); Assert.NotEmpty(getVariationResponse); Assert.Equal(expectedVariationName, getVariationResponse); } else { Assert.Null(expectedVariationName); Assert.Null(getVariationResponse); } var activateResponse = vwoClient.Activate(campaignTestKey, userId); if (expectedPartOfCampaign) { Assert.NotNull(activateResponse); Assert.NotEmpty(activateResponse); Assert.Equal(expectedVariationName, activateResponse); } else { Assert.Null(expectedVariationName); Assert.Null(activateResponse); } var trackResponse = vwoClient.Track(campaignTestKey, userId, "CUSTOM"); Assert.Equal(expectedPartOfCampaign, trackResponse); }