Ejemplo n.º 1
0
        public void JsonLoadDeserializedMigrationTest(FintoItemImportDefinition.Resources resource, int replaceMore, int notFoundCount)
        {
            var resourceManager = new ResourceLoader();
            var json            = resourceManager.GetDeserializedResource <List <VmServiceViewsJsonItem> >(new FintoItemImportDefinition {
                Resource = resource
            });

            Assert.NotNull(json);
            var ids = json.GroupBy(x => x.Id).ToDictionary(x => x.Key);

            var duplicated = ids.Where(x => x.Value.Count() > 1).Select(x => x.Key).ToList();

            duplicated.Count.Should().Be(0, "Duplicated keys: " + String.Join(", ", duplicated));

            var replaceList = json.Where(x => !string.IsNullOrEmpty(x.ReplacedBy)).GroupBy(x => x.ReplacedBy).Where(x => x.Count() > 1).Select(x => x.Key).ToList();

            replaceList.Count.Should().Be(replaceMore, "Replace more items by one key: " + String.Join(", ", replaceList));


            var replaceByIds = json.Where(x => !string.IsNullOrEmpty(x.ReplacedBy)).Select(x => x.ReplacedBy).Distinct().ToList();
            var notFound     = replaceByIds.Where(x => !ids.ContainsKey(x)).ToList();

            notFound.Count.Should().Be(notFoundCount, string.Join(", ", notFound));

            json.Count(x => !string.IsNullOrEmpty(x.ReplacedBy)).Should().BeGreaterOrEqualTo(replaceByIds.Count);
        }
Ejemplo n.º 2
0
        public void JsonLoadDeserializedTest(FintoItemImportDefinition.Resources resource, int expectedCountMain, int expectedCountAll, int replacedCount)
        {
            var resourceManager = new ResourceLoader();
            var json            = resourceManager.GetDeserializedResource <List <VmServiceViewsJsonItem> >(new FintoItemImportDefinition {
                Resource = resource
            });

            Assert.NotNull(json);
            json.Count(x => (x.BroaderURIs == null || x.BroaderURIs.Count == 0) && string.IsNullOrEmpty(x.ReplacedBy)).Should().Be(expectedCountMain);
//            FillChildren(json);
            var notReplaced = json.Count(x => string.IsNullOrEmpty(x.ReplacedBy));

            notReplaced.Should().Be(expectedCountAll);
            var replaced = json.Count(x => !string.IsNullOrEmpty(x.ReplacedBy));

            replaced.Should().Be(replacedCount);
            json.Count.Should().Be(replaced + notReplaced);

            //            File.WriteAllText($@"D:\{resource}_update.json", JsonConvert.SerializeObject(json));
        }
Ejemplo n.º 3
0
 public FintoTypeJsonCache(ResourceLoader resourceLoader, FintoItemImportDefinition.Resources resourceType)
 {
     this.resourceLoader = resourceLoader;
     this.resourceType   = resourceType;
 }