Example #1
0
        public void Returns_by_disk_file()
        {
            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 < 5 ? "file" : i.ToString(),
                    DiskFile = i < 5 ? "diskfile" : i.ToString(),
                    Id       = i.ToString(),
                    ModName  = i.ToString(),
                    Type     = i.ToString()
                });
            }
            var service = new IndexedDefinitions();

            service.InitMap(defs);
            var results = service.GetByDiskFile("diskfile");

            results.Count().Should().Be(defs.Where(s => s.DiskFile == "diskfile").Count());
            int match = 0;

            foreach (var item in defs.Where(s => s.DiskFile == "diskfile"))
            {
                if (results.Contains(item))
                {
                    match++;
                }
            }
            match.Should().Be(defs.Where(s => s.DiskFile == "diskfile").Count());
        }