Example #1
0
        public void Instantiate_Should_Return_Null_For_InValid_Settings_File_And_Call_Settings_Processor_With_EventBatching()
        {
            var inValidSettings = new Settings(null, null, -2, -1);
            var mockValidator   = Mock.GetValidator();

            Mock.SetupSettingsFile(mockValidator, false);
            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);

            // BatchEventData batchData = VWOCore.Controllers.EventBatchDataProvider.BatchEventData();
            BatchEventData batchData = new BatchEventData();

            batchData.EventsPerRequest    = 4;
            batchData.RequestTimeInterval = 20;
            batchData.FlushCallback       = new FlushCallback(); //Callback
            var vwoClient = VWO.Launch(inValidSettings, true, null, batchData);

            Assert.Null(vwoClient);

            mockValidator.Verify(mock => mock.SettingsFile(It.IsAny <Settings>()), Times.Once);
            mockValidator.Verify(mock => mock.SettingsFile(It.Is <Settings>(val => ReferenceEquals(inValidSettings, val))), Times.Once);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Never);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, inValidSettings))), Times.Never);
        }
Example #2
0
        public void Instantiate_Should_Return_Null_When_Settings_Processor_Returns_Null_Account_Settings_With_EventBatching()
        {
            var inValidSettings = new Settings(null, null, -2, -1);
            var mockValidator   = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            //Mock.SetupProcessAndBucket(mockSettingProcessor, returnValue: null);
            VWO.Configure(mockSettingProcessor.Object);


            BatchEventData batchData = new BatchEventData();

            batchData.EventsPerRequest    = 4;
            batchData.RequestTimeInterval = 20;
            batchData.FlushCallback       = new FlushCallback(); //Callback

            var vwoClient = VWO.Launch(inValidSettings, true, null, batchData);

            //  var vwoClient = VWO.Launch(inValidSettings);
            Assert.Null(vwoClient);

            mockValidator.Verify(mock => mock.SettingsFile(It.IsAny <Settings>()), Times.Once);
            mockValidator.Verify(mock => mock.SettingsFile(It.Is <Settings>(val => ReferenceEquals(inValidSettings, val))), Times.Once);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Once);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, inValidSettings))), Times.Once);
        }
Example #3
0
 static HomeController()
 {
     VWO.Configure(LogLevel.DEBUG);
     VWO.Configure(new CustomLogger());
     SettingsFile = SettingsProvider.GetSettingsFile(VWOConfig.SDK.AccountId, VWOConfig.SDK.SdkKey);
     VWOClient    = VWO.Launch(SettingsFile, isDevelopmentMode: false, userStorageService: new UserStorageService());
 }
Example #4
0
 static HomeController()
 {
     VWO.Configure(LogLevel.DEBUG);
     VWO.Configure(new CustomLogger());
     SettingsFile = SettingsProvider.GetSettings(VWOConfig.AccountId, VWOConfig.SdkKey);
     VWOClient    = VWO.Instantiate(SettingsFile, isDevelopmentMode: true, userProfileService: new UserProfileService());
 }
        static HomeController()
        {
            VWO.Configure(LogLevel.DEBUG);
            VWO.Configure(new CustomLogger());
            CustomLogger logger = new CustomLogger();

            SettingsFile = SettingsProvider.GetSettingsFile(VWOConfig.SDK.AccountId, VWOConfig.SDK.SdkKey);
            BatchEventData _batchData = new BatchEventData();

            _batchData.EventsPerRequest    = Defaults.EventsPerRequest;
            _batchData.RequestTimeInterval = Defaults.RequestTimeInterval;
            _batchData.FlushCallback       = new FlushCallback();
            //logger.WriteLog(LogLevel.DEBUG, "BatchEventData : EventsPerRequest-" + Defaults.EventsPerRequest.ToString() +", RequestTimeInterval:" + Defaults.RequestTimeInterval);
            //VWOClient = VWO.Launch(SettingsFile, batchData: _batchData);

            //logger.WriteLog(LogLevel.DEBUG, "HookManager : IntegrationEventListener onEvent requested ");
            //VWOClient = VWO.Launch(SettingsFile, batchData: _batchData, integrations: new HookManager(){HookCallback = new HookCallback()});

            logger.WriteLog(LogLevel.DEBUG, "BatchEventData,userStorageService,isDevelopmentMode,integrations,shouldTrackReturningUser passed in SDK");
            VWOClient = VWO.Launch(SettingsFile, batchData: _batchData, userStorageService: new UserStorageService(),
                                   isDevelopmentMode: false, integrations: new HookManager()
            {
                HookCallback = new HookCallback()
            }, shouldTrackReturningUser: false);
        }
