public void CanAppendAllText() { string f1 = GetTempPathName(); const string contents = "123"; using (TransactionScope scope1 = new TransactionScope()) { _target.AppendAllText(f1, contents); scope1.Complete(); } Assert.Equal(contents, File.ReadAllText(f1)); }
public void CanAppendAllText() { var f1 = GetTempPathName(); const string contents = "123"; using (var scope1 = new TransactionScope()) { _target.AppendAllText(f1, contents); scope1.Complete(); } File.ReadAllText(f1).Should().Be(contents); }
public void CanAppendText() { string f1 = _target.GetTempFileName(); const string contents = "123"; try { using (TransactionScope scope1 = new TransactionScope()) { _target.AppendAllText(f1, contents); scope1.Complete(); } File.ReadAllText(f1).ShouldBe(contents, "Incorrect value for ReadAllText."); } finally { File.Delete(f1); } }
public void CanAppendText() { var f1 = _target.GetTempFileName(); const string contents = "123"; try { using (var scope1 = new TransactionScope()) { _target.AppendAllText(f1, contents); scope1.Complete(); } Assert.AreEqual(contents, File.ReadAllText(f1)); } finally { File.Delete(f1); } }
public static void ExecuteOperation(IFileManager fileManager, FileOperations operation, object[] param) { if (operation == FileOperations.AppendAllText) { string path = param[0].ToString(); string contents = param[1].ToString(); fileManager.AppendAllText(path, contents); } else if (operation == FileOperations.Copy) { string sourceFileName = param[0].ToString(); string destFileName = param[1].ToString(); bool overwrite = (bool)param[2]; fileManager.Copy(sourceFileName, destFileName, overwrite); } else if (operation == FileOperations.CreateFile) { string pathToFile = param[0].ToString(); fileManager.CreateFile(pathToFile); } else if (operation == FileOperations.Delete) { string path = param[0].ToString(); fileManager.Delete(path); } else if (operation == FileOperations.Move) { string sourceFileName = param[0].ToString(); string destFileName = param[1].ToString(); fileManager.Move(sourceFileName, destFileName); } else if (operation == FileOperations.WriteAllText) { string path = param[0].ToString(); string contents = param[1].ToString(); fileManager.WriteAllText(path, contents); } }