public void TestContains()
        {
            ToastArguments qs = new ToastArguments();

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            qs.Add("isBook");

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsTrue(qs.Contains("isBook", null));
            Assert.IsFalse(qs.Contains("isBook", "True"));

            qs.Add("isBook", "True");

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsFalse(qs.Contains("isBook", null));
            Assert.IsTrue(qs.Contains("isBook", "True"));

            qs.Add("name", "Andrew");

            Assert.IsTrue(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", null));     // Value doesn't exist
            Assert.IsTrue(qs.Contains("name", "Andrew"));
            Assert.IsFalse(qs.Contains("Name", "Andrew")); // Wrong case on name
            Assert.IsFalse(qs.Contains("name", "andrew")); // Wrong case on value
            Assert.IsFalse(qs.Contains("Name"));           // Wrong case on name
        }
        public static ToastArguments MakeDeleteCacheToastArguments(string videoId)
        {
            var args = new ToastArguments();

            args.Add(ToastArgumentKey_Action, ToastArgumentValue_Action_DeleteCache);
            args.Add(ToastArgumentKey_Id, videoId);
            return(args);
        }
        public static ToastArguments MakePlayVideoToastArguments(string videoId)
        {
            var args = new ToastArguments();

            args.Add(ToastArgumentKey_Action, ToastArgumentValue_Action_PlayVideo);
            args.Add(ToastArgumentKey_Id, videoId);
            return(args);
        }
        public static ToastArguments MakeOpenPageWithIdToastArguments(HohoemaPageType pageType, string id)
        {
            var args = new ToastArguments();

            args.Add(ToastArgumentKey_Action, ToastArgumentValue_Action_OpenPage);
            args.Add(ToastArgumentKey_PageType, pageType.ToString());
            args.Add(ToastArgumentKey_PageParameters, $"id={id}");
            return(args);
        }
        public static ToastArguments MakePlayPlaylistToastArguments(PlaylistItemsSourceOrigin origin, string playlistId)
        {
            var args = new ToastArguments();

            args.Add(ToastArgumentKey_Action, ToastArgumentValue_Action_PlayPlaylist);
            args.Add(ToastArgumentKey_PlaylistOrigin, origin.ToString());
            args.Add(ToastArgumentKey_PlaylistId, playlistId);
            return(args);
        }
        public static ToastArguments MakeOpenPageToastArguments(HohoemaPageType pageType, string parameters = null)
        {
            var args = new ToastArguments();

            args.Add(ToastArgumentKey_Action, ToastArgumentValue_Action_OpenPage);
            args.Add(ToastArgumentKey_PageType, pageType.ToString());
            if (parameters != null)
            {
                args.Add(ToastArgumentKey_PageParameters, parameters);
            }
            return(args);
        }
        public void TestAdd()
        {
            ToastArguments qs = new ToastArguments();

            qs.Add("name", "Andrew");

            AssertEqual(
                new ToastArguments()
            {
                { "name", "Andrew" }
            }, qs);

            qs.Add("age", "22");

            AssertEqual(
                new ToastArguments()
            {
                { "name", "Andrew" },
                { "age", "22" }
            }, qs);

            qs.Add("name", "Lei");

            AssertEqual(
                new ToastArguments()
            {
                { "name", "Lei" },
                { "age", "22" }
            }, qs);

            string nullStr = null;

            qs.Add("name", nullStr);

            AssertEqual(
                new ToastArguments()
            {
                { "name" },
                { "age", "22" }
            }, qs);
        }
        public void TestCount()
        {
            ToastArguments qs = new ToastArguments();

            Assert.AreEqual(0, qs.Count);

            qs.Add("name", "Andrew");

            Assert.AreEqual(1, qs.Count);

            qs.Add("age", "22");

            Assert.AreEqual(2, qs.Count);

            qs.Remove("age");

            Assert.AreEqual(1, qs.Count);

            qs.Remove("name");

            Assert.AreEqual(0, qs.Count);
        }
        public void TestAddExceptions_NullName()
        {
            ToastArguments query = new ToastArguments();

            try
            {
                query.Add(null, "value");
            }
            catch (ArgumentNullException)
            {
                return;
            }

            Assert.Fail("Adding null name shouldn't be allowed.");
        }
        public void TestStronglyTyped()
        {
            ToastArguments args = new ToastArguments()
                                  .Add("isAdult", true)
                                  .Add("isPremium", false)
                                  .Add("age", 22)
                                  .Add("level", 0)
                                  .Add("gpa", 3.97)
                                  .Add("percent", 97.3f);

#if !WINRT
            args.Add("activationKind", ToastActivationType.Background);
#endif

            AssertEqual(
                new ToastArguments()
            {
                { "isAdult", "1" },
                { "isPremium", "0" },
                { "age", "22" },
                { "level", "0" },
                { "gpa", "3.97" },
                { "percent", "97.3" },
#if !WINRT
                { "activationKind", "1" }
#endif
            }, args);

            Assert.AreEqual(true, args.GetBool("isAdult"));
            Assert.AreEqual("1", args.Get("isAdult"));

            Assert.AreEqual(false, args.GetBool("isPremium"));
            Assert.AreEqual("0", args.Get("isPremium"));

            Assert.AreEqual(22, args.GetInt("age"));
            Assert.AreEqual(22d, args.GetDouble("age"));
            Assert.AreEqual(22f, args.GetFloat("age"));
            Assert.AreEqual("22", args.Get("age"));

            Assert.AreEqual(0, args.GetInt("level"));

            Assert.AreEqual(3.97d, args.GetDouble("gpa"));

            Assert.AreEqual(97.3f, args.GetFloat("percent"));

#if !WINRT
            Assert.AreEqual(ToastActivationType.Background, args.GetEnum <ToastActivationType>("activationKind"));

            if (args.TryGetValue("activationKind", out ToastActivationType activationType))
            {
                Assert.AreEqual(ToastActivationType.Background, activationType);
            }
            else
            {
                Assert.Fail("TryGetValue as enum failed");
            }

            // Trying to get enum that isn't an enum should return false
            Assert.IsFalse(args.TryGetValue("percent", out activationType));
#endif

            // After serializing and deserializing, the same should work
            args = ToastArguments.Parse(args.ToString());

            Assert.AreEqual(true, args.GetBool("isAdult"));
            Assert.AreEqual("1", args.Get("isAdult"));

            Assert.AreEqual(false, args.GetBool("isPremium"));
            Assert.AreEqual("0", args.Get("isPremium"));

            Assert.AreEqual(22, args.GetInt("age"));
            Assert.AreEqual(22d, args.GetDouble("age"));
            Assert.AreEqual(22f, args.GetFloat("age"));
            Assert.AreEqual("22", args.Get("age"));

            Assert.AreEqual(0, args.GetInt("level"));

            Assert.AreEqual(3.97d, args.GetDouble("gpa"));

            Assert.AreEqual(97.3f, args.GetFloat("percent"));

#if !WINRT
            Assert.AreEqual(ToastActivationType.Background, args.GetEnum <ToastActivationType>("activationKind"));

            if (args.TryGetValue("activationKind", out activationType))
            {
                Assert.AreEqual(ToastActivationType.Background, activationType);
            }
            else
            {
                Assert.Fail("TryGetValue as enum failed");
            }

            // Trying to get enum that isn't an enum should return false
            Assert.IsFalse(args.TryGetValue("percent", out activationType));
#endif
        }