Exemple #1
0
        public void Deletes_specified_definition()
        {
            DISetup.SetupContainer();
            var defs = new List <IDefinition>();

            for (int i = 0; i < 10; i++)
            {
                defs.Add(new Definition()
                {
                    Code         = i.ToString(),
                    ContentSHA   = i.ToString(),
                    Dependencies = new List <string> {
                        i.ToString()
                    },
                    File    = i.ToString(),
                    Id      = i.ToString(),
                    ModName = i.ToString(),
                    Type    = i.ToString()
                });
            }
            var service = new IndexedDefinitions();

            service.InitMap(defs, true);
            service.Remove(defs.First());
            var result = service.GetAll();

            result.Count().Should().Be(defs.Count - 1);
            result.FirstOrDefault(p => p.Id == "0").Should().BeNull();
            var hierarchalResult = service.GetHierarchicalDefinitions();

            hierarchalResult.First().Children.Count.Should().Be(defs.Count - 1);
            hierarchalResult.First().Children.FirstOrDefault(p => p.Key.StartsWith("0")).Should().BeNull();
            service.GetByTypeAndId(defs.First().TypeAndId).Count().Should().Be(0);
        }
Exemple #2
0
        public void Returns_hierarchical_objects()
        {
            DISetup.SetupContainer();
            var defs = new List <IDefinition>();

            for (int i = 0; i < 10; i++)
            {
                defs.Add(new Definition()
                {
                    Code         = i.ToString(),
                    ContentSHA   = i.ToString(),
                    Dependencies = new List <string> {
                        i.ToString()
                    },
                    File    = i < 3 ? "file" : i.ToString(),
                    Id      = i.ToString(),
                    ModName = i.ToString(),
                    Type    = i > 3 && i < 6 ? "type" : i.ToString()
                });
            }
            var service = new IndexedDefinitions();

            service.InitMap(defs, true);
            var results = service.GetHierarchicalDefinitions();

            results.Count().Should().Be(1);
            results.First().Children.Count.Should().Be(10);
        }