Created
February 2, 2010 23:31
-
-
Save tucaz/293171 to your computer and use it in GitHub Desktop.
This file contains 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
[TestMethod] | |
public void CanSaveAndDeleteAFunctionButNotTheApplication() | |
{ | |
//Arrange | |
Application myApp = new Application() | |
{ | |
Description = "MyApp", | |
KeyName = "MyApp", | |
Name = "My App", | |
Url = "http://www.myapp.com" | |
}; | |
Function myFunc = new Function() | |
{ | |
Application = myApp, | |
Code = "MyFuncCode", | |
Description = "My Func Desc" | |
}; | |
//Act | |
//Create the function with and Application | |
_session.Save(myFunc); | |
int myNewFuncId = myFunc.Id; | |
_session.Flush(); | |
_session.Clear(); | |
//Retrieve the function and the Id of the application | |
var myOldFunc = _session.Load<Function>(myNewFuncId); | |
var myOldAppId = myOldFunc.Application.Id; | |
//Now deletes the Function | |
_session.Delete(myOldFunc); | |
_session.Flush(); | |
_session.Clear(); | |
//And tries to load the application to make sure that | |
//it was not deleted by cascade | |
var myOldApp = _session.Load<Application>(myOldAppId); | |
//The function must be null because I deleted it | |
var myReallyOldFunc = _session.Get<Function>(myNewFuncId); | |
//Assert | |
Assert.IsNotNull(myOldApp); | |
Assert.AreEqual<int>(myOldAppId, myOldApp.Id); | |
Assert.IsNull(myReallyOldFunc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment