public IWebDriver GetTestBrowser() { RunEnv env = EnumHelper.GetRunEnv(TestConfigurationManager.GetInstance().GetRunOn()); ITestBrowserFactory browserFactory; switch (env) { case RunEnv.LOCAL: browserFactory = new LocalTestBrowser(); break; case RunEnv.BUILDSERVER: browserFactory = new BuildServerTestBrowser(); break; case RunEnv.CLOUD: browserFactory = new CloudTestBrowser(); break; default: return(null); } return(browserFactory.Create()); }
public IWebDriver Create() { //BrowserType type = BrowserType.GetBrowserType(TestConfigurationManager.GetInstance().GetTestBrowser()); string type = TestConfigurationManager.GetInstance().GetTestBrowser(); if (type == "chrome") { return(new ChromeDriver()); } return(null); //switch (type) //{ // case CHROME: // return new ChromeDriver(); // case FIREFOX: // return new FirefoxDriver(); // case IEXPLORER: // return new InternetExplorerDriver(); // case SAFARI: // return new SafariDriver(); // default: // return null; //} }
public TestBase() { Token = TestConfigurationManager.GetToken(); RestConfiguration = new RestConfiguration { AccessToken = Token }; }
public IWebDriver Create() { string type = TestConfigurationManager.GetInstance().GetTestBrowser(); if (type == "chrome") { return(new ChromeDriver()); } return(null); }
public void TestSaveLoad() { const int change = 727; using (var storage = new TemporaryNativeStorage(Guid.NewGuid().ToString())) { using (var manager = new TestConfigurationManager(storage)) { Assert.AreEqual(manager.TestNumber, default(int)); manager.TestNumber = change; Assert.AreEqual(manager.TestNumber, change); } using (var manager = new TestConfigurationManager(storage)) Assert.AreEqual(manager.TestNumber, change); } }
public void AppleNotificationsTest() { var payLoad = new AppleApiNotificationPayLoad("token", "hello World", 0, "default", "wrong key", "deviceUuid"); var testConfigurationManager = new TestConfigurationManager(); var securityService = new SecurityService(testConfigurationManager); var settings = new AppleServiceSettings(testConfigurationManager); var broker = new Mock<IPushBroker>(); broker.Setup(b => b.Dispose()).Verifiable(); broker.Setup(b => b.RegisterService<AppleNotification>(It.IsAny<ApplePushService>(), It.IsAny<bool>())); broker.Setup(b => b.QueueNotification(It.IsAny<AppleNotification>())); var appleService = new AppleNotificationService(broker.Object, new ApiLogger(), settings); var controller = new NotificationsController(appleService, securityService); var exception = new Exception("Test Exception"); // senario 1: invalid Key var result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful, "Should fail, wrong api key"); Assert.AreEqual("Invalid Authentication Key", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 2: send successful payLoad.AuthenticationKey = "LeopardValidApiKey"; broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnNotificationSent += null, this, null); result = controller.Apple(payLoad); Assert.IsTrue(result.IsSuccessful); Assert.AreEqual("Notification Sent", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 3: send failed broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnNotificationFailed += null, this, null, exception); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Test Exception", result.Message, "should get the exception message in the result"); AssertPushNotificationReturnedInfo(payLoad, result); // senario 4: device subuscription changed broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnDeviceSubscriptionChanged += null, this, string.Empty, string.Empty, null); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Device Subscription Changed", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 5: device subscription expired broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnDeviceSubscriptionExpired += null, this, string.Empty, DateTime.Now, null); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.IsTrue(result.Message.Contains("Device Subscription Expired: ")); AssertPushNotificationReturnedInfo(payLoad, result); // senario 6: Service Exception broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnServiceException += null, this, exception ); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Service Exception: Test Exception", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 7: channel Exception broker.Setup(b => b.StopAllServices(It.IsAny<bool>())).Raises(b => b.OnChannelException += null, this, null, exception); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Channel Exception: Test Exception", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); }
public void AppleNotificationsTest() { var payLoad = new AppleApiNotificationPayLoad("token", "hello World", 0, "default", "wrong key", "deviceUuid"); var testConfigurationManager = new TestConfigurationManager(); var securityService = new SecurityService(testConfigurationManager); var settings = new AppleServiceSettings(testConfigurationManager); var broker = new Mock <IPushBroker>(); broker.Setup(b => b.Dispose()).Verifiable(); broker.Setup(b => b.RegisterService <AppleNotification>(It.IsAny <ApplePushService>(), It.IsAny <bool>())); broker.Setup(b => b.QueueNotification(It.IsAny <AppleNotification>())); var appleService = new AppleNotificationService(broker.Object, new ApiLogger(), settings); var controller = new NotificationsController(appleService, securityService); var exception = new Exception("Test Exception"); // senario 1: invalid Key var result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful, "Should fail, wrong api key"); Assert.AreEqual("Invalid Authentication Key", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 2: send successful payLoad.AuthenticationKey = "LeopardValidApiKey"; broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnNotificationSent += null, this, null); result = controller.Apple(payLoad); Assert.IsTrue(result.IsSuccessful); Assert.AreEqual("Notification Sent", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 3: send failed broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnNotificationFailed += null, this, null, exception); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Test Exception", result.Message, "should get the exception message in the result"); AssertPushNotificationReturnedInfo(payLoad, result); // senario 4: device subuscription changed broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnDeviceSubscriptionChanged += null, this, string.Empty, string.Empty, null); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Device Subscription Changed", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 5: device subscription expired broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnDeviceSubscriptionExpired += null, this, string.Empty, DateTime.Now, null); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.IsTrue(result.Message.Contains("Device Subscription Expired: ")); AssertPushNotificationReturnedInfo(payLoad, result); // senario 6: Service Exception broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnServiceException += null, this, exception); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Service Exception: Test Exception", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); // senario 7: channel Exception broker.Setup(b => b.StopAllServices(It.IsAny <bool>())).Raises(b => b.OnChannelException += null, this, null, exception); result = controller.Apple(payLoad); Assert.IsFalse(result.IsSuccessful); Assert.AreEqual("Channel Exception: Test Exception", result.Message); AssertPushNotificationReturnedInfo(payLoad, result); }