Exemplo n.º 1
0
 public static Settings GetSettingsFile(long accountId, string sdkKey)
 {
     if (accountId == 123456)
     {
         return(GetSettingsFile("DemoSettingsFile"));
     }
     return(VWO.GetSettingsFile(accountId, sdkKey));
 }
        public static Settings GetSettingsFile(long accountId, string sdkKey)
        {
            if (File.Exists(_SettingsFilePath) == false)
            {
                File.Create(_SettingsFilePath).Close();
            }
            Settings SettingsFile = VWO.GetSettingsFile(accountId, sdkKey);

            _ = SaveAsync(SettingsFile);
            return(SettingsFile);
        }
Exemplo n.º 3
0
        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.GetSettingsFile(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);
        }
Exemplo n.º 4
0
        public void GetVariation_Should_Return_Desired_Output(string campaignKey, string userId, bool expectedPartOfCampaign, string expectedVariationName)
        {
            AppContext.Configure(new FileReaderApiCaller("Campaign50percVariation50-50"));
            VWO.Configure(new Validator());
            var settings = VWO.GetSettingsFile(123456, "sampleSdkKey");

            Assert.NotNull(settings);
            Assert.Equal(123456, settings.AccountId);
            Assert.Equal("sampleSdkKey", settings.SdkKey);

            var vwoClient            = VWO.Launch(settings, isDevelopmentMode: true);
            var getVariationResponse = vwoClient.GetVariation(campaignKey, userId);

            if (expectedPartOfCampaign)
            {
                Assert.NotNull(getVariationResponse);
                Assert.NotEmpty(getVariationResponse);
                Assert.Equal(expectedVariationName, getVariationResponse);
            }
            else
            {
                Assert.Null(expectedVariationName);
                Assert.Null(getVariationResponse);
            }

            var activateResponse = vwoClient.Activate(campaignKey, userId);

            if (expectedPartOfCampaign)
            {
                Assert.NotNull(activateResponse);
                Assert.NotEmpty(activateResponse);
                Assert.Equal(expectedVariationName, activateResponse);
            }
            else
            {
                Assert.Null(expectedVariationName);
                Assert.Null(activateResponse);
            }

            var trackResponse = vwoClient.Track(campaignKey, userId, "CUSTOM");

            Assert.Equal(expectedPartOfCampaign, trackResponse);
        }