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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }