public void CreateFileStreamWhenTransactionalFileSystemUnsupported() { TransactionalFile._operatingSystem = OperatingSystemExtensionsFixture.WindowsXP; using (var file = TransactionalFile.Create(_filename)) { file.Should().BeOfType <FileStream>(); } }
public void TransactionRollbackOnDispose() { using (var file = TransactionalFile.Create(_filename)) { file.Should().BeOfType <TransactionalFileStream>(); file.Write(_buffer, 0, _buffer.Length); } File.Exists(_filename).Should().BeFalse("Transaction should have been rolled back: file is found."); }
public void CreateFileStreamWhenNetworkPath() { var uncFilename = @"\\localhost\" + _filename.Replace(':', '$'); TransactionalFile._operatingSystem = OperatingSystemExtensionsFixture.Windows7; using (var file = TransactionalFile.Create(uncFilename)) { file.Should().BeOfType <FileStream>(); } }
public void TransactionCommitHasToBeExplicit() { using (var file = TransactionalFile.Create(_filename)) { file.Should().BeOfType <TransactionalFileStream>(); file.Write(_buffer, 0, _buffer.Length); ((TransactionalFileStream)file).Commit(); } File.Exists(_filename).Should().BeTrue("Transaction should have been committed: file is not found."); }
public void TransactionRollbackOnFinalize() { var file = TransactionalFile.Create(_filename); file.Should().BeOfType <TransactionalFileStream>(); file.Write(_buffer, 0, _buffer.Length); file = null; GC.Collect(); GC.WaitForPendingFinalizers(); File.Exists(_filename).Should().BeFalse("Transaction should have been rolled back: file is found."); }
public void CreateFileStreamWhenGivenAmbientTransactionAndTransactionalFileSystemSupported() { TransactionalFile._operatingSystem = OperatingSystemExtensionsFixture.Windows7; using (new TransactionScope()) { // grab kernel level transaction handle var dtcTransaction = TransactionInterop.GetDtcTransaction(Transaction.Current); var kernelTransaction = (IKernelTransaction)dtcTransaction; var file = TransactionalFile.Create(_filename, 1024, kernelTransaction); file.Should().BeOfType <FileStream>(); } }
public void TransactionRollbackWithAmbientTransaction() { using (new TransactionScope()) { var kernelTransaction = (IKernelTransaction)TransactionInterop.GetDtcTransaction(Transaction.Current); using (var file = TransactionalFile.Create(_filename, 1024, kernelTransaction)) { file.Should().BeOfType <FileStream>(); file.Write(_buffer, 0, _buffer.Length); } // this is the root scope and failing to cast a vote will abort the ambient transaction } File.Exists(_filename).Should().BeFalse(); }
public void TransactionCommitWithAmbientTransaction() { using (var scope = new TransactionScope()) { var kernelTransaction = (IKernelTransaction)TransactionInterop.GetDtcTransaction(Transaction.Current); using (var file = TransactionalFile.Create(_filename, 1024, kernelTransaction)) { file.Should().BeOfType <FileStream>(); file.Write(_buffer, 0, _buffer.Length); } // this is the root scope and it has to cast a vote scope.Complete(); } File.Exists(_filename).Should().BeTrue(); }