public void One_Level_Nesting_Unescaped()
        {
            var         guids       = Enumerable.Range(0, 6).Select(x => Guid.NewGuid()).ToList();
            var         guidCounter = 0;
            Func <Guid> guidFactory = () => guids[guidCounter++];

            // nested blocks without property value escaping used in the conversion
            var innerJson = GetBlockListJson(null, _subContentGuid1, _subContentGuid2, _subSettingsGuid1);

            // get the json with the subFeatures as unescaped
            var json = GetBlockListJson(innerJson);

            var expected = ReplaceGuids(GetBlockListJson(innerJson), guids,
                                        _contentGuid1, _contentGuid2, _settingsGuid1,
                                        _subContentGuid1, _subContentGuid2, _subSettingsGuid1);

            var component = new BlockEditorComponent();
            var result    = component.ReplaceBlockListUdis(json, guidFactory);

            var expectedJson = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(expected, _serializerSettings), _serializerSettings);
            var resultJson   = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(result, _serializerSettings), _serializerSettings);

            Console.WriteLine(expectedJson);
            Console.WriteLine(resultJson);
            Assert.AreEqual(expectedJson, resultJson);
        }
        public void One_Level_Nesting_Escaped()
        {
            var guids = Enumerable.Range(0, 6).Select(x => Guid.NewGuid()).ToList();

            var         guidCounter = 0;
            Func <Guid> guidFactory = () => guids[guidCounter++];

            var innerJson = GetBlockListJson(null, _subContentGuid1, _subContentGuid2, _subSettingsGuid1);

            // we need to ensure the escaped json is consistent with how it will be re-escaped after parsing
            // and this is how to do that, the result will also include quotes around it.
            var innerJsonEscaped = JsonConvert.ToString(innerJson);

            // get the json with the subFeatures as escaped
            var json = GetBlockListJson(innerJsonEscaped);

            var component = new BlockEditorComponent();
            var result    = component.ReplaceBlockListUdis(json, guidFactory);

            // the expected result is that the subFeatures data is no longer escaped
            var expected = ReplaceGuids(GetBlockListJson(innerJson), guids,
                                        _contentGuid1, _contentGuid2, _settingsGuid1,
                                        _subContentGuid1, _subContentGuid2, _subSettingsGuid1);

            var expectedJson = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(expected, _serializerSettings), _serializerSettings);
            var resultJson   = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(result, _serializerSettings), _serializerSettings);

            Console.WriteLine(expectedJson);
            Console.WriteLine(resultJson);
            Assert.AreEqual(expectedJson, resultJson);
        }
        public void Cannot_Have_Null_Udi()
        {
            var component = new BlockEditorComponent();
            var json      = GetBlockListJson(null, string.Empty);

            Assert.Throws <FormatException>(() => component.ReplaceBlockListUdis(json));
        }
        public void No_Nesting()
        {
            var         guids       = Enumerable.Range(0, 3).Select(x => Guid.NewGuid()).ToList();
            var         guidCounter = 0;
            Func <Guid> guidFactory = () => guids[guidCounter++];

            var json = GetBlockListJson(null);

            var expected = ReplaceGuids(json, guids, _contentGuid1, _contentGuid2, _settingsGuid1);

            var component = new BlockEditorComponent();
            var result    = component.ReplaceBlockListUdis(json, guidFactory);

            var expectedJson = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(expected, _serializerSettings), _serializerSettings);
            var resultJson   = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(result, _serializerSettings), _serializerSettings);

            Console.WriteLine(expectedJson);
            Console.WriteLine(resultJson);
            Assert.AreEqual(expectedJson, resultJson);
        }