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);
            }
Пример #2
0
 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");
 }
Пример #3
0
        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());
        }
Пример #4
0
        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"));
        }
Пример #5
0
        public void GivenADirectoryWithAFile()
        {
            _fs  = new DotNetFileSystem();
            _dir = new DotNetDirectory(DirectoryName.GetDirectoryName("bob"));
            var file = _dir.GetChildFile("test.txt");

            _fs.CreateDirectory(_dir);
            _fs.CreateFile(file);
        }
Пример #6
0
 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);
     });
 }
Пример #7
0
        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");
        }
Пример #8
0
        public void Open_Path_Throws_FileNotFoundException()
        {
            IFileSystem target = new DotNetFileSystem();

            Assert.Throws <FileNotFoundException>(
                () =>
            {
                using (var stream = target.Open("existing1.txt")) { }
            });
        }
Пример #9
0
        public void ReadUtf8Text_Read_String_From_Path()
        {
            IFileSystem target = new DotNetFileSystem();

            Assert.Throws <FileNotFoundException>(
                () =>
            {
                target.ReadUtf8Text("existing2.txt");
            });
        }
Пример #10
0
        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");
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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");
        }
Пример #14
0
        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));
        }
Пример #15
0
        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);
        }
Пример #16
0
        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);
        }
Пример #17
0
 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();
 }
Пример #19
0
 public override void Context()
 {
     FileSystem = new DotNetFileSystem();
 }
Пример #20
0
 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");
 }
Пример #21
0
        public void Implements_IFileSystem_Interface()
        {
            var target = new DotNetFileSystem();

            Assert.True(target is IFileSystem);
        }
Пример #22
0
 public void We_Write_a_file()
 {
     fs = new DotNetFileSystem();
     fs.Write(filePath, contents);
 }