public void DirectoryExistsTest() { var dir = @"z:\temp"; var file = new FileEmu(); Assert.IsFalse(file.DirectoryExists(dir)); file.CreateDirectory(dir); Assert.IsTrue(file.DirectoryExists(dir)); }
public void DeleteTest() { var name = @"z:\temp\aaa.txt"; var file = new FileEmu(); file.AddFile(name, "あいうえお", Encoding.GetEncoding("shift-jis")); Assert.IsTrue(file.Exists(name)); file.Delete(name); Assert.IsFalse(file.Exists(name)); }
public void DownloadDataTest() { var path = @"z:\temp\aaa.txt"; var text = "aaaa"; var encoding = Encoding.UTF8; var file = new FileEmu(); var client = new FtpClientMock(); client.FileBase = file; client.Host = "xxxx.xxx.xxx"; client.AddFile("web/test", "aaa.txt", text, encoding); client.DownloadFile("web/test", Path.GetFileName(path), Path.GetDirectoryName(path)); Assert.AreEqual(text, file.ReadAllText(path, encoding)); }
public void SaveLoad() { var file = new FileEmu(); var filename = "a.xml"; { var settei = new Settei(); settei.FileBase = file; settei.FileName = filename; settei.変更されたら保存 = true; settei.Set("aaa", 10); } { var settei = new Settei(filename, file); Assert.AreEqual(10, settei.Get<int>("aaa")); } }
public void ReadTest() { var file = new FileEmu(); file.AddFile("aaa.xml", _xml_sample, Encoding.UTF8); using (var stream = file.OpenRead("aaa.xml")) { var dict = Settei.Read(stream); Assert.AreEqual( @"<?xml version=""1.0""?> <int>10</int>", dict["aaa"].Replace("\n", "\r\n")); Assert.AreEqual( @"<?xml version=""1.0""?> <int>20</int>", dict["bbb"].Replace("\n", "\r\n")); } }
public void GetFilesTest() { var file = new FileEmu(); file.AddFile(@"z:\temp\aaa.txt", "", Encoding.UTF8); file.AddFile(@"z:\temp\bbb.TXT", "", Encoding.UTF8); file.AddFile(@"z:\temp\ccc.txt", "", Encoding.UTF8); file.AddFile(@"z:\temp\AAA.exe", "", Encoding.UTF8); file.AddFile(@"z:\temp\test\AAA.txt", "", Encoding.UTF8); var list = file.GetFiles(@"z:\temp", filename => { return Regex.IsMatch(filename, @"\.txt$", RegexOptions.IgnoreCase); }).ToList(); Assert.AreEqual(3, list.Count); Assert.AreEqual(@"z:\temp\aaa.txt", list[0]); Assert.AreEqual(@"z:\temp\bbb.TXT", list[1]); Assert.AreEqual(@"z:\temp\ccc.txt", list[2]); }
public void Test1() { var settei = new Settei(); var file = new FileEmu(); settei.FileBase = file; settei.FileName = "aaa.xml"; settei.Set("aaa", 10); Assert.AreEqual(10, settei.Get<int>("aaa")); }
public void 存在しないキー() { var settei = new Settei(); var file = new FileEmu(); settei.FileBase = file; settei.FileName = "aaa.xml"; settei.Get<int>("aaa"); }
public void オブジェクトのセーブ() { var settei = new Settei(); var file = new FileEmu(); settei.FileBase = file; settei.FileName = "aaa.xml"; var obj = new Test4648(); obj.Value = 11; settei.Set("aaa", obj); Assert.AreEqual(11, (settei.Get<Test4648>("aaa")).Value); }
public void XMLを取得() { var settei = new Settei(); var file = new FileEmu(); settei.FileBase = file; settei.FileName = "aaa.xml"; settei.Set("aaa", 10); settei.Set("bbb", 20); string xml = settei.GetXml(); Assert.IsTrue(_xml_sample == xml); }
public void WriteAllBytesTest() { var path = @"z:\temp\aaa.txt"; var text = "あいうえお"; var encoding = Encoding.GetEncoding("shift-jis"); var file = new FileEmu(); file.WriteAllBytes(path, encoding.GetBytes(text)); Assert.AreEqual(text, file.ReadAllText(path, encoding)); }
public void OpenWriteTest() { var path = @"z:\temp\aaa.txt"; var text = "あいうえお"; var file = new FileEmu(); using (Stream stream = file.OpenWrite(path)) { byte[] data = Encoding.GetEncoding("shift-jis").GetBytes(text); stream.Write(data, 0, data.Length); } Assert.AreEqual(text, file.ReadAllText(path, Encoding.GetEncoding("shift-jis"))); }
public void ReadAllBytesTest() { var path = @"z:\temp\aaa.txt"; var text = "あいうえお"; var encoding = Encoding.GetEncoding("shift-jis"); var file = new FileEmu(); file.AddFile(path, text, encoding); byte[] data = file.ReadAllBytes(path); Assert.AreEqual(text, encoding.GetString(data)); }
public void 例外テスト_例外テーブル() { var file = new FileEmu(); file.AddException("Exists", new ApplicationException()); file.Exists("aaa.txt"); }
public void 例外テスト() { var file = new FileEmu(); file.Exception = new ApplicationException(); file.Exists("aaa.txt"); }
public void ファイル長_存在しないファイル() { var file = new FileEmu(); file.GetLength("bbb.txt"); }
public void ファイル長_SetLength() { var path = @"z:\temp\aaa.txt"; var text = "aaa"; var encoding = Encoding.GetEncoding("shift-jis"); var file = new FileEmu(); file.AddFile(path, text, encoding); Assert.AreEqual(3, file.GetLength(path)); file.SetLength(path, 10); Assert.AreEqual(10, file.GetLength(path)); }
public void UploadFileTest() { var path = @"z:\temp\aaa.txt"; var text = "aaaa"; var encoding = Encoding.UTF8; var file = new FileEmu(); file.AddFile(path, text, Encoding.UTF8); var client = new FtpClientMock(); client.FileBase = file; client.Host = "xxxx.xxx.xxx"; client.UploadFile(path, "web/test/"); Assert.AreEqual(text, encoding.GetString(client._dict[new Uri("ftp://xxxx.xxx.xxx/web/test/aaa.txt")])); }
public void OpenReadTest() { var path = @"z:\temp\aaa.txt"; var text = "あいうえお"; var file = new FileEmu(); file.AddFile(path, text, Encoding.GetEncoding("shift-jis")); using (Stream stream = file.OpenRead(path)) { byte[] data = stream.ReadToEnd(); Assert.AreEqual(text, Encoding.GetEncoding("shift-jis").GetString(data)); } }
public void Test1() { var file = new FileEmu(); Assert.IsFalse(file.Exists("aaa.txt")); file.AddFile("aaa.txt", "あいうえお", Encoding.GetEncoding("shift-jis")); Assert.IsTrue(file.Exists("aaa.txt")); Assert.AreEqual("あいうえお", file.ReadAllText("aaa.txt", Encoding.GetEncoding("shift-jis"))); file.WriteAllText("aaa.txt", "かきくけこ", Encoding.GetEncoding("shift-jis")); Assert.AreEqual("かきくけこ", file.ReadAllText("aaa.txt", Encoding.GetEncoding("shift-jis"))); }