Example #6
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);
        }
Example #7
0
        public void Instantiate_Should_Return_VWOClient_For_Valid_Settings_File_And_Call_Settings_Processor()
        {
            var validSettings = new FileReaderApiCaller().Execute <Settings>(null);
            var mockValidator = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);

            var vwoClient = VWO.Launch(validSettings);

            Assert.NotNull(vwoClient);
            Assert.IsType <VWO>(vwoClient);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Once);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, validSettings))), Times.Once);
        }
Example #8
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);
        }
Example #9
0
        public void GetSettings_Should_Return_Null_When_Api_Caller_Returns_Null()
        {
            var mockApiCaller = Mock.GetApiCaller <Settings>();

            Mock.SetupExecute <Settings>(mockApiCaller, returnValue: null);
            AppContext.Configure(mockApiCaller.Object);
            var mockValidator = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);

            var result = VWO.GetSettings(MockAccountId, MockSdkKey);

            Assert.Null(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);
        }
Example #10
0
        public void Instantiate_Should_Return_Null_When_Settings_Processor_Returns_Null_Account_Settings()
        {
            var inValidSettings = new Settings(null, null, -2, -1);
            var mockValidator   = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            //Mock.SetupProcessAndBucket(mockSettingProcessor, returnValue: null);
            VWO.Configure(mockSettingProcessor.Object);

            var vwoClient = VWO.Launch(inValidSettings);

            Assert.Null(vwoClient);

            mockValidator.Verify(mock => mock.SettingsFile(It.IsAny <Settings>()), Times.Once);
            mockValidator.Verify(mock => mock.SettingsFile(It.Is <Settings>(val => ReferenceEquals(inValidSettings, val))), Times.Once);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Once);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, inValidSettings))), Times.Once);
        }
Example #11
0
        public void Instantiate_Should_Return_Null_For_InValid_Settings_File_And_Call_Settings_Processor()
        {
            var inValidSettings = new Settings(null, null, -2, -1);
            var mockValidator   = Mock.GetValidator();

            Mock.SetupSettingsFile(mockValidator, false);
            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);

            var vwoClient = VWO.Launch(inValidSettings);

            Assert.Null(vwoClient);

            mockValidator.Verify(mock => mock.SettingsFile(It.IsAny <Settings>()), Times.Once);
            mockValidator.Verify(mock => mock.SettingsFile(It.Is <Settings>(val => ReferenceEquals(inValidSettings, val))), Times.Once);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Never);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, inValidSettings))), Times.Never);
        }
Example #12
0
        public void Launch_EventBatching_Queue_Size_Tests()
        {
            var validSettings = new FileReaderApiCaller().Execute <Settings>(null);
            var mockValidator = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);
            BatchEventData batchData = new BatchEventData();

            batchData.EventsPerRequest    = 4;
            batchData.RequestTimeInterval = 20;
            batchData.FlushCallback       = new FlushCallback(); //Callback
            var vwoClient = VWO.Launch(validSettings, true, null, batchData);

            Assert.NotNull(vwoClient);
            Assert.Equal(0, vwoClient.getBatchEventQueue().BatchQueueCount());


            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Once);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, validSettings))), Times.Once);
        }
Example #13
0
        public void Instantiate_Should_Return_VWOClient_For_Valid_Settings_File_And_Call_Settings_Processor_With_EventBatching()
        {
            var validSettings = new FileReaderApiCaller().Execute <Settings>(null);
            var mockValidator = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);


            BatchEventData batchData = new BatchEventData();

            batchData.EventsPerRequest    = 4;
            batchData.RequestTimeInterval = 20;
            batchData.FlushCallback       = new FlushCallback(); //Callback
            var vwoClient = VWO.Launch(validSettings, true, null, batchData);

            Assert.NotNull(vwoClient);
            Assert.IsType <VWO>(vwoClient);

            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Once);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, validSettings))), Times.Once);
        }
Example #14
0
 static CampaignAllocatorTests()
 {
     VWO.Configure(LogLevel.DEBUG);
 }
Example #15
0
 static VWOTests()
 {
     VWO.Configure(new DefaultLogWriter());
     AppContext.Configure(new FileReaderApiCaller());
 }
