Пример #1
0
        public void ByteAssemblyFileToString()
        {
            var path = GeneratePath();
            var file = new ByteFile(path, Array.Empty <byte>());

            Assert.Equal(path, file.ToString());
        }
Пример #2
0
        public void FilePath()
        {
            var path = GeneratePath();
            var file = new ByteFile(path, Array.Empty <byte>());

            Assert.Equal(path, file.Path);
        }
Пример #3
0
        public void Contents()
        {
            var path     = GeneratePath();
            var contents = GenerateContents();

            var file = new ByteFile(path, GetBytes(contents));

            using (var stream = file.OpenRead())
                using (var reader = new StreamReader(stream))
                {
                    var result = reader.ReadToEnd();

                    Assert.Equal(contents, result);
                }
        }
Пример #4
0
        public static IEnumerable <object[]> FileInstances()
        {
            var path1 = GeneratePath();
            var path2 = GeneratePath();

            var data1 = new byte[] { 1, 2, 3 };
            var data2 = Array.Empty <byte>();

            var file = new ByteFile(GeneratePath(), new byte[] { 1, 2 });

            yield return(new object[] { file, file, true });

            yield return(new object[] { new ByteFile(path1, data1), new ByteFile(path1, data1), true });

            yield return(new object[] { new ByteFile(path1, data2), new ByteFile(path1, data1), false });

            yield return(new object[] { new ByteFile("path", data2), new ByteFile("path", data1), false });

            // Check case sensitivies
            yield return(new object[] { new ByteFile("path", data2), new ByteFile("path", data2), true });

            yield return(new object[] { new ByteFile("Path", data2), new ByteFile("path", data2), false });
        }
Пример #5
0
        public void OtherTypeEquality()
        {
            var file = new ByteFile(GeneratePath(), new byte[] { 1, 2 });

            Assert.False(file.Equals(new NoOpAssemblyFile()));
        }