public void CreateFileTransactionally_Rollback() { if (Environment.OSVersion.Version.Major < 6) { Assert.Ignore("TxF not supported"); return; } string filePath = testFixturePath.CombineAssert("temp").Combine("temp2"); infosCreated.Add(filePath); // simply write something to to file. using (StreamWriter wr = File.CreateText(filePath)) wr.WriteLine("Hello"); using (var tx = new FileTransaction("Rollback tx")) { tx.Begin(); using (FileStream fs = tx.Open(filePath, FileMode.Truncate)) { byte[] str = new UTF8Encoding().GetBytes("Goodbye"); fs.Write(str, 0, str.Length); fs.Flush(); } tx.Rollback(); } Assert.That(File.ReadAllLines(filePath)[0], Is.EqualTo("Hello")); }