public void Dashboard_Login_GetAccessToken() { TestBaseWebDriver test = base.TestContainer[Gallio.Framework.TestContext.CurrentContext.Test.Name]; GeneralMethods utility = test.GeneralMethods; try { DashboardAPIBase api = new DashboardAPIBase(); HttpWebResponse response = api.getAccessTokenObject(api.ConsumerKey, api.ConsumerSecret, api.Username, api.Password, api.ChurchCode); AccessToken token = api.JsonToObject <AccessToken>(response); TestLog.WriteLine(string.Format("{0}|{1}|{2}|{3}", token.user.firstName, token.user.lastName, token.accessToken, token.tokenType)); Assert.AreEqual("FT", token.user.firstName); test.Dashboard.LoginWebDriver(); Assert.IsTrue(utility.IsElementExist(By.Id("settings"))); } finally { //clear test data } }
public void Dashboard_TimeFrame_SetTimeFrame() { TestBaseWebDriver test = base.TestContainer[Gallio.Framework.TestContext.CurrentContext.Test.Name]; GeneralMethods utility = test.GeneralMethods; DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); try { DashboardAPIBase api = new DashboardAPIBase(); int churchId = test.SQL.FetchChurchID(api.ChurchCode); int userId = test.SQL.User_FetchID(churchId, api.Email, api.Username); string jsonBody = string.Format("{{ userId: {0}, firstDay: \"sunday\", window:\"week\"}}", userId.ToString()); TestLog.WriteLine(jsonBody); TimeFrame obj = api.DoPostRequest <TimeFrame>("/api/dashboard/settings/date", jsonBody); TestLog.WriteLine(string.Format("{0}|{1}|{2}|{3}|{4}", obj.timeframeId, obj.time, obj.userId, obj.window, obj.firstDay)); TestLog.WriteLine(now.ToLongDateString() + "|" + now.ToLongTimeString()); test.Dashboard.LoginWebDriver(); DashboardHomePage dashboard = new DashboardHomePage(test.Driver, test.GeneralMethods); Assert.AreEqual(dashboard.whichViewTypeIsSelected(), "week"); Assert.AreEqual(dashboard.whichStartDayIsSelected(), "sunday"); DateTime[] dateRange = test.Dashboard.getDateRange(now, obj.window, test.Dashboard.getIntStartDay("sunday")); string format = "MMMM d"; Assert.IsTrue(dashboard.getCurrentSDateRangeString().Contains(dateRange[0].ToString(format))); Assert.IsTrue(dashboard.getCurrentSDateRangeString().Contains(dateRange[1].ToString(format))); } finally { //clear test data } }
public void Dashboard_TimeFrame_GetDefaultTimeFrame() { TestBaseWebDriver test = base.TestContainer[Gallio.Framework.TestContext.CurrentContext.Test.Name]; GeneralMethods utility = test.GeneralMethods; DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); try { DashboardAPIBase api = new DashboardAPIBase(); HttpWebResponse response = api.getAccessTokenObject(api.ConsumerKey, api.ConsumerSecret, api.Username, api.Password, api.ChurchCode); AccessToken token = api.JsonToObject <AccessToken>(response); TimeFrame obj = api.DoGetRequest <TimeFrame>(string.Format("/api/dashboard/settings/date/{0}", token.user.userId)); TestLog.WriteLine(string.Format("{0}|{1}|{2}|{3}|{4}", obj.timeframeId, obj.time, obj.userId, obj.window, obj.firstDay)); TestLog.WriteLine(now.ToLongDateString() + "|" + now.ToLongTimeString()); test.Dashboard.LoginWebDriver(); DashboardHomePage dashboard = new DashboardHomePage(test.Driver, test.GeneralMethods); Assert.AreEqual(dashboard.whichViewTypeIsSelected(), obj.window); Assert.AreEqual(dashboard.whichStartDayIsSelected(), obj.firstDay); DateTime[] dateRange = test.Dashboard.getDateRange(now, obj.window, test.Dashboard.getIntStartDay(obj.firstDay)); string format = "MMMM d"; TestLog.WriteLine(dateRange[0].ToString(format)); TestLog.WriteLine(dashboard.getCurrentSDateRangeString()); Assert.IsTrue(dashboard.getCurrentSDateRangeString().Contains(dateRange[0].ToString(format))); Assert.IsTrue(dashboard.getCurrentSDateRangeString().Contains(dateRange[1].ToString(format))); } finally { //clear test data } }