Example #16
0
 public FunctionalVWOTests()
 {
     VWO.Configure(LogLevel.DEBUG);
     VWO.Configure(logger: null);
     AppContext.Configure(new ApiCaller());
 }
Example #17
0
        public void Launch_EventBatching_Validation()
        {
            // "Event Batching Queue should be undefined if batchEventsData is not passed"
            var validSettings = new FileReaderApiCaller().Execute <Settings>(null);
            var mockValidator = Mock.GetValidator();

            VWO.Configure(mockValidator.Object);
            var mockSettingProcessor = Mock.GetSettingsProcessor();

            VWO.Configure(mockSettingProcessor.Object);


            var vwoClient = VWO.Launch(validSettings, true);

            Assert.NotNull(vwoClient);
            Assert.Null(vwoClient.getBatchEventQueue());
            Assert.IsType <VWO>(vwoClient);

            //"Event batching Queue should be defined if batchEventsData is passed"
            BatchEventData batchData = new BatchEventData();

            batchData.EventsPerRequest    = 4;
            batchData.RequestTimeInterval = 20;
            batchData.FlushCallback       = new FlushCallback();

            var vwoClientBatch = VWO.Launch(validSettings, true, null, batchData);

            Assert.NotNull(vwoClientBatch);

            Assert.Equal(0, vwoClientBatch.getBatchEventQueue().BatchQueueCount());
            Assert.Equal(4, vwoClientBatch.getBatchEventQueue().eventsPerRequest);
            Assert.Equal(20, vwoClientBatch.getBatchEventQueue().requestTimeInterval);

            Assert.IsType <VWO>(vwoClientBatch);

            //"Event batching Queue should be defined if batchEventsData is passed even wrong format"

            BatchEventData batchDataWrongFormat = new BatchEventData();


            var vwoClientBatchDefault = VWO.Launch(validSettings, true, null, batchDataWrongFormat);

            Assert.NotNull(vwoClientBatchDefault);
            Assert.Equal(0, vwoClientBatchDefault.getBatchEventQueue().BatchQueueCount());
            Assert.Equal(100, vwoClientBatchDefault.getBatchEventQueue().eventsPerRequest);
            Assert.Equal(600, vwoClientBatchDefault.getBatchEventQueue().requestTimeInterval);
            Assert.IsType <VWO>(vwoClientBatchDefault);

            //"Event batching Queue should be defined if batchEventsData is passed null value"
            BatchEventData batchDataNullValue = new BatchEventData();

            batchDataNullValue.EventsPerRequest    = null;
            batchDataNullValue.RequestTimeInterval = null;
            batchDataNullValue.FlushCallback       = null;

            var vwoClientBatchNull = VWO.Launch(validSettings, true, null, batchDataNullValue);

            Assert.NotNull(vwoClientBatchNull);
            Assert.Equal(0, vwoClientBatchNull.getBatchEventQueue().BatchQueueCount());
            Assert.Equal(100, vwoClientBatchNull.getBatchEventQueue().eventsPerRequest);
            Assert.Equal(600, vwoClientBatchNull.getBatchEventQueue().requestTimeInterval);
            Assert.IsType <VWO>(vwoClientBatchNull);
            //"Event batching Queue should be defined if batchEventsData cross the limits"
            BatchEventData batchDataLimitCheck = new BatchEventData();

            batchDataLimitCheck.EventsPerRequest    = 6000;
            batchDataLimitCheck.RequestTimeInterval = 0;
            batchDataLimitCheck.FlushCallback       = null;

            var vwoClientBatchLimit = VWO.Launch(validSettings, true, null, batchDataLimitCheck);

            Assert.NotNull(vwoClientBatchLimit);
            Assert.Equal(0, vwoClientBatchLimit.getBatchEventQueue().BatchQueueCount());
            Assert.Equal(100, vwoClientBatchLimit.getBatchEventQueue().eventsPerRequest);
            Assert.Equal(600, vwoClientBatchLimit.getBatchEventQueue().requestTimeInterval);
            Assert.IsType <VWO>(vwoClientBatchLimit);
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.IsAny <Settings>()), Times.Exactly(5));
            mockSettingProcessor.Verify(mock => mock.ProcessAndBucket(It.Is <Settings>(val => ReferenceEquals(val, validSettings))), Times.Exactly(5));
        }