/// <summary> /// Deep load all UserGrp children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.UserGrpProvider.GetPaged(tm, 0, 10, out count); DataRepository.UserGrpProvider.DeepLoading += new EntityProviderBaseCore <UserGrp, UserGrpKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.UserGrpProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("UserGrp instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.UserGrpProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Update the Typed UserGrp Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, UserGrp mock) { mock.Name = TestUtility.Instance.RandomString(24, false);; mock.Descript = TestUtility.Instance.RandomString(49, false);; mock.MenuPer = TestUtility.Instance.RandomString(2, false);; mock.Rpright = TestUtility.Instance.RandomString(2, false);; mock.Status = TestUtility.Instance.RandomBoolean(); }
///<summary> /// Update the Typed UserGrp Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, UserGrp mock) { UserGrpTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
/// <summary> /// Check the foreign key dal methods. /// </summary> private void Step_10_FK_Generated() { using (TransactionManager tm = CreateTransaction()) { UserGrp entity = CreateMockInstance(tm); bool result = DataRepository.UserGrpProvider.Insert(tm, entity); Assert.IsTrue(result, "Could Not Test FK, Insert Failed"); } }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); UserGrp entity = mock.Copy() as UserGrp; entity = (UserGrp)mock.Clone(); Assert.IsTrue(UserGrp.ValueEquals(entity, mock), "Clone is not working"); } }
///<summary> /// Returns a Typed UserGrp Entity with mock values. ///</summary> static public UserGrp CreateMockInstance(TransactionManager tm) { // get the default mock instance UserGrp mock = UserGrpTest.CreateMockInstance_Generated(tm); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); // return the modified object return(mock); }
/// <summary> /// Serialize the mock UserGrp entity into a temporary file. /// </summary> private void Step_06_SerializeEntity_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_UserGrp.xml"); EntityHelper.SerializeXml(mock, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found"); System.Console.WriteLine("mock correctly serialized to a temporary file."); } }
/// <summary> /// Inserts a mock UserGrp entity into the database. /// </summary> private void Step_01_Insert_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); Assert.IsTrue(DataRepository.UserGrpProvider.Insert(tm, mock), "Insert failed"); System.Console.WriteLine("DataRepository.UserGrpProvider.Insert(mock):"); System.Console.WriteLine(mock); //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
/// <summary> /// Serialize a UserGrp collection into a temporary file. /// </summary> private void Step_08_SerializeCollection_Generated() { using (TransactionManager tm = CreateTransaction()) { string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_UserGrpCollection.xml"); mock = CreateMockInstance(tm); TList <UserGrp> mockCollection = new TList <UserGrp>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<UserGrp> correctly serialized to a temporary file."); } }
///<summary> /// Returns a Typed UserGrp Entity with mock values. ///</summary> static public UserGrp CreateMockInstance_Generated(TransactionManager tm) { UserGrp mock = new UserGrp(); mock.Id = TestUtility.Instance.RandomString(2, false);; mock.Name = TestUtility.Instance.RandomString(24, false);; mock.Descript = TestUtility.Instance.RandomString(49, false);; mock.MenuPer = TestUtility.Instance.RandomString(2, false);; mock.Rpright = TestUtility.Instance.RandomString(2, false);; mock.Status = TestUtility.Instance.RandomBoolean(); // create a temporary collection and add the item to it TList <UserGrp> tempMockCollection = new TList <UserGrp>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((UserGrp)mock); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance UserGrp mock = CreateMockInstance(tm); bool result = DataRepository.UserGrpProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); UserGrpQuery query = new UserGrpQuery(); query.AppendEquals(UserGrpColumn.Id, mock.Id.ToString()); if (mock.Name != null) { query.AppendEquals(UserGrpColumn.Name, mock.Name.ToString()); } if (mock.Descript != null) { query.AppendEquals(UserGrpColumn.Descript, mock.Descript.ToString()); } if (mock.MenuPer != null) { query.AppendEquals(UserGrpColumn.MenuPer, mock.MenuPer.ToString()); } if (mock.Rpright != null) { query.AppendEquals(UserGrpColumn.Rpright, mock.Rpright.ToString()); } if (mock.Status != null) { query.AppendEquals(UserGrpColumn.Status, mock.Status.ToString()); } TList <UserGrp> results = DataRepository.UserGrpProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
/// <summary> /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.) /// </summary> /// <param name="mock">Object to be modified</param> static private void SetSpecialTestData(UserGrp mock) { //Code your changes to the data object here. }