public override void Context() { base.Context(); var fileToSetReadOnly = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "chocolateyInstall.ps1"); var fileSystem = new DotNetFileSystem(); fileSystem.ensure_file_attribute_set(fileToSetReadOnly, FileAttributes.ReadOnly); }
public override void Context() { FileSystem = new DotNetFileSystem(); ContextPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "infrastructure", "filesystem"); DestinationPath = Path.Combine(ContextPath, "context"); TheTestFile = Path.Combine(ContextPath, "Slipsum.txt"); TestDirectory = Path.Combine(DestinationPath, "TestDirectory"); }
public static void WriteIntrospectionToFile(this IServiceBus bus, string fileName) { IDiagnosticsProbe probe = bus.Probe(); var fs = new DotNetFileSystem(); fs.DeleteFile(fileName); fs.Write(fileName, probe.ToString()); }
public void We_Write_a_file() { fs = new DotNetFileSystem(); fs.Write(filePath, contents); var f = new DotNetFile(FileName.GetFileName(@".\temp.txt")); f.CopyTo(FileName.GetFileName(@".\copy.txt")); }
public void GivenADirectoryWithAFile() { _fs = new DotNetFileSystem(); _dir = new DotNetDirectory(DirectoryName.GetDirectoryName("bob")); var file = _dir.GetChildFile("test.txt"); _fs.CreateDirectory(_dir); _fs.CreateFile(file); }
public void when_upgrading_a_package_with_readonly_files() { TestUpgrade((conf) => { var path = Path.Combine(InstallContext.Instance.PackagesLocation, conf.PackageNames, "tools", "chocolateyInstall.ps1"); var fileSystem = new DotNetFileSystem(); fileSystem.ensure_file_attribute_set(path, FileAttributes.ReadOnly); }); }
public void Create_Path_Creates_New_File() { IFileSystem target = new DotNetFileSystem(); using (var stream = target.Create("new1.txt")) { } Assert.True(File.Exists("new1.txt")); using (var stream = target.Open("new1.txt")) { } File.Delete("new1.txt"); }
public void Open_Path_Throws_FileNotFoundException() { IFileSystem target = new DotNetFileSystem(); Assert.Throws <FileNotFoundException>( () => { using (var stream = target.Open("existing1.txt")) { } }); }
public void ReadUtf8Text_Read_String_From_Path() { IFileSystem target = new DotNetFileSystem(); Assert.Throws <FileNotFoundException>( () => { target.ReadUtf8Text("existing2.txt"); }); }
public void Overwrite_Files() { var conv = new DefaultNuConventions(); var fs = new DotNetFileSystem(conv); fs.Write(@".\temp.txt", "hi123"); Assert.AreEqual(fs.ReadToEnd(@".\temp.txt"), "hi123"); fs.Write(@".\temp.txt", "hii"); Assert.AreEqual(fs.ReadToEnd(@".\temp.txt"), "hii"); fs.DeleteFile(@".\temp.txt"); }
public void ReadUtf8Text_Read_String_From_Stream() { IFileSystem target = new DotNetFileSystem(); var expceted = "κόσμε"; string actual; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(expceted))) { actual = target.ReadUtf8Text(stream); } Assert.Equal(expceted, actual); }
public void ReadBinary_Read_All_Bytes_From_Stream() { IFileSystem target = new DotNetFileSystem(); var expceted = new byte[] { 0x12, 0x34, 0x56, 0x67 }; byte[] actual; using (var stream = new MemoryStream(expceted)) { actual = target.ReadBinary(stream); } Assert.Equal(expceted, actual); }
public void WriteUtf8Text_Write_String_To_Path() { IFileSystem target = new DotNetFileSystem(); var expceted = "κόσμε"; target.WriteUtf8Text("new2.txt", expceted); Assert.True(File.Exists("new2.txt")); var actual = target.ReadUtf8Text("new2.txt"); Assert.Equal(expceted, actual); File.Delete("new2.txt"); }
static InteractivePackageManager CreatePackageManager(FrameworkName targetFramework) { var rootPath = new DotNetFileSystem().GetTempDirectory("tests"); var localRepositoryDirectory = rootPath.Combine("NuGet", "package-cache"); try { Directory.Delete(localRepositoryDirectory, recursive: true); } catch (DirectoryNotFoundException) { } return(new InteractivePackageManager( targetFramework, localRepositoryDirectory)); }
public void WriteBinary_Write_All_Bytes_To_Stream() { IFileSystem target = new DotNetFileSystem(); var expceted = new byte[] { 0x12, 0x34, 0x56, 0x67 }; byte[] actual; using (var stream = new MemoryStream()) { target.WriteBinary(stream, expceted); actual = stream.ToArray(); } Assert.Equal(expceted, actual); }
public void WriteUtf8Text_Write_String_To_Stream() { IFileSystem target = new DotNetFileSystem(); var expceted = "κόσμε"; byte[] actual; using (var stream = new MemoryStream()) { target.WriteUtf8Text(stream, expceted); actual = stream.ToArray(); } var excpetedBytes = Encoding.UTF8.GetBytes(expceted); var actualBytesWithoutPreamble = actual.Skip(3).ToArray(); Assert.Equal(excpetedBytes, actualBytesWithoutPreamble); }
public override void Context() { FileSystem = new DotNetFileSystem(); Provider = new CryptoHashProvider(FileSystem); ContextDirectory = FileSystem.combine_paths(FileSystem.get_directory_name(FileSystem.get_current_assembly_path()), "context"); }
public override void Context() { FileSystem = new DotNetFileSystem(); }
public override void Context() { FileSystem = new DotNetFileSystem(); Provider = new CrytpoHashProvider(FileSystem, CryptoHashProviderType.Md5); ContextDirectory = FileSystem.combine_paths(FileSystem.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty)), "context"); }
public void Implements_IFileSystem_Interface() { var target = new DotNetFileSystem(); Assert.True(target is IFileSystem); }
public void We_Write_a_file() { fs = new DotNetFileSystem(); fs.Write(filePath, contents); }