public void Typical( [Frozen] MockFileSystem fs, IEnumerable <ModPath> modPaths, [Frozen] IModImporter <TestMod> importer, LoadOrderImporter <TestMod> sut) { foreach (var mp in modPaths) { fs.File.WriteAllText(mp.Path, string.Empty); } foreach (var modPath in modPaths) { importer.Import(modPath) .Returns(new TestMod(modPath.ModKey)); } sut.LoadOrderListingsProvider.Get() .Returns(modPaths.Select(x => new ModListing(x.ModKey, true))); var lo = sut.Import(); var expected = modPaths .Select(x => importer.Import(x)) .ToArray(); lo.Count.Should().Be(modPaths.Count()); lo.Select(x => x.Value.Mod) .Should().Equal(expected); }
public void EntryDoesNotExist() { var dataFolder = "C:/DataFolder"; var modPaths = new ModKey[] { TestConstants.MasterModKey, TestConstants.MasterModKey2, TestConstants.MasterModKey3, } .Select(x => ModPath.FromPath(Path.Combine(dataFolder, x.FileName))) .ToArray(); var fs = new MockFileSystem( modPaths .Skip(1) .ToDictionary(x => (string)x.Path, x => new MockFileData(string.Empty))); var importer = Substitute.For <IModImporter <TestMod> >(); foreach (var modPath in modPaths) { importer.Import(modPath).Returns(new TestMod(modPath.ModKey)); } var lo = new LoadOrderImporter <TestMod>( fs, new DataDirectoryInjection(dataFolder), new LoadOrderListingsInjection(modPaths.Select(x => x.ModKey).ToArray()), importer) .Import(); lo.Count.Should().Be(3); lo.First().Value.Mod.Should().BeNull(); lo.First().Value.ModKey.Should().Be(TestConstants.MasterModKey); lo.Select(x => x.Value.Mod) .Skip(1) .Should().Equal( modPaths .Skip(1) .Select(x => importer.Import(x))); }