public async Task ProducesProperZipFileForSingleFile() { var container = CreateContainer( c => { c.RegisterFake <IClipboardInjectionService>(); }); var fakeClipboardInjectionService = container.Resolve <IClipboardInjectionService>(); var action = container.Resolve <IZipFilesAction>(); var file = Path.GetTempFileName(); File.WriteAllText(file, "file"); var fakeDataSourceService = Substitute.For <IDataSourceService>(); var fileData = new ClipboardFileData(fakeDataSourceService) { FullPath = file, FileName = Path.GetFileName(file) }; var package = new ClipboardDataPackage(); package.AddData(fileData); string zipPath = null; fakeClipboardInjectionService .When(x => x.InjectFiles(Arg.Any <string[]>())) .Do( parameters => { var files = (string[])parameters[0]; zipPath = files[0]; }); await action.PerformAsync(package); Assert.IsNotNull(zipPath); using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Read)) { var entries = archive.Entries; Assert.AreEqual(1, entries.Count); Assert.AreEqual( 1, entries .Count(x => x.FullName == Path.GetFileName(file))); } }
public async Task ProducesProperZipFileForSingleFile() { ExcludeFakeFor <IFileManager>(); var file = Path.GetTempFileName(); File.WriteAllText(file, "file"); var fileData = new ClipboardFileData() { FullPath = file, FileName = Path.GetFileName(file) }; var package = CreateEmptyDataPackage(); package.AddData(fileData); string zipPath = null; Container.Resolve <IClipboardInjectionService>() .When(x => x.InjectFilesAsync(Arg.Any <string[]>())) .Do( parameters => { var files = (string[])parameters[0]; zipPath = files[0]; }); await SystemUnderTest.PerformAsync(package); Assert.IsNotNull(zipPath); using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Read)) { var entries = archive.Entries; Assert.AreEqual(1, entries.Count); Assert.AreEqual( 1, entries .Count(x => x.FullName == Path.GetFileName(file))); } }
public async Task ProducesProperZipFileForSingleFile() { var container = CreateContainer( c => { c.RegisterFake<IClipboardInjectionService>(); }); var fakeClipboardInjectionService = container.Resolve<IClipboardInjectionService>(); var action = container.Resolve<IZipFilesAction>(); var file = Path.GetTempFileName(); File.WriteAllText(file, "file"); var fakeDataSourceService = Substitute.For<IDataSourceService>(); var fileData = new ClipboardFileData(fakeDataSourceService) { FullPath = file, FileName = Path.GetFileName(file) }; var package = new ClipboardDataPackage(); package.AddData(fileData); string zipPath = null; fakeClipboardInjectionService .When(x => x.InjectFiles(Arg.Any<string[]>())) .Do( parameters => { var files = (string[]) parameters[0]; zipPath = files[0]; }); await action.PerformAsync(package); Assert.IsNotNull(zipPath); using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Read)) { var entries = archive.Entries; Assert.AreEqual(1, entries.Count); Assert.AreEqual( 1, entries .Count(x => x.FullName == Path.GetFileName(file))); } }