public async Task Should_not_export_hash_report() { var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); var gameService = new Mock <IGameService>(); var modExport = new Mock <IModCollectionExporter>(); var hashExport = new Mock <IReportExportService>(); var messageBus = new Mock <IMessageBus>(); messageBus.Setup(p => p.PublishAsync(It.IsAny <IMessageBusEvent>())); messageBus.Setup(p => p.Publish(It.IsAny <IMessageBusEvent>())); DISetup.SetupContainer(); var service = new ModCollectionService(messageBus.Object, hashExport.Object, new Cache(), null, null, null, null, gameService.Object, modExport.Object, storageProvider.Object, mapper.Object); var result = await service.ExportHashReportAsync(null, "test"); result.Should().BeFalse(); result = await service.ExportHashReportAsync(new List <IMod>(), string.Empty); result.Should().BeFalse(); }
public async Task Should_export_hash_report() { var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); var gameService = new Mock <IGameService>(); gameService.Setup(s => s.GetSelected()).Returns(new Game() { Type = "no-items", UserDirectory = "C:\\fake", GameFolders = new List <string>() { "test" } }); var collections = new List <IModCollection>() { new ModCollection() { IsSelected = true, Mods = new List <string>() { "mod/fakemod.mod" }, Name = "test", Game = "no-items" } }; storageProvider.Setup(s => s.GetModCollections()).Returns(() => { return(collections); }); var modExport = new Mock <IModCollectionExporter>(); var hashExport = new Mock <IReportExportService>(); hashExport.Setup(p => p.ExportAsync(It.IsAny <IEnumerable <IHashReport> >(), It.IsAny <string>())).ReturnsAsync((IEnumerable <IHashReport> report, string path) => { if (report.Count() == 1 && report.FirstOrDefault().Reports.Count == 1 && report.FirstOrDefault().Reports.FirstOrDefault().File == "test\\test" && report.FirstOrDefault().Reports.FirstOrDefault().Hash == "2") { return(true); } return(false); }); var messageBus = new Mock <IMessageBus>(); messageBus.Setup(p => p.PublishAsync(It.IsAny <IMessageBusEvent>())); messageBus.Setup(p => p.Publish(It.IsAny <IMessageBusEvent>())); var reader = new Mock <IReader>(); reader.Setup(p => p.GetFileInfo(It.IsAny <string>(), It.IsAny <string>())).Returns(new FileInfo() { ContentSHA = "2" }); var modWriter = new Mock <IModWriter>(); modWriter.Setup(p => p.ModDirectoryExistsAsync(It.IsAny <ModWriterParameters>())).Returns((ModWriterParameters p) => { return(Task.FromResult(false)); }); DISetup.SetupContainer(); var service = new ModCollectionService(messageBus.Object, hashExport.Object, new Cache(), null, reader.Object, modWriter.Object, null, gameService.Object, modExport.Object, storageProvider.Object, mapper.Object); var result = await service.ExportHashReportAsync(new List <IMod>() { new Mod() { Name = "test", Files = new List <string>() { "test\\test" } } }, "test"); result.Should().BeTrue(); }