Test.ThatValuesParses.ThatStringGetTokenValueWorks C# (CSharp) Méthode

ThatStringGetTokenValueWorks() private méthode

private ThatStringGetTokenValueWorks ( ) : void
Résultat void
        public void ThatStringGetTokenValueWorks()
        {
            Action<string> expectFailure = str =>
                {
                    bool caught = false;
                    try
                    {
                        DynamicJson.Utilities.GetStringValueFromToken(str);
                    }
                    catch (InvalidOperationException)
                    {
                        caught = true;
                        // swallow since this is what we want
                    }
                    Assert.IsTrue(caught, "exception not caught");
                };

            expectFailure(null);
            expectFailure("");
            expectFailure("oeu");
            expectFailure("\"");
            expectFailure("u");

            var tries = new[] {
                "thaoeu",
                "is",
                "just",
                "\u1234",
                "some testing",
                "aoeu \u4321 \u4543 that is to be happening"
            };

            Assert.IsTrue(tries
                .Select(str => new
                {
                    Orig = str,
                    Extr = DynamicJson.Utilities.GetStringValueFromToken("\"" + str + "\"")
                })
                .All(item => item.Extr == item.Orig));

        }