예제 #1
1
        public void Exists()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"dir\foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.IsFalse(fs.GetFileInfo("unknown.txt").Exists);
            Assert.IsTrue(fs.GetFileInfo(@"dir\foo.txt").Exists);
            Assert.IsFalse(fs.GetFileInfo(@"dir").Exists);
        }
예제 #2
0
        public void Equals()
        {
            CDBuilder builder = new CDBuilder();
            CDReader  fs      = new CDReader(builder.Build(), false);

            Assert.AreEqual(fs.GetFileInfo("foo.txt"), fs.GetFileInfo("foo.txt"));
        }
예제 #3
0
        public void Equals()
        {
            CDBuilder builder = new CDBuilder();
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.AreEqual(fs.GetFileInfo("foo.txt"), fs.GetFileInfo("foo.txt"));
        }
예제 #4
0
        public void CreationTimeUtc()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile(@"foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.GreaterOrEqual(DateTime.UtcNow, fs.GetFileInfo("foo.txt").CreationTimeUtc);
            Assert.LessOrEqual(DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(10)), fs.GetFileInfo("foo.txt").CreationTimeUtc);
        }
예제 #5
0
        public void Name()
        {
            CDBuilder builder = new CDBuilder();
            CDReader  fs      = new CDReader(builder.Build(), false);

            Assert.AreEqual("foo.txt", fs.GetFileInfo("foo.txt").Name);
            Assert.AreEqual("foo.txt", fs.GetFileInfo(@"path\foo.txt").Name);
            Assert.AreEqual("foo.txt", fs.GetFileInfo(@"\foo.txt").Name);
        }
예제 #6
0
        public void Exists()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile(@"dir\foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.IsFalse(fs.GetFileInfo("unknown.txt").Exists);
            Assert.IsTrue(fs.GetFileInfo(@"dir\foo.txt").Exists);
            Assert.IsFalse(fs.GetFileInfo(@"dir").Exists);
        }
예제 #7
0
        public void CreationTimeUtc()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.GreaterOrEqual(DateTime.UtcNow, fs.GetFileInfo("foo.txt").CreationTimeUtc);
            Assert.LessOrEqual(DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(10)), fs.GetFileInfo("foo.txt").CreationTimeUtc);
        }
예제 #8
0
 public void FileInfo()
 {
     CDBuilder builder = new CDBuilder();
     CDReader fs = new CDReader(builder.Build(), false);
     DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\SOMEFILE.TXT");
     Assert.IsNotNull(fi);
 }
예제 #9
0
        public void Length()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"FILE.TXT", new byte[0]);
            builder.AddFile(@"FILE2.TXT", new byte[1]);
            builder.AddFile(@"FILE3.TXT", new byte[10032]);
            builder.AddFile(@"FILE3.TXT;2", new byte[132]);
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.AreEqual(0, fs.GetFileInfo("FILE.txt").Length);
            Assert.AreEqual(1, fs.GetFileInfo("FILE2.txt").Length);
            Assert.AreEqual(10032, fs.GetFileInfo("FILE3.txt;1").Length);
            Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt;2").Length);
            Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt").Length);
        }
        public void FileInfo()
        {
            CDBuilder    builder = new CDBuilder();
            CDReader     fs      = new CDReader(builder.Build(), false);
            DiscFileInfo fi      = fs.GetFileInfo(@"SOMEDIR\SOMEFILE.TXT");

            Assert.IsNotNull(fi);
        }
예제 #11
0
        public void Open_FileNotFound()
        {
            CDBuilder builder = new CDBuilder();
            CDReader  fs      = new CDReader(builder.Build(), false);

            DiscFileInfo di = fs.GetFileInfo("foo.txt");

            using (Stream s = di.Open(FileMode.Open)) { }
        }
예제 #12
0
        public void Attributes()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile("foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo fi = fs.GetFileInfo("foo.txt");

            // Check default attributes
            Assert.AreEqual(FileAttributes.ReadOnly, fi.Attributes);
        }
예제 #13
0
        public void Attributes()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile("foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo fi = fs.GetFileInfo("foo.txt");

            // Check default attributes
            Assert.AreEqual(FileAttributes.ReadOnly, fi.Attributes);
        }
예제 #14
0
        public void Parent()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"SOMEDIR\ADIR\FILE.TXT", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT");

            Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent);
            Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory);
        }
예제 #15
0
        public void Open_Read()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile("foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo di = fs.GetFileInfo("foo.txt");

            using (Stream s = di.Open(FileMode.Open, FileAccess.Read))
            {
                Assert.IsFalse(s.CanWrite);
                Assert.IsTrue(s.CanRead);

                Assert.AreEqual(1, s.ReadByte());
            }
        }
예제 #16
0
        public void Length()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile(@"FILE.TXT", new byte[0]);
            builder.AddFile(@"FILE2.TXT", new byte[1]);
            builder.AddFile(@"FILE3.TXT", new byte[10032]);
            builder.AddFile(@"FILE3.TXT;2", new byte[132]);
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.AreEqual(0, fs.GetFileInfo("FILE.txt").Length);
            Assert.AreEqual(1, fs.GetFileInfo("FILE2.txt").Length);
            Assert.AreEqual(10032, fs.GetFileInfo("FILE3.txt;1").Length);
            Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt;2").Length);
            Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt").Length);
        }
예제 #17
0
        public void Name()
        {
            CDBuilder builder = new CDBuilder();
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.AreEqual("foo.txt", fs.GetFileInfo("foo.txt").Name);
            Assert.AreEqual("foo.txt", fs.GetFileInfo(@"path\foo.txt").Name);
            Assert.AreEqual("foo.txt", fs.GetFileInfo(@"\foo.txt").Name);
        }
예제 #18
0
        public void Open_FileNotFound()
        {
            CDBuilder builder = new CDBuilder();
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo di = fs.GetFileInfo("foo.txt");
            using (Stream s = di.Open(FileMode.Open)) { }
        }
예제 #19
0
        public void Open_Read()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile("foo.txt", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo di = fs.GetFileInfo("foo.txt");
            using (Stream s = di.Open(FileMode.Open, FileAccess.Read))
            {
                Assert.IsFalse(s.CanWrite);
                Assert.IsTrue(s.CanRead);

                Assert.AreEqual(1, s.ReadByte());
            }
        }
예제 #20
0
        public void Parent()
        {
            CDBuilder builder = new CDBuilder();
            builder.AddFile(@"SOMEDIR\ADIR\FILE.TXT", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT");
            Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent);
            Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory);
        }