Beispiel #1
0
    public void TODO_Utilities_CanCompareJsonEnumProperty_WithoutAllocatingGCMemory()
    {
        var json = @"
            {
                ""first"" : true,
                ""second"" : [ 1, 2, 3.00 ],
                ""third"" : 1,
                ""fourth"" : ""BB""
            }
        ";

        var kProfileRegion = "Utilities_CanCompareJsonEnumProperty_WithoutAllocatingGCMemory";
        var kThird         = "third";
        var kFourth        = "fourth";
        var kTest          = (Enum)TestEnum.BB;

        Assert.That(() =>
        {
            Profiler.BeginSample(kProfileRegion);
            var parser = new JsonParser(json);
            parser.NavigateToProperty(kThird);
            parser.CurrentPropertyHasValueEqualTo(kTest);

            parser.Reset();
            parser.NavigateToProperty(kFourth);
            parser.CurrentPropertyHasValueEqualTo(kTest);

            Profiler.EndSample();
        }, ConstraintExtensions.AllocatingGCMemory(Is.Not));
    }
Beispiel #2
0
    [Retry(2)] // Warm up JIT
    public void Utilities_CanCompareJsonStringProperty_WithoutAllocatingGCMemory_EvenIfStringContainsEscapeSequences()
    {
        var json = @"
            {
                ""first"" : true,
                ""second"" : [ 1, 2, 3.00 ],
                ""third"" : ""te\""st"",
                ""fourth"" : ""other""
            }
        ";

        var kProfileRegion = "Utilities_CanCompareJsonStringProperty_WithoutAllocatingGCMemory";
        var kThird         = "third";
        var kTest          = "te\"st";

        Assert.That(() =>
        {
            Profiler.BeginSample(kProfileRegion);
            var parser = new JsonParser(json);
            parser.NavigateToProperty(kThird);
            parser.CurrentPropertyHasValueEqualTo(kTest);
            Profiler.EndSample();
        }, ConstraintExtensions.AllocatingGCMemory(Is.Not));
    }