public static List <ZumoTestGroup> CreateTestGroups() { List <ZumoTestGroup> result = new List <ZumoTestGroup> { ZumoSetupTests.CreateTests(), #if !NET45 ZumoLoginTests.CreateTests(), #endif ZumoCustomApiTests.CreateTests(), ZumoRoundTripTests.CreateTests(), ZumoQueryTests.CreateTests(), ZumoCUDTests.CreateTests(), ZumoMiscTests.CreateTests(), #if WINDOWS_PHONE ZumoWP8PushTests.CreateTests(), #endif #if NETFX_CORE ZumoPushTests.CreateTests() #endif }; ZumoTestGroup allTestsUnattendedGroup = CreateGroupWithAllTests(result, true); ZumoTestGroup allTestsGroup = CreateGroupWithAllTests(result, false); result.Add(allTestsUnattendedGroup); result.Add(allTestsGroup); return(result); }
private async void btnSendLogs_Click_1(object sender, RoutedEventArgs e) { int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { // Saves URL in local storage SavedAppInfo appInfo = await AppInfoRepository.Instance.GetSavedAppInfo(); string uploadUrl = this.txtUploadLogsUrl.Text; if (appInfo.LastUploadUrl != uploadUrl) { appInfo.LastUploadUrl = uploadUrl; await AppInfoRepository.Instance.SaveAppInfo(appInfo); } ZumoTestGroup testGroup = allTests[selectedIndex]; List <string> lines = new List <string>(); foreach (var test in testGroup.AllTests) { lines.Add(string.Format("Logs for test {0} (status = {1})", test.Name, test.Status)); lines.AddRange(test.GetLogs()); lines.Add("-----------------------"); } UploadLogsControl uploadLogsPage = new UploadLogsControl(testGroup.Name, string.Join("\n", lines), uploadUrl); await uploadLogsPage.Display(); } else { await Util.MessageBox("A test group needs to be selected", "Error"); } }
private async void btnRunTests_Click_1(object sender, RoutedEventArgs e) { btnRunTests.Content = "Cancel Run"; int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { ZumoTestGroup testGroup = allTests[selectedIndex]; await this.RunTestGroup(testGroup); int passed = testGroup.AllTests.Count(t => t.Status == TestStatus.Passed); int failed = testGroup.AllTests.Count(t => t.Status == TestStatus.Failed); int skipped = testGroup.AllTests.Count(t => t.Status == TestStatus.Skipped); string message = string.Format(CultureInfo.InvariantCulture, "Passed {0} of {1} tests (skipped {2})", passed, (passed + failed), skipped); await Util.MessageBox(message, "Test group finished"); } else { await Util.MessageBox("Please select a test group.", "Error"); } var tb = (ToggleButton)sender; if (!tb.IsChecked.HasValue || tb.IsChecked.Value) { tb.IsChecked = false; } }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Push tests"); const string imageUrl = "http://zumotestserver.azurewebsites.net/content/zumo2.png"; const string wideImageUrl = "http://zumotestserver.azurewebsites.net/content/zumo1.png"; result.AddTest(CreateRegisterChannelTest()); result.AddTest(CreateToastPushTest("sendToastText01", "hello world")); result.AddTest(CreateToastPushTest("sendToastImageAndText03", "ts-iat3-1", "ts-iat3-2", null, imageUrl, "zumo")); result.AddTest(CreateToastPushTest("sendToastImageAndText04", "ts-iat4-1", "ts-iat4-2", "ts-iat4-3", imageUrl, "zumo")); result.AddTest(CreateBadgePushTest(4)); result.AddTest(CreateBadgePushTest("playing")); result.AddTest(CreateRawPushTest("hello world")); result.AddTest(CreateRawPushTest("foobaráéíóú")); result.AddTest(CreateTilePushTest("TileWideImageAndText02", new[] { "tl-wiat2-1", "tl-wiat2-2" }, new[] { wideImageUrl }, new[] { "zumowide" })); result.AddTest(CreateTilePushTest("TileWideImageCollection", new string[0], new[] { wideImageUrl, imageUrl, imageUrl, imageUrl, imageUrl }, new[] { "zumowide", "zumo", "zumo", "zumo", "zumo" })); result.AddTest(CreateTilePushTest("TileWideText02", new[] { "large caption", "tl-wt2-1", "tl-wt2-2", "tl-wt2-3", "tl-wt2-4", "tl-wt2-5", "tl-wt2-6", "tl-wt2-7", "tl-wt2-8" }, new string[0], new string[0])); result.AddTest(CreateTilePushTest("TileSquarePeekImageAndText01", new[] { "tl-spiat1-1", "tl-spiat1-2", "tl-spiat1-3", "tl-spiat1-4" }, new[] { imageUrl }, new[] { "zumo img" })); result.AddTest(CreateTilePushTest("TileSquareBlock", new[] { "24", "aliquam" }, new string[0], new string[0])); result.AddTest(CreateUnregisterChannelTest()); return(result); }
internal static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Offline tests"); result.AddTest(CreateClearStoreTest()); result.AddTest(CreateBasicTest()); result.AddTest(CreateSyncConflictTest(true)); result.AddTest(CreateSyncConflictTest(false)); result.AddTest(CreateAbortPushDuringSyncTest(whereToAbort: SyncAbortLocation.Start)); result.AddTest(CreateAbortPushDuringSyncTest(whereToAbort: SyncAbortLocation.Middle)); result.AddTest(CreateAbortPushDuringSyncTest(whereToAbort: SyncAbortLocation.End)); result.AddTest(ZumoLoginTests.CreateLogoutTest()); result.AddTest(CreateSyncTestForAuthenticatedTable(false)); result.AddTest(ZumoLoginTests.CreateLoginTest(MobileServiceAuthenticationProvider.Facebook)); var noOptimisticConcurrencyTest = CreateNoOptimisticConcurrencyTest(); noOptimisticConcurrencyTest.CanRunUnattended = false; result.AddTest(noOptimisticConcurrencyTest); result.AddTest(CreateSyncTestForAuthenticatedTable(true)); result.AddTest(ZumoLoginTests.CreateLogoutTest()); return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Push tests"); const string imageUrl = "http://zumotestserver.azurewebsites.net/content/zumo2.png"; const string wideImageUrl = "http://zumotestserver.azurewebsites.net/content/zumo1.png"; result.AddTest(CreateRegisterChannelTest()); result.AddTest(CreateToastPushTest("first text", "second text")); result.AddTest(CreateToastPushTest("ãéìôü ÇñÑ", "الكتاب على الطاولة")); result.AddTest(CreateToastPushTest("这本书在桌子上", "本は机の上に")); result.AddTest(CreateToastPushTest("הספר הוא על השולחן", "Книга лежит на столе")); result.AddTest(CreateToastPushTest("with param", "a value", "/UIElements/InputDialog")); result.AddTest(CreateRawPushTest("hello world")); result.AddTest(CreateRawPushTest("foobaráéíóú")); result.AddTest(CreateTilePushTest( "Simple tile", new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative), 0, "Simple tile", new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative), "Back title", "Back content")); result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("After clicking OK, make sure the application is pinned to the start menu")); result.AddTest(ZumoTestCommon.CreateYesNoTest("Is the app in the start menu?", true)); result.AddTest(CreateTilePushTest("Tile with image", new Uri(imageUrl), 3, "Test title", new Uri(wideImageUrl), "Back title", "Back content")); result.AddTest(ZumoTestCommon.CreateYesNoTest("Did the tile change?", true, 3000)); result.AddTest(CreateFlipTilePushTest("Flip tile", new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative), 5, "Flip title", new Uri("/Assets/Tiles/IconicTileSmall.png", UriKind.Relative), "Flip back title", "Flip back content", new Uri("/Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative), new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative), "Flip wide back content", new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative))); result.AddTest(ZumoTestCommon.CreateYesNoTest("Did the tile change?", true, 3000)); result.AddTest(CreateUnregisterChannelTest()); return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Tests Setup"); result.AddTest(CreateSetupTest()); return(result); }
private async Task RunTestGroup(ZumoTestGroup testGroup) { var appUrl = this.txtAppUrl.Text; var appKey = this.txtAppKey.Text; await SaveAppInfo(); string error = null; try { ZumoTestGlobals.Instance.InitializeClient(appUrl, appKey); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "{0}", ex); } if (error != null) { MessageBox.Show(error, "Error initializing client", MessageBoxButton.OK); } else { try { await testGroup.Run(); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "Unhandled exception: {0}", ex); } if (error != null) { MessageBox.Show(error, "Error", MessageBoxButton.OK); } else { if (testGroup.Name.StartsWith(TestStore.AllTestsGroupName) && !string.IsNullOrEmpty(this.txtUploadUrl.Text)) { // Upload logs automatically if running all tests await Util.UploadLogs(this.txtUploadUrl.Text, string.Join("\n", testGroup.GetLogs()), "wp8", true); } else { int passed = this.currentGroup.AllTests.Count(t => t.Status == TestStatus.Passed); int skipped = this.currentGroup.AllTests.Count(t => t.Status == TestStatus.Skipped); int failed = this.currentGroup.AllTests.Count(t => t.Status == TestStatus.Failed); string message = string.Format(CultureInfo.InvariantCulture, "Passed {0} of {1} tests (Skipped {2})", passed, (passed + failed), skipped); MessageBox.Show(message, "Test group finished", MessageBoxButton.OK); } } } }
private void SwapPanels(bool showTestGroups) { this.appBtnBack.IsEnabled = !showTestGroups; this.appBtnReset.IsEnabled = !showTestGroups; this.pnlGroups.Visibility = showTestGroups ? Visibility.Visible : Visibility.Collapsed; this.grdTests.Visibility = showTestGroups ? Visibility.Collapsed : Visibility.Visible; if (showTestGroups) { this.currentGroup = null; } }
private async Task RunTestGroup(ZumoTestGroup testGroup) { var appUrl = this.txtAppUrl.Text; var appKey = this.txtAppKey.Text; string error = null; try { ZumoTestGlobals.Instance.InitializeClient(appUrl, appKey); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "{0}", ex); } if (error != null) { await Alert("Error initializing client", error); } else { try { await testGroup.Run(); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "Unhandled exception: {0}", ex); } if (error != null) { await Alert("Error", error); } else { // Saving app info for future runs var savedAppInfo = await AppInfoRepository.Instance.GetSavedAppInfo(); if (savedAppInfo.LastService == null || savedAppInfo.LastService.AppUrl != appUrl || savedAppInfo.LastService.AppKey != appKey) { if (savedAppInfo.LastService == null) { savedAppInfo.LastService = new MobileServiceInfo(); } savedAppInfo.LastService.AppKey = appKey; savedAppInfo.LastService.AppUrl = appUrl; await AppInfoRepository.Instance.SaveAppInfo(savedAppInfo); } } } }
internal static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Custom API tests"); DateTime now = DateTime.UtcNow; int seed = now.Year * 10000 + now.Month * 100 + now.Day; Random rndGen = new Random(seed); #if !NET45 result.AddTest(ZumoLoginTests.CreateLogoutTest()); #endif result.AddTest(CreateHttpContentApiTest(DataFormat.Xml, DataFormat.Json, rndGen)); #if !NET45 List <ZumoTest> testsWhichNeedAuth = new List <ZumoTest>(); foreach (ApiPermissions apiPermission in Util.EnumGetValues(typeof(ApiPermissions))) { testsWhichNeedAuth.Add(CreateJTokenApiTest(apiPermission, false, rndGen)); } testsWhichNeedAuth.Add(ZumoLoginTests.CreateLoginTest(MobileServiceAuthenticationProvider.Google)); testsWhichNeedAuth.Add(CreateJTokenApiTest(ApiPermissions.User, true, rndGen)); testsWhichNeedAuth.Add(ZumoLoginTests.CreateLogoutTest()); foreach (var test in testsWhichNeedAuth) { test.CanRunUnattended = false; result.AddTest(test); } #endif foreach (DataFormat inputFormat in Util.EnumGetValues(typeof(DataFormat))) { foreach (DataFormat outputFormat in Util.EnumGetValues(typeof(DataFormat))) { result.AddTest(CreateHttpContentApiTest(inputFormat, outputFormat, rndGen)); } } result.AddTest(ZumoQueryTests.CreatePopulateTableTest()); foreach (TypedTestType testType in Util.EnumGetValues(typeof(TypedTestType))) { result.AddTest(CreateTypedApiTest(rndGen, testType)); } return(result); }
private async void btnRunTests_Click_1(object sender, RoutedEventArgs e) { int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { ZumoTestGroup testGroup = allTests[selectedIndex]; await this.RunTestGroup(testGroup); } else { await Alert("Error", "Please select a test group."); } }
private void lstTestGroups_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { ZumoTestGroup testGroup = allTests[selectedIndex]; List <ListViewForTest> sources = testGroup.GetTests().Select((t, i) => new ListViewForTest(i + 1, t)).ToList(); this.lstTests.ItemsSource = sources; this.lblTestGroupTitle.Text = string.Format("{0}. {1}", selectedIndex + 1, testGroup.Name); } else { this.lstTests.ItemsSource = null; } }
private async Task RunTestGroup(ZumoTestGroup testGroup) { var appUrl = this.txtAppUrl.Text; var appKey = this.txtAppKey.Text; await SaveAppInfo(); string error = null; try { ZumoTestGlobals.Instance.InitializeClient(appUrl, appKey); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "{0}", ex); } if (error != null) { MessageBox.Show(error, "Error initializing client", MessageBoxButton.OK); } else { try { await testGroup.Run(); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "Unhandled exception: {0}", ex); } if (error != null) { MessageBox.Show(error, "Error", MessageBoxButton.OK); } else { int passed = this.currentGroup.AllTests.Count(t => t.Status == TestStatus.Passed); string message = string.Format(CultureInfo.InvariantCulture, "Passed {0} of {1} tests", passed, this.currentGroup.AllTests.Count()); MessageBox.Show(message, "Test group finished", MessageBoxButton.OK); // Saving app info for future runs // TODO: implement saving } } }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Misc tests"); result.AddTest(CreateFilterTestWithMultipleRequests(true)); result.AddTest(CreateFilterTestWithMultipleRequests(false)); result.AddTest(new ZumoTest("Validate that 'WithFilter' doesn't change client", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var filteredClient = client.WithFilter(new FilterWhichThrows()); var table = client.GetTable <RoundTripTableItem>(); var items = await table.Take(5).ToListAsync(); test.AddLog("Retrieved items successfully, without filter which throws affecting request."); return(true); })); result.AddTest(new ZumoTest("Validate that filter can bypass service", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; string json = "{'id':1,'name':'John Doe','age':33}".Replace('\'', '\"'); var filtered = client.WithFilter(new FilterToBypassService(201, "application/json", json)); var table = filtered.GetTable("TableWhichDoesNotExist"); var item = new JsonObject(); await table.InsertAsync(item); List <string> errors = new List <string>(); if (!Util.CompareJson(JsonObject.Parse(json), item, errors)) { foreach (var error in errors) { test.AddLog(error); } test.AddLog("Error comparing object returned by the filter"); return(false); } else { return(true); } })); result.AddTest(CreateUserAgentValidationTest()); result.AddTest(CreateParameterPassingTest(true)); result.AddTest(CreateParameterPassingTest(false)); return(result); }
private async void btnRunTests_Click_1(object sender, RoutedEventArgs e) { int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { ZumoTestGroup testGroup = allTests[selectedIndex]; await this.RunTestGroup(testGroup); int passed = testGroup.AllTests.Count(t => t.Status == TestStatus.Passed); string message = string.Format(CultureInfo.InvariantCulture, "Passed {0} of {1} tests", passed, testGroup.AllTests.Count()); await Util.MessageBox(message, "Test group finished"); } else { await Alert("Error", "Please select a test group."); } }
private async void btnRunSelected_Click_1(object sender, RoutedEventArgs e) { var items = this.lstTests.SelectedItems; if (items.Count == 0) { await Alert("Error", "No tests selected"); } else { ZumoTestGroup partialGroup = new ZumoTestGroup("Partial test group"); foreach (ListViewForTest test in items) { partialGroup.AddTest(test.Test); } await this.RunTestGroup(partialGroup); } }
private async void lstTestGroups_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { int selectedIndex = this.lstTestGroups.SelectedIndex; if (selectedIndex >= 0) { ZumoTestGroup testGroup = allTests[selectedIndex]; List <ListViewForTest> sources = testGroup.GetTests().Select((t, i) => new ListViewForTest(i + 1, t)).ToList(); this.lstTests.ItemsSource = sources; this.lblTestGroupTitle.Text = string.Format("{0}. {1}", selectedIndex + 1, testGroup.Name); if (testGroup.Name.StartsWith(TestStore.AllTestsGroupName) && !string.IsNullOrEmpty(this.txtUploadLogsUrl.Text)) { await this.RunTestGroup(testGroup); int passed = testGroup.AllTests.Count(t => t.Status == TestStatus.Passed); int failed = testGroup.AllTests.Count(t => t.Status == TestStatus.Failed); int skipped = testGroup.AllTests.Count(t => t.Status == TestStatus.Skipped); string message = string.Format(CultureInfo.InvariantCulture, "Passed {0} of {1} tests (skipped {2})", passed, (passed + failed), skipped); if (failed == 0) { if (testGroup.Name == TestStore.AllTestsGroupName) { btnRunAllTests.Content = "Passed"; } else { btnRunAllUnattendedTests.Content = "Passed"; } } if (ZumoTestGlobals.ShowAlerts) { await Util.MessageBox(message, "Test group finished"); } ZumoTestGlobals.ShowAlerts = true; } } else { this.lstTests.ItemsSource = null; } }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Push tests"); result.AddTest(CreateRegisterChannelTest()); result.AddTest(CreateToastPushTest("sendToastText01", "hello world")); result.AddTest(CreateToastPushTest("sendToastImageAndText03", "ts-iat3-1", "ts-iat3-2", null, imageUrl, "zumo")); result.AddTest(CreateToastPushTest("sendToastImageAndText04", "ts-iat4-1", "ts-iat4-2", "ts-iat4-3", imageUrl, "zumo")); result.AddTest(CreateBadgePushTest(4)); result.AddTest(CreateBadgePushTest("playing")); result.AddTest(CreateRawPushTest("hello world")); result.AddTest(CreateRawPushTest("foobaráéíóú")); result.AddTest(CreateTilePushTest("TileWideImageAndText02", new[] { "tl-wiat2-1", "tl-wiat2-2" }, new[] { wideImageUrl }, new[] { "zumowide" })); result.AddTest(CreateTilePushTest("TileWideImageCollection", new string[0], new[] { wideImageUrl, imageUrl, imageUrl, imageUrl, imageUrl }, new[] { "zumowide", "zumo", "zumo", "zumo", "zumo" })); result.AddTest(CreateTilePushTest("TileWideText02", new[] { "large caption", "tl-wt2-1", "tl-wt2-2", "tl-wt2-3", "tl-wt2-4", "tl-wt2-5", "tl-wt2-6", "tl-wt2-7", "tl-wt2-8" }, new string[0], new string[0])); result.AddTest(CreateTilePushTest("TileSquarePeekImageAndText01", new[] { "tl-spiat1-1", "tl-spiat1-2", "tl-spiat1-3", "tl-spiat1-4" }, new[] { imageUrl }, new[] { "zumo img" })); result.AddTest(CreateTilePushTest("TileSquareBlock", new[] { "24", "aliquam" }, new string[0], new string[0])); result.AddTest(CreateUnregisterChannelTest()); result.AddTest(CreateRegisterTemplateChannelTest("Toast")); result.AddTest(CreateTemplateToastPushTest("sendToastText01", "World News in English!")); result.AddTest(CreateUnregisterTemplateChannelTest(ZumoPushTestGlobals.NHToastTemplateName)); result.AddTest(CreateRegisterTemplateChannelTest("Tile")); result.AddTest(CreateTemplateTilePushTest("TileWideImageAndText02", new[] { "tl-wiat2-1", "在普通话的世界新闻!" }, new[] { wideImageUrl }, new[] { "zumowide" })); result.AddTest(CreateUnregisterTemplateChannelTest(ZumoPushTestGlobals.NHTileTemplateName)); result.AddTest(CreateRegisterTemplateChannelTest("Badge")); result.AddTest(CreateTemplateBadgePushTest("10")); result.AddTest(CreateUnregisterTemplateChannelTest(ZumoPushTestGlobals.NHBadgeTemplateName)); result.AddTest(CreateRegisterTemplateChannelTest("Raw")); result.AddTest(CreateTemplateRawPushTest("Nouvelles du monde en français!")); result.AddTest(CreateUnregisterTemplateChannelTest(ZumoPushTestGlobals.NHRawTemplateName)); return(result); }
private static ZumoTestGroup CreateGroupWithAllTests(List <ZumoTestGroup> testGroups, bool unattendedOnly) { ZumoTestGroup result = new ZumoTestGroup(unattendedOnly ? AllTestsUnattendedGroupName : AllTestsGroupName); foreach (var group in testGroups) { result.AddTest(ZumoTestCommon.CreateSeparator("Start of group: " + group.Name)); foreach (var test in group.AllTests) { if (test.CanRunUnattended || !unattendedOnly) { result.AddTest(test); } } result.AddTest(ZumoTestCommon.CreateSeparator("------------------")); } return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Push tests"); result.AddTest(CreateRegisterChannelTest()); result.AddTest(CreateToastPushTest("first text", "second text")); result.AddTest(CreateToastPushTest("ãéìôü ÇñÑ", "الكتاب على الطاولة")); result.AddTest(CreateToastPushTest("这本书在桌子上", "本は机の上に")); result.AddTest(CreateToastPushTest("הספר הוא על השולחן", "Книга лежит на столе")); result.AddTest(CreateToastPushTest("with param", "a value", "/UIElements/InputDialog")); result.AddTest(CreateRawPushTest("hello world")); result.AddTest(CreateRawPushTest("foobaráéíóú")); result.AddTest(CreateTilePushTest( "Simple tile", new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative), 0, "Simple tile", new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative), "Back title", "Back content")); result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("After clicking OK, make sure the application is pinned to the start menu")); result.AddTest(ZumoTestCommon.CreateYesNoTest("Is the app in the start menu?", true)); result.AddTest(CreateTilePushTest("Tile with image", new Uri(imageUrl), 3, "Test title", new Uri(wideImageUrl), "Back title", "Back content")); result.AddTest(ZumoTestCommon.CreateYesNoTest("Did the tile change?", true, 3000)); result.AddTest(CreateFlipTilePushTest("Flip tile", new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative), 5, "Flip title", new Uri("/Assets/Tiles/IconicTileSmall.png", UriKind.Relative), "Flip back title", "Flip back content", new Uri("/Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative), new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative), "Flip wide back content", new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative))); result.AddTest(ZumoTestCommon.CreateYesNoTest("Did the tile change?", true, 3000)); result.AddTest(CreateUnregisterChannelTest()); result.AddTest(CreateRegisterChannelTest(true, "toast")); result.AddTest(CreateToastPushTest("World News in English!", null, null, true)); result.AddTest(CreateUnregisterChannelTest(true, "wp8" + ZumoPushTestGlobals.NHToastTemplateName)); result.AddTest(CreateRegisterChannelTest(true, "tile")); result.AddTest(CreateTilePushTest("Tile Template", new Uri(imageUrl), 3, "在普通话的世界新闻!", null, null, null, true)); result.AddTest(CreateUnregisterChannelTest(true, "wp8" + ZumoPushTestGlobals.NHTileTemplateName)); result.AddTest(CreateRegisterChannelTest(true, "raw")); result.AddTest(CreateRawPushTest("Nouvelles du monde en français!", true)); result.AddTest(CreateUnregisterChannelTest(true, "wp8" + ZumoPushTestGlobals.NHRawTemplateName)); return(result); }
private void lstTests_DoubleTapped_1(object sender, DoubleTappedRoutedEventArgs e) { int selectedGroup = this.lstTestGroups.SelectedIndex; if (selectedGroup >= 0) { ZumoTestGroup testGroup = allTests[selectedGroup]; int selectedTest = this.lstTests.SelectedIndex; List <ZumoTest> tests = testGroup.AllTests.ToList(); if (selectedTest >= 0 && selectedTest < tests.Count) { ZumoTest test = tests[selectedTest]; List <string> lines = new List <string>(); lines.Add(string.Format("Logs for test {0} (status = {1})", test.Name, test.Status)); lines.AddRange(test.GetLogs()); lines.Add("-----------------------"); UploadLogsControl uploadLogsPage = new UploadLogsControl(testGroup.Name, string.Join("\n", lines), null); uploadLogsPage.Display(); } } }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Misc tests"); result.AddTest(CreateFilterTestWithMultipleRequests(true)); result.AddTest(CreateFilterTestWithMultipleRequests(false)); result.AddTest(new ZumoTest("Validate that filter can bypass service", async delegate(ZumoTest test) { string json = "{'id':1,'name':'John Doe','age':33}".Replace('\'', '\"'); var client = new MobileServiceClient( ZumoTestGlobals.Instance.Client.ApplicationUri, ZumoTestGlobals.Instance.Client.ApplicationKey, new HandlerToBypassService(201, "application/json", json)); var table = client.GetTable("TableWhichDoesNotExist"); var item = new JObject(); var inserted = await table.InsertAsync(item); List <string> errors = new List <string>(); if (!Util.CompareJson(JObject.Parse(json), inserted, errors)) { foreach (var error in errors) { test.AddLog(error); } test.AddLog("Error comparing object returned by the filter"); return(false); } else { return(true); } })); result.AddTest(CreateUserAgentValidationTest()); result.AddTest(CreateParameterPassingTest(true)); result.AddTest(CreateParameterPassingTest(false)); return(result); }
private async Task RunTestGroup(ZumoTestGroup testGroup) { this.currentTestGroup = testGroup; var clientInitialized = await InitializeClient(); if (!clientInitialized) { return; } string error = null; try { await testGroup.Run(); } catch (Exception ex) { error = string.Format(CultureInfo.InvariantCulture, "Unhandled exception: {0}", ex); } if (error != null) { await Util.MessageBox(error, "Error"); } if (testGroup.Name.StartsWith(TestStore.AllTestsGroupName) && !string.IsNullOrEmpty(this.txtUploadLogsUrl.Text)) { // Upload logs automatically if running all tests and write the the logs location to done.txt var logsUploadedURL = await Util.UploadLogs(this.txtUploadLogsUrl.Text, string.Join("\n", testGroup.GetLogs()), "winstorecs", true); StorageFolder storageFolder = KnownFolders.PicturesLibrary; StorageFile logsUploadedFile = await storageFolder.CreateFileAsync(ZumoTestGlobals.LogsLocationFile, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(logsUploadedFile, logsUploadedURL); } }
public ListViewForTestGroup(int index, ZumoTestGroup testGroup) { this.index = index; this.testGroup = testGroup; }
internal static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Query tests"); result.AddTest(new ZumoTest("Populate table, if necessary", new TestExecution(async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <AllMovies>(); AllMovies allMovies = new AllMovies { Movies = ZumoQueryTestData.AllMovies }; await table.InsertAsync(allMovies); test.AddLog("Result of populating table: {0}", allMovies.Status); return(true); }))); // Numeric fields result.AddTest(CreateQueryTest("GreaterThan and LessThan - Movies from the 90s", m => m.Year > 1989 && m.Year < 2000)); result.AddTest(CreateQueryTest("GreaterEqual and LessEqual - Movies from the 90s", m => m.Year >= 1990 && m.Year <= 1999)); result.AddTest(CreateQueryTest("Compound statement - OR of ANDs - Movies from the 30s and 50s", m => ((m.Year >= 1930) && (m.Year < 1940)) || ((m.Year >= 1950) && (m.Year < 1960)))); result.AddTest(CreateQueryTest("Division, equal and different - Movies from the year 2000 with rating other than R", m => ((m.Year / 1000.0) == 2) && (m.MPAARating != "R"))); result.AddTest(CreateQueryTest("Addition, subtraction, relational, AND - Movies from the 1980s which last less than 2 hours", m => ((m.Year - 1900) >= 80) && (m.Year + 10 < 2000) && (m.Duration < 120))); // String functions result.AddTest(CreateQueryTest("String: StartsWith - Movies which starts with 'The'", m => m.Title.StartsWith("The"), 100)); result.AddTest(CreateQueryTest("String: StartsWith, case insensitive - Movies which start with 'the'", m => m.Title.ToLower().StartsWith("the"), 100)); result.AddTest(CreateQueryTest("String: EndsWith, case insensitive - Movies which end with 'r'", m => m.Title.ToLower().EndsWith("r"))); result.AddTest(CreateQueryTest("String: Contains - Movies which contain the word 'one', case insensitive", m => m.Title.ToUpper().Contains("ONE"))); result.AddTest(CreateQueryTest("String: Length - Movies with small names", m => m.Title.Length < 10, 200)); result.AddTest(CreateQueryTest("String: Substring (1 parameter), length - Movies which end with 'r'", m => m.Title.Substring(m.Title.Length - 1) == "r")); result.AddTest(CreateQueryTest("String: Substring (2 parameters), length - Movies which end with 'r'", m => m.Title.Substring(m.Title.Length - 1, 1) == "r")); result.AddTest(CreateQueryTest("String: Replace - Movies ending with either 'Part 2' or 'Part II'", m => m.Title.Replace("II", "2").EndsWith("Part 2"))); result.AddTest(CreateQueryTest("String: Concat - Movies rated 'PG' or 'PG-13' from the 2000s", m => m.Year >= 2000 && string.Concat(m.MPAARating, "-13").StartsWith("PG-13"))); // String fields result.AddTest(CreateQueryTest("String equals - Movies since 1980 with rating PG-13", m => m.Year >= 1980 && m.MPAARating == "PG-13", 100)); result.AddTest(CreateQueryTest("String field, comparison to null - Movies since 1980 without a MPAA rating", m => m.Year >= 1980 && m.MPAARating == null)); result.AddTest(CreateQueryTest("String field, comparison (not equal) to null - Movies before 1970 with a MPAA rating", m => m.Year < 1970 && m.MPAARating != null)); // Numeric functions result.AddTest(CreateQueryTest("Floor - Movies which last more than 3 hours", m => Math.Floor(m.Duration / 60.0) >= 3)); result.AddTest(CreateQueryTest("Ceiling - Best picture winners which last at most 2 hours", m => m.BestPictureWinner == true && Math.Ceiling(m.Duration / 60.0) == 2)); result.AddTest(CreateQueryTest("Round - Best picture winners which last more than 2.5 hours", m => m.BestPictureWinner == true && Math.Round(m.Duration / 60.0) > 2)); // Date fields result.AddTest(CreateQueryTest("Date: Greater than, less than - Movies with release date in the 70s", m => m.ReleaseDate > new DateTime(1969, 12, 31, 0, 0, 0, DateTimeKind.Utc) && m.ReleaseDate < new DateTime(1971, 1, 1, 0, 0, 0, DateTimeKind.Utc))); result.AddTest(CreateQueryTest("Date: Greater than, less than - Movies with release date in the 80s", m => m.ReleaseDate >= new DateTime(1980, 1, 1, 0, 0, 0, DateTimeKind.Utc) && m.ReleaseDate < new DateTime(1989, 12, 31, 23, 59, 59, DateTimeKind.Utc))); result.AddTest(CreateQueryTest("Date: Equal - Movies released on 1994-10-14 (Shawshank Redemption / Pulp Fiction)", m => m.ReleaseDate == new DateTime(1994, 10, 14, 0, 0, 0, DateTimeKind.Utc))); // Date functions result.AddTest(CreateQueryTest("Date (month): Movies released in November", m => m.ReleaseDate.Month == 11)); result.AddTest(CreateQueryTest("Date (day): Movies released in the first day of the month", m => m.ReleaseDate.Day == 1)); result.AddTest(CreateQueryTest("Date (year): Movies whose year is different than its release year", m => m.ReleaseDate.Year != m.Year, 100)); // Bool fields result.AddTest(CreateQueryTest("Bool: equal to true - Best picture winners before 1950", m => m.Year < 1950 && m.BestPictureWinner == true)); result.AddTest(CreateQueryTest("Bool: equal to false - Best picture winners after 2000", m => m.Year >= 2000 && !(m.BestPictureWinner == false))); result.AddTest(CreateQueryTest("Bool: not equal to false - Best picture winners after 2000", m => m.BestPictureWinner != false && m.Year >= 2000)); // Top and skip result.AddTest(CreateQueryTest("Get all using large $top - 500", null, 500)); result.AddTest(CreateQueryTest("Skip all using large skip - 500", null, null, 500)); result.AddTest(CreateQueryTest("Skip, take, includeTotalCount - movies 11-20, ordered by title", null, 10, 10, new[] { new OrderByClause("Title", true) }, null, true)); result.AddTest(CreateQueryTest("Skip, take, filter includeTotalCount - movies 11-20 which won a best picture award, ordered by year", m => m.BestPictureWinner == true, 10, 10, new[] { new OrderByClause("Year", false) }, null, true)); // Order by result.AddTest(CreateQueryTest("Order by date and string - 50 movies, ordered by release date, then title", null, 50, null, new[] { new OrderByClause("ReleaseDate", false), new OrderByClause("Title", true) })); result.AddTest(CreateQueryTest("Order by number - 30 shortest movies since 1970", m => m.Year >= 1970, 30, null, new[] { new OrderByClause("Duration", true), new OrderByClause("Title", true) }, null, true)); // Select result.AddTest(CreateQueryTest("Select one field - Only title of movies from 2008", m => m.Year == 2008, null, null, null, m => m.Title)); result.AddTest(CreateQueryTest("Select multiple fields - Nicely formatted list of movies from the 2000's", m => m.Year >= 2000, 200, null, new[] { new OrderByClause("ReleaseDate", false), new OrderByClause("Title", true) }, m => string.Format("{0} {1} - {2} minutes", m.Title.PadRight(30), m.BestPictureWinner ? "(best picture)" : "", m.Duration))); // Negative tests result.AddTest(CreateQueryTest <MobileServiceInvalidOperationException>("(Neg) Very large top value", m => m.Year > 2000, 1001)); result.AddTest(CreateQueryTest <NotSupportedException>("(Neg) Unsupported predicate: unsupported arithmetic", m => Math.Sqrt(m.Year) > 43)); // Invalid lookup for (int i = -1; i <= 0; i++) { int id = i; result.AddTest(new ZumoTest("(Neg) Invalid id for lookup: " + i, async delegate(ZumoTest test) { var table = ZumoTestGlobals.Instance.Client.GetTable <Movie>(); try { var item = await table.LookupAsync(id); test.AddLog("Error, LookupAsync for id = {0} should have failed, but succeeded: {1}", id, item); return(false); } catch (MobileServiceInvalidOperationException ex) { test.AddLog("Caught expected exception - {0}: {1}", ex.GetType().FullName, ex.Message); return(true); } })); } result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("The next test will show a dialog with certain movies. Please validate that movie titles and release years are shown correctly in the list.")); result.AddTest(new ZumoTest("ToCollectionView - displaying movies on a ListBox", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <Movie>(); var query = from m in table where m.Year > 1980 orderby m.ReleaseDate descending select new { Date = m.ReleaseDate.ToUniversalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), Title = m.Title }; var newPage = new MoviesDisplayPage(); newPage.SetMoviesSource(query.ToCollectionView()); await newPage.Display(); return(true); })); result.AddTest(ZumoTestCommon.CreateYesNoTest("Were the movies displayed correctly?", true)); return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Round trip tests"); result.AddTest(CreateSetupSchemaTest()); DateTime now = DateTime.UtcNow; int seed = now.Year * 10000 + now.Month * 100 + now.Day; Random rndGen = new Random(seed); result.AddTest(CreateSimpleTypedRoundTripTest("String: Empty", RoundTripTestType.String, "")); result.AddTest(CreateSimpleTypedRoundTripTest("String: null", RoundTripTestType.String, null)); result.AddTest(CreateSimpleTypedRoundTripTest("String: random value", RoundTripTestType.String, Util.CreateSimpleRandomString(rndGen, 10))); result.AddTest(CreateSimpleTypedRoundTripTest("String: large (1000 characters)", RoundTripTestType.String, new string('*', 1000))); result.AddTest(CreateSimpleTypedRoundTripTest("String: large (64k+1 characters)", RoundTripTestType.String, new string('*', 65537))); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Latin", RoundTripTestType.String, "ãéìôü ÇñÑ")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Arabic", RoundTripTestType.String, "الكتاب على الطاولة")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Chinese", RoundTripTestType.String, "这本书在桌子上")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Chinese 2", RoundTripTestType.String, "⒈①Ⅻㄨㄩ 啊阿鼾齄 丂丄狚狛 狜狝﨨﨩 ˊˋ˙–〇 㐀㐁䶴䶵")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Japanese", RoundTripTestType.String, "本は机の上に")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Hebrew", RoundTripTestType.String, "הספר הוא על השולחן")); result.AddTest(CreateSimpleTypedRoundTripTest("String: non-ASCII characters - Russian", RoundTripTestType.String, "Книга лежит на столе")); result.AddTest(CreateSimpleTypedRoundTripTest("Date: now", RoundTripTestType.Date, Util.TrimSubMilliseconds(DateTime.Now))); result.AddTest(CreateSimpleTypedRoundTripTest("Date: now (UTC)", RoundTripTestType.Date, Util.TrimSubMilliseconds(DateTime.UtcNow))); result.AddTest(CreateSimpleTypedRoundTripTest("Date: null", RoundTripTestType.Date, null)); result.AddTest(CreateSimpleTypedRoundTripTest("Date: min date", RoundTripTestType.Date, DateTime.MinValue)); result.AddTest(CreateSimpleTypedRoundTripTest("Date: specific date, before unix 0", RoundTripTestType.Date, new DateTime(1901, 1, 1))); result.AddTest(CreateSimpleTypedRoundTripTest("Date: specific date, after unix 0", RoundTripTestType.Date, new DateTime(2000, 12, 31))); result.AddTest(CreateSimpleTypedRoundTripTest("Bool: true", RoundTripTestType.Bool, true)); result.AddTest(CreateSimpleTypedRoundTripTest("Bool: false", RoundTripTestType.Bool, false)); result.AddTest(CreateSimpleTypedRoundTripTest("Bool: null", RoundTripTestType.Bool, null)); result.AddTest(CreateSimpleTypedRoundTripTest("Int: zero", RoundTripTestType.Int, 0)); result.AddTest(CreateSimpleTypedRoundTripTest("Int: MaxValue", RoundTripTestType.Int, int.MaxValue)); result.AddTest(CreateSimpleTypedRoundTripTest("Int: MinValue", RoundTripTestType.Int, int.MinValue)); result.AddTest(CreateSimpleTypedRoundTripTest("Long: zero", RoundTripTestType.Long, 0L)); long maxAllowedValue = 0x0020000000000000; long minAllowedValue = 0; unchecked { minAllowedValue = (long)0xFFE0000000000000; } result.AddTest(CreateSimpleTypedRoundTripTest("Long: max allowed", RoundTripTestType.Long, maxAllowedValue)); result.AddTest(CreateSimpleTypedRoundTripTest("Long: min allowed", RoundTripTestType.Long, minAllowedValue)); long largePositiveValue = maxAllowedValue - rndGen.Next(0, int.MaxValue); long largeNegativeValue = minAllowedValue + rndGen.Next(0, int.MaxValue); result.AddTest(CreateSimpleTypedRoundTripTest("Long: large value, less than max allowed (" + largePositiveValue + ")", RoundTripTestType.Long, largePositiveValue)); result.AddTest(CreateSimpleTypedRoundTripTest("Long: large negative value, more than min allowed (" + largeNegativeValue + ")", RoundTripTestType.Long, largeNegativeValue)); result.AddTest(CreateSimpleTypedRoundTripTest <InvalidOperationException>("(Neg) Long: more than max allowed", RoundTripTestType.Long, maxAllowedValue + 1)); result.AddTest(CreateSimpleTypedRoundTripTest <InvalidOperationException>("(Neg) Long: less than min allowed", RoundTripTestType.Long, minAllowedValue - 1)); result.AddTest(CreateSimpleTypedRoundTripTest("Enum (with JSON converter): simple value", RoundTripTestType.Enum, EnumType.Second)); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (custom table serialization): simple value", RoundTripTestType.ComplexWithCustomSerialization, new ComplexType2(rndGen))); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (custom table serialization): null", RoundTripTestType.ComplexWithCustomSerialization, null)); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (converter): empty array", RoundTripTestType.ComplexWithConverter, new ComplexType[0])); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (converter): 1-element array", RoundTripTestType.ComplexWithConverter, new ComplexType[] { new ComplexType(rndGen) })); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (converter): multi-element array", RoundTripTestType.ComplexWithConverter, new ComplexType[] { new ComplexType(rndGen), null, new ComplexType(rndGen) })); result.AddTest(CreateSimpleTypedRoundTripTest( "Complex type (converter): null array", RoundTripTestType.ComplexWithConverter, null)); result.AddTest( CreateSimpleTypedRoundTripTest <ArgumentException>( "(Neg) Insert item with non-default id", RoundTripTestType.Id, 1)); // Untyped table result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: Empty", "string1", "")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: null", "string1", null)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: random value", "string1", Util.CreateSimpleRandomString(rndGen, 10))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: large (1000 characters)", "string1", new string('*', 1000))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: large (64k+1 characters)", "string1", new string('*', 65537))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Latin", "string1", "ãéìôü ÇñÑ")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Arabic", "string1", "الكتاب على الطاولة")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Chinese", "string1", "这本书在桌子上")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Chinese 2", "string1", "⒈①Ⅻㄨㄩ 啊阿鼾齄 丂丄狚狛 狜狝﨨﨩 ˊˋ˙–〇 㐀㐁䶴䶵")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Japanese", "string1", "本は机の上に")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Hebrew", "string1", "הספר הוא על השולחן")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped String: non-ASCII characters - Russian", "string1", "Книга лежит на столе")); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: now", "date1", Util.TrimSubMilliseconds(DateTime.Now))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: now (UTC)", "date1", Util.TrimSubMilliseconds(DateTime.UtcNow))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: null", "date1", null)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: min date", "date1", DateTime.MinValue)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: specific date, before unix 0", "date1", new DateTime(1901, 1, 1))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Date: specific date, after unix 0", "date1", new DateTime(2000, 12, 31))); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Bool: true", "bool1", true)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Bool: false", "bool1", false)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Bool: null", "bool1", null)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Int: zero", "int1", 0)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Int: MaxValue", "int1", int.MaxValue)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Int: MinValue", "int1", int.MinValue)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Long: zero", "long1", 0L)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Long: max allowed", "long1", maxAllowedValue)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Long: min allowed", "long1", minAllowedValue)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Long: more than max allowed (positive) for typed", "long1", maxAllowedValue + 1)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped Long: more than max allowed (negative) for typed", "long1", minAllowedValue - 1)); result.AddTest(CreateSimpleUntypedRoundTripTest("Untyped complex (object): simple value", JObject.Parse(@"{""complexType2"":{""Name"":""John Doe"",""Age"":33,""Friends"":[""Jane Roe"", ""John Smith""]}}"))); result.AddTest(CreateSimpleUntypedRoundTripTest( "Untyped complex (object): null", JObject.Parse(@"{""complexType2"":null}"))); result.AddTest(CreateSimpleUntypedRoundTripTest( "Untyped complex (array): simple value", JObject.Parse(@"{""complexType1"":[{""Name"":""Scooby"",""Age"":10}, {""Name"":""Shaggy"",""Age"":19}]}"))); result.AddTest(CreateSimpleUntypedRoundTripTest( "Untyped complex (array): empty array", JObject.Parse(@"{""complexType1"":[]}"))); result.AddTest(CreateSimpleUntypedRoundTripTest( "Untyped complex (array): null", JObject.Parse(@"{""complexType1"":null}"))); result.AddTest(CreateSimpleUntypedRoundTripTest( "Untyped complex (array): array with null elements", JObject.Parse(@"{""complexType1"":[{""Name"":""Scooby"",""Age"":10}, null, {""Name"":""Shaggy"",""Age"":19}]}"))); result.AddTest(CreateSimpleUntypedRoundTripTest <ArgumentException>("(Neg) Insert item with non-default 'id' property", JObject.Parse("{\"id\":1,\"value\":2}"))); result.AddTest(CreateSimpleUntypedRoundTripTest <ArgumentException>("(Neg) Insert item with non-default 'ID' property", JObject.Parse("{\"ID\":1,\"value\":2}"))); result.AddTest(CreateSimpleUntypedRoundTripTest <ArgumentException>("(Neg) Insert item with non-default 'Id' property", JObject.Parse("{\"Id\":1,\"value\":2}"))); return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Misc tests"); result.AddTest(CreateFilterTestWithMultipleRequests(true)); result.AddTest(CreateFilterTestWithMultipleRequests(false)); result.AddTest(new ZumoTest("Validate that filter can bypass service", async delegate(ZumoTest test) { string json = "{'id':1,'name':'John Doe','age':33}".Replace('\'', '\"'); var client = new MobileServiceClient( ZumoTestGlobals.Instance.Client.ApplicationUri, ZumoTestGlobals.Instance.Client.ApplicationKey, new HandlerToBypassService(201, "application/json", json)); var table = client.GetTable("TableWhichDoesNotExist"); var item = new JObject(); var inserted = await table.InsertAsync(item); List <string> errors = new List <string>(); if (!Util.CompareJson(JObject.Parse(json), inserted, errors)) { foreach (var error in errors) { test.AddLog(error); } test.AddLog("Error comparing object returned by the filter"); return(false); } else { return(true); } })); result.AddTest(CreateUserAgentValidationTest()); result.AddTest(CreateParameterPassingTest(true)); result.AddTest(CreateParameterPassingTest(false)); result.AddTest(CreateOptimisticConcurrencyTest("Conflicts (client side) - client wins", (clientItem, serverItem) => { var mergeResult = clientItem.Clone(); mergeResult.Version = serverItem.Version; return(mergeResult); })); result.AddTest(CreateOptimisticConcurrencyTest("Conflicts (client side) - server wins", (clientItem, serverItem) => { return(serverItem); })); result.AddTest(CreateOptimisticConcurrencyTest("Conflicts (client side) - Name from client, Number from server", (clientItem, serverItem) => { var mergeResult = serverItem.Clone(); mergeResult.Name = clientItem.Name; return(mergeResult); })); result.AddTest(CreateOptimisticConcurrencyWithServerConflictsTest("Conflicts (server side) - client wins", true)); result.AddTest(CreateOptimisticConcurrencyWithServerConflictsTest("Conflicts (server side) - server wins", false)); result.AddTest(CreateSystemPropertiesTest(true)); result.AddTest(CreateSystemPropertiesTest(false)); return(result); }
public static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Login tests"); result.AddTest(CreateLogoutTest()); result.AddTest(CreateCRUDTest(TablePublicPermission, null, TablePermission.Public, false)); result.AddTest(CreateCRUDTest(TableApplicationPermission, null, TablePermission.Application, false)); result.AddTest(CreateCRUDTest(TableUserPermission, null, TablePermission.User, false)); result.AddTest(CreateCRUDTest(TableAdminPermission, null, TablePermission.Admin, false)); int indexOfTestsWithAuthentication = result.AllTests.Count(); Dictionary <MobileServiceAuthenticationProvider, bool> providersWithRecycledTokenSupport; providersWithRecycledTokenSupport = new Dictionary <MobileServiceAuthenticationProvider, bool> { { MobileServiceAuthenticationProvider.Facebook, true }, { MobileServiceAuthenticationProvider.Google, false }, // Known bug - Drop login via Google token until Google client flow is reintroduced { MobileServiceAuthenticationProvider.MicrosoftAccount, false }, { MobileServiceAuthenticationProvider.Twitter, false }, { MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, false } }; #if !WINDOWS_PHONE result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("In the next few tests you will be prompted for username / password five times.")); #endif foreach (MobileServiceAuthenticationProvider provider in Util.EnumGetValues(typeof(MobileServiceAuthenticationProvider))) { result.AddTest(CreateLogoutTest()); #if !WINDOWS_PHONE result.AddTest(CreateLoginTest(provider, false)); #else result.AddTest(CreateLoginTest(provider)); #endif result.AddTest(CreateCRUDTest(TableApplicationPermission, provider.ToString(), TablePermission.Application, true)); result.AddTest(CreateCRUDTest(TableUserPermission, provider.ToString(), TablePermission.User, true)); result.AddTest(CreateCRUDTest(TableAdminPermission, provider.ToString(), TablePermission.Admin, true)); bool supportsTokenRecycling; if (providersWithRecycledTokenSupport.TryGetValue(provider, out supportsTokenRecycling) && supportsTokenRecycling) { result.AddTest(CreateLogoutTest()); result.AddTest(CreateClientSideLoginTest(provider)); result.AddTest(CreateCRUDTest(TableUserPermission, provider.ToString(), TablePermission.User, userIsAuthenticated: true, usingSingleSignOnOrToken: true)); } } #if !WINDOWS_PHONE result.AddTest(ZumoTestCommon.CreateYesNoTest("Were you prompted for username / password five times?", true)); #endif result.AddTest(CreateLogoutTest()); #if WINDOWS_PHONE && !WP75 result.AddTest(ZumoTestCommon.CreateInputTest("Enter Live App Client ID", testPropertyBag, ClientIdKeyName)); #endif #if !WP75 result.AddTest(CreateLiveSDKLoginTest()); result.AddTest(CreateCRUDTest(TableUserPermission, MicrosoftViaLiveSDK, TablePermission.User, true)); #endif #if !WINDOWS_PHONE result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("We'll log in again; you may or may not be asked for password in the next few moments.")); foreach (MobileServiceAuthenticationProvider provider in Enum.GetValues(typeof(MobileServiceAuthenticationProvider))) { if (provider == MobileServiceAuthenticationProvider.MicrosoftAccount) { // Known issue - SSO with MS account will not work if Live SDK is also used continue; } result.AddTest(CreateLogoutTest()); result.AddTest(CreateLoginTest(provider, true)); result.AddTest(CreateCRUDTest(TableUserPermission, provider.ToString(), TablePermission.User, userIsAuthenticated: true, usingSingleSignOnOrToken: true)); } result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("Now we'll continue running the tests, but you *should not be prompted for the username or password anymore*.")); foreach (MobileServiceAuthenticationProvider provider in Enum.GetValues(typeof(MobileServiceAuthenticationProvider))) { if (provider == MobileServiceAuthenticationProvider.MicrosoftAccount) { // Known issue - SSO with MS account will not work if Live SDK is also used continue; } result.AddTest(CreateLogoutTest()); result.AddTest(CreateLoginTest(provider, true)); result.AddTest(CreateCRUDTest(TableUserPermission, provider.ToString(), TablePermission.User, userIsAuthenticated: true, usingSingleSignOnOrToken: true)); } result.AddTest(ZumoTestCommon.CreateYesNoTest("Were you prompted for the username in any of the providers?", false)); #endif foreach (var test in result.AllTests.Skip(indexOfTestsWithAuthentication)) { test.CanRunUnattended = false; } // Clean-up any logged in user result.AddTest(CreateLogoutTest()); return(result); }
internal static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Update / delete tests"); DateTime now = DateTime.UtcNow; int seed = now.Year * 10000 + now.Month * 100 + now.Day; Random rndGen = new Random(seed); result.AddTest(CreateTypedUpdateTest("Update typed item", new RoundTripTableItem(rndGen), new RoundTripTableItem(rndGen))); result.AddTest(CreateTypedUpdateTest( "Update typed item, setting values to null", new RoundTripTableItem(rndGen), new RoundTripTableItem(rndGen) { Bool1 = null, ComplexType2 = null, Int1 = null, String1 = null, ComplexType1 = null })); result.AddTest(CreateTypedUpdateTest <MobileServiceInvalidOperationException>("(Neg) Update typed item, non-existing item id", new RoundTripTableItem(rndGen), new RoundTripTableItem(rndGen) { Id = 1000000000 }, false)); result.AddTest(CreateTypedUpdateTest <ArgumentException>("(Neg) Update typed item, id = 0", new RoundTripTableItem(rndGen), new RoundTripTableItem(rndGen) { Id = 0 }, false)); string toInsertJsonString = @"{ ""string1"":""hello"", ""bool1"":true, ""int1"":-1234, ""double1"":123.45, ""long1"":1234, ""date1"":""2012-12-13T09:23:12.000Z"", ""complexType1"":[{""Name"":""John Doe"",""Age"":33}, null], ""complexType2"":{""Name"":""John Doe"",""Age"":33,""Friends"":[""Jane""]} }"; string toUpdateJsonString = @"{ ""string1"":""world"", ""bool1"":false, ""int1"":9999, ""double1"":888.88, ""long1"":77777777, ""date1"":""1999-05-23T19:15:54.000Z"", ""complexType1"":[{""Name"":""Jane Roe"",""Age"":23}, null], ""complexType2"":{""Name"":""Jane Roe"",""Age"":23,""Friends"":[""John""]} }"; result.AddTest(CreateUntypedUpdateTest("Update untyped item", toInsertJsonString, toUpdateJsonString)); JsonValue nullValue = JsonValue.Parse("null"); JsonObject toUpdate = JsonObject.Parse(toUpdateJsonString); toUpdate["string1"] = nullValue; toUpdate["bool1"] = nullValue; toUpdate["complexType2"] = nullValue; toUpdate["complexType1"] = nullValue; toUpdate["int1"] = nullValue; result.AddTest(CreateUntypedUpdateTest("Update untyped item, setting values to null", toInsertJsonString, toUpdate.Stringify())); toUpdate["id"] = JsonValue.CreateNumberValue(1000000000); result.AddTest(CreateUntypedUpdateTest <MobileServiceInvalidOperationException>("(Neg) Update untyped item, non-existing item id", toInsertJsonString, toUpdate.Stringify(), false)); toUpdate["id"] = JsonValue.CreateNumberValue(0); result.AddTest(CreateUntypedUpdateTest <ArgumentException>("(Neg) Update typed item, id = 0", toInsertJsonString, toUpdateJsonString, false)); // Delete tests result.AddTest(CreateDeleteTest("Delete typed item", true, DeleteTestType.ValidDelete)); result.AddTest(CreateDeleteTest("(Neg) Delete typed item with non-existing id", true, DeleteTestType.NonExistingId)); result.AddTest(CreateDeleteTest("Delete untyped item", false, DeleteTestType.ValidDelete)); result.AddTest(CreateDeleteTest("(Neg) Delete untyped item with non-existing id", false, DeleteTestType.NonExistingId)); result.AddTest(CreateDeleteTest("(Neg) Delete untyped item without id field", false, DeleteTestType.NoIdField)); result.AddTest(new ZumoTest("Refresh - updating item with server modifications", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <RoundTripTableItem>(); int randomSeed = Environment.TickCount; test.AddLog("Using random seed {0}", randomSeed); Random random = new Random(randomSeed); var item = new RoundTripTableItem(random); test.AddLog("Item to be inserted: {0}", item); await table.InsertAsync(item); test.AddLog("Added item with id = {0}", item.Id); var item2 = new RoundTripTableItem(random); item2.Id = item.Id; test.AddLog("Item to update: {0}", item2); await table.UpdateAsync(item2); test.AddLog("Updated item"); test.AddLog("Now refreshing first object"); await table.RefreshAsync(item); test.AddLog("Refreshed item: {0}", item); if (item.Equals(item2)) { test.AddLog("Item was refreshed successfully"); return(true); } else { test.AddLog("Error, refresh didn't happen successfully"); return(false); } })); result.AddTest(new ZumoTest("Refresh item without id does not send request", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client.WithFilter(new FilterWhichThrows()); var table = client.GetTable <RoundTripTableItem>(); var item = new RoundTripTableItem(new Random()); item.Id = 0; await table.RefreshAsync(item); test.AddLog("Call to RefreshAsync didn't go to the network, as expected."); return(true); })); return(result); }