/// <summary> /// Deep load all AtrCode children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.AtrCodeProvider.GetPaged(tm, 0, 10, out count); DataRepository.AtrCodeProvider.DeepLoading += new EntityProviderBaseCore <AtrCode, AtrCodeKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.AtrCodeProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("AtrCode instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.AtrCodeProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Returns a Typed AtrCode Entity with mock values. ///</summary> static public AtrCode CreateMockInstance_Generated(TransactionManager tm) { AtrCode mock = new AtrCode(); mock.TransCode = TestUtility.Instance.RandomString(2, false);; mock.TransName = TestUtility.Instance.RandomString(99, false);; mock.Status = TestUtility.Instance.RandomBoolean(); mock.DbAccid = TestUtility.Instance.RandomString(9, false);; mock.CrAccid = TestUtility.Instance.RandomString(9, false);; mock.Accid1 = TestUtility.Instance.RandomString(9, false);; mock.Accid2 = TestUtility.Instance.RandomString(9, false);; mock.Accid3 = TestUtility.Instance.RandomString(9, false);; mock.Pcommand = TestUtility.Instance.RandomString(49, false);; mock.Form = TestUtility.Instance.RandomString(9, false);; mock.Voucher = TestUtility.Instance.RandomString(9, false);; mock.Fvoucher = TestUtility.Instance.RandomString(9, false);; mock.Nov = (decimal)TestUtility.Instance.RandomShort(); mock.TrType = TestUtility.Instance.RandomString(2, false);; // create a temporary collection and add the item to it TList <AtrCode> tempMockCollection = new TList <AtrCode>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((AtrCode)mock); }
///<summary> /// Update the Typed AtrCode Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, AtrCode mock) { AtrCodeTest.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()) { AtrCode entity = CreateMockInstance(tm); bool result = DataRepository.AtrCodeProvider.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); AtrCode entity = mock.Copy() as AtrCode; entity = (AtrCode)mock.Clone(); Assert.IsTrue(AtrCode.ValueEquals(entity, mock), "Clone is not working"); } }
///<summary> /// Returns a Typed AtrCode Entity with mock values. ///</summary> static public AtrCode CreateMockInstance(TransactionManager tm) { // get the default mock instance AtrCode mock = AtrCodeTest.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 AtrCode 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_AtrCode.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 AtrCode entity into the database. /// </summary> private void Step_01_Insert_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); Assert.IsTrue(DataRepository.AtrCodeProvider.Insert(tm, mock), "Insert failed"); System.Console.WriteLine("DataRepository.AtrCodeProvider.Insert(mock):"); System.Console.WriteLine(mock); //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Update the Typed AtrCode Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, AtrCode mock) { mock.TransName = TestUtility.Instance.RandomString(99, false);; mock.Status = TestUtility.Instance.RandomBoolean(); mock.DbAccid = TestUtility.Instance.RandomString(9, false);; mock.CrAccid = TestUtility.Instance.RandomString(9, false);; mock.Accid1 = TestUtility.Instance.RandomString(9, false);; mock.Accid2 = TestUtility.Instance.RandomString(9, false);; mock.Accid3 = TestUtility.Instance.RandomString(9, false);; mock.Pcommand = TestUtility.Instance.RandomString(49, false);; mock.Form = TestUtility.Instance.RandomString(9, false);; mock.Voucher = TestUtility.Instance.RandomString(9, false);; mock.Fvoucher = TestUtility.Instance.RandomString(9, false);; mock.Nov = (decimal)TestUtility.Instance.RandomShort(); mock.TrType = TestUtility.Instance.RandomString(2, false);; }
/// <summary> /// Serialize a AtrCode 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_AtrCodeCollection.xml"); mock = CreateMockInstance(tm); TList <AtrCode> mockCollection = new TList <AtrCode>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<AtrCode> correctly serialized to a temporary file."); } }
/// <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(AtrCode mock) { //Code your changes to the data object here. }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance AtrCode mock = CreateMockInstance(tm); bool result = DataRepository.AtrCodeProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); AtrCodeQuery query = new AtrCodeQuery(); query.AppendEquals(AtrCodeColumn.TransCode, mock.TransCode.ToString()); if (mock.TransName != null) { query.AppendEquals(AtrCodeColumn.TransName, mock.TransName.ToString()); } if (mock.Status != null) { query.AppendEquals(AtrCodeColumn.Status, mock.Status.ToString()); } if (mock.DbAccid != null) { query.AppendEquals(AtrCodeColumn.DbAccid, mock.DbAccid.ToString()); } if (mock.CrAccid != null) { query.AppendEquals(AtrCodeColumn.CrAccid, mock.CrAccid.ToString()); } if (mock.Accid1 != null) { query.AppendEquals(AtrCodeColumn.Accid1, mock.Accid1.ToString()); } if (mock.Accid2 != null) { query.AppendEquals(AtrCodeColumn.Accid2, mock.Accid2.ToString()); } if (mock.Accid3 != null) { query.AppendEquals(AtrCodeColumn.Accid3, mock.Accid3.ToString()); } if (mock.Pcommand != null) { query.AppendEquals(AtrCodeColumn.Pcommand, mock.Pcommand.ToString()); } if (mock.Form != null) { query.AppendEquals(AtrCodeColumn.Form, mock.Form.ToString()); } if (mock.Voucher != null) { query.AppendEquals(AtrCodeColumn.Voucher, mock.Voucher.ToString()); } if (mock.Fvoucher != null) { query.AppendEquals(AtrCodeColumn.Fvoucher, mock.Fvoucher.ToString()); } if (mock.Nov != null) { query.AppendEquals(AtrCodeColumn.Nov, mock.Nov.ToString()); } if (mock.TrType != null) { query.AppendEquals(AtrCodeColumn.TrType, mock.TrType.ToString()); } TList <AtrCode> results = DataRepository.AtrCodeProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }