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); }
public void Equals() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(fs.GetFileInfo("foo.txt"), fs.GetFileInfo("foo.txt")); }
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); }
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); }
public void FileInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\SOMEFILE.TXT"); Assert.IsNotNull(fi); }
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 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)) { } }
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); }
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); }
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()); } }