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); }
public void Returns_all_definitions_and_added_definitions() { 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); service.AddToMap(new Definition() { Code = "a", Id = "14", Type = "14" }); var results = service.GetAll(); results.Count().Should().Be(defs.Count + 1); }
public void Returns_all_definitions() { 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); var results = service.GetAll(); results.Count().Should().Be(defs.Count); int match = 0; foreach (var item in defs) { if (results.Contains(item)) { match++; } } match.Should().Be(defs.Count); }