Last active
August 29, 2015 14:10
-
-
Save adamralph/f373d68afc25c6265090 to your computer and use it in GitHub Desktop.
xBehave.net transaction rollback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Scenario] | |
public void MyScenario(..., SqlTransaction transaction) | |
{ | |
"Given..." | |
.f(() => ...); | |
... | |
"When..." | |
.f(c => | |
{ | |
// Appending .Using(c) will call Dispose() after all steps in the scenario have finished. | |
// There is no call to Commit(), so the transaction will be rolled back. | |
transaction = connection.BeginTransaction(IsolationLevel.Serializable).Using(c); | |
... // mutate the DB | |
}); | |
"And..." | |
.f(() => ...); // mutate the DB again | |
... | |
"Then..." | |
.f(() => ...); // assert DB state | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment