Esempio n. 1
0
 public void InvalidBodyTemplateIfNotXml()
 {
     try
     {
         var registration = new WnsTemplateRegistration("uri", "junkBodyTemplate", "testName");
         Assert.Fail("Expected templateBody that is not XML to throw ArgumentException");
     }
     catch
     {
         // PASSES
     }
 }
 public void InvalidBodyTemplateIfNotXml()
 {
     try
     {
         var registration = new WnsTemplateRegistration("uri", "junkBodyTemplate", "testName");
         Assert.Fail("Expected templateBody that is not XML to throw ArgumentException");
     }
     catch
     {
         // PASSES
     }           
 }
Esempio n. 3
0
 public void InvalidBodyTemplateIfImproperXml()
 {
     try
     {
         var registration = new WnsTemplateRegistration(
             "uri",
             "<foo><visual><binding template=\"ToastText01\"><text id=\"1\">$(message)</text></binding></visual></foo>",
             "testName");
         Assert.Fail("Expected templateBody with unexpected first XML node to throw ArgumentException");
     }
     catch
     {
         // PASSES
     }
 }
 public void InvalidBodyTemplateIfImproperXml()
 {
     try
     {
         var registration = new WnsTemplateRegistration(
             "uri",
             "<foo><visual><binding template=\"ToastText01\"><text id=\"1\">$(message)</text></binding></visual></foo>", 
             "testName");
         Assert.Fail("Expected templateBody with unexpected first XML node to throw ArgumentException");
     }
     catch
     {
         // PASSES
     }           
 }
Esempio n. 5
0
        private static ZumoTest CreateRegisterTemplateChannelTest(string nhNotificationType)
        {
            return(new ZumoTest("Register template " + nhNotificationType + " push channel", async delegate(ZumoTest test)
            {
                var client = ZumoTestGlobals.Instance.Client;
                var push = client.GetPush();
                WnsTemplateRegistration reg = null;
                switch (nhNotificationType.ToLower())
                {
                case "toast":
                    var toastTemplate = BuildXmlToastPayload("sendToastText01", "$(News_English)");
                    reg = new WnsTemplateRegistration(ZumoPushTests.pushChannel.Uri, toastTemplate.ToString(), ZumoPushTestGlobals.NHToastTemplateName, "World English".Split());
                    break;

                case "raw":
                    var rawTemplate = "<raw>$(News_French)</raw>";
                    IDictionary <string, string> wnsHeaders = new Dictionary <string, string>();
                    wnsHeaders.Add("X-WNS-Type", "wns/raw");
                    reg = new WnsTemplateRegistration(ZumoPushTests.pushChannel.Uri, rawTemplate, ZumoPushTestGlobals.NHRawTemplateName, "World Mandarin".Split(), wnsHeaders);
                    break;

                case "badge":
                    var badgeTemplate = BuildBadgeXmlPayload("$(News_Badge)");
                    reg = new WnsTemplateRegistration(ZumoPushTests.pushChannel.Uri, badgeTemplate.ToString(), ZumoPushTestGlobals.NHBadgeTemplateName, "World Badge".Split());
                    break;

                case "tile":
                    var tileTemplate = BuildXmlTilePayload("TileWideImageAndText02", new[] { "tl-wiat2-1", "$(News_Mandarin)" }, new[] { wideImageUrl }, new[] { "zumowide" });
                    reg = new WnsTemplateRegistration(ZumoPushTests.pushChannel.Uri, tileTemplate.ToString(), ZumoPushTestGlobals.NHTileTemplateName, "World Mandarin".Split());
                    break;

                default:
                    throw new Exception("Template type" + nhNotificationType + "is not supported.");
                }

                await push.RegisterAsync(reg);
                pushChannelUri = null;
                test.AddLog("Registered " + nhNotificationType + " template with NH succeeded.");
                pushChannel.PushNotificationReceived += pushChannel_PushNotificationReceived;
                return true;
            }, ZumoTestGlobals.RuntimeFeatureNames.NH_PUSH_ENABLED));
        }