/// <summary> /// Deep load all StudentMasterIndex children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.StudentMasterIndexProvider.GetPaged(tm, 0, 10, out count); DataRepository.StudentMasterIndexProvider.DeepLoading += new EntityProviderBaseCore <StudentMasterIndex, StudentMasterIndexKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.StudentMasterIndexProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("StudentMasterIndex instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.StudentMasterIndexProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Update the Typed StudentMasterIndex Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, StudentMasterIndex mock) { mock.EpassId = TestUtility.Instance.RandomString(24, false);; mock.StudentUpn = TestUtility.Instance.RandomString(13, false);; mock.SsabsaId = TestUtility.Instance.RandomString(49, false);; mock.Surname = TestUtility.Instance.RandomString(14, false);; mock.FirstName = TestUtility.Instance.RandomString(11, false);; mock.OtherNames = TestUtility.Instance.RandomString(24, false);; mock.KnownName = TestUtility.Instance.RandomString(11, false);; mock.LegalName = TestUtility.Instance.RandomString(14, false);; mock.Dob = TestUtility.Instance.RandomDateTime(); mock.Gender = TestUtility.Instance.RandomString(6, false);; mock.IndigeneousStatus = TestUtility.Instance.RandomString(19, false);; mock.Lbote = TestUtility.Instance.RandomString(3, false);; mock.EslPhase = TestUtility.Instance.RandomString(11, false);; mock.TribalGroup = TestUtility.Instance.RandomString(24, false);; mock.SlpCreatedFlag = TestUtility.Instance.RandomString(3, false);; mock.AddressLine1 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine2 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine3 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine4 = TestUtility.Instance.RandomString(24, false);; mock.Suburb = TestUtility.Instance.RandomString(24, false);; mock.Postcode = TestUtility.Instance.RandomString(4, false);; mock.Phone1 = TestUtility.Instance.RandomString(10, false);; mock.Phone2 = TestUtility.Instance.RandomString(10, false);; mock.SourceSystem = TestUtility.Instance.RandomString(11, false);; mock.PhoneticMatchId = TestUtility.Instance.RandomNumber(); }
///<summary> /// Update the Typed StudentMasterIndex Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, StudentMasterIndex mock) { StudentMasterIndexTest.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()) { StudentMasterIndex entity = CreateMockInstance(tm); bool result = DataRepository.StudentMasterIndexProvider.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); StudentMasterIndex entity = mock.Copy() as StudentMasterIndex; entity = (StudentMasterIndex)mock.Clone(); Assert.IsTrue(StudentMasterIndex.ValueEquals(entity, mock), "Clone is not working"); } }
///<summary> /// Returns a Typed StudentMasterIndex Entity with mock values. ///</summary> static public StudentMasterIndex CreateMockInstance(TransactionManager tm) { // get the default mock instance StudentMasterIndex mock = StudentMasterIndexTest.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 StudentMasterIndex 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_StudentMasterIndex.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 StudentMasterIndex entity into the database. /// </summary> private void Step_01_Insert_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); Assert.IsTrue(DataRepository.StudentMasterIndexProvider.Insert(tm, mock), "Insert failed"); System.Console.WriteLine("DataRepository.StudentMasterIndexProvider.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 StudentMasterIndex 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_StudentMasterIndexCollection.xml"); mock = CreateMockInstance(tm); TList <StudentMasterIndex> mockCollection = new TList <StudentMasterIndex>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<StudentMasterIndex> correctly serialized to a temporary file."); } }
///<summary> /// Returns a Typed StudentMasterIndex Entity with mock values. ///</summary> static public StudentMasterIndex CreateMockInstance_Generated(TransactionManager tm) { StudentMasterIndex mock = new StudentMasterIndex(); mock.StudentId = TestUtility.Instance.RandomNumber(); mock.EpassId = TestUtility.Instance.RandomString(24, false);; mock.StudentUpn = TestUtility.Instance.RandomString(13, false);; mock.SsabsaId = TestUtility.Instance.RandomString(49, false);; mock.Surname = TestUtility.Instance.RandomString(14, false);; mock.FirstName = TestUtility.Instance.RandomString(11, false);; mock.OtherNames = TestUtility.Instance.RandomString(24, false);; mock.KnownName = TestUtility.Instance.RandomString(11, false);; mock.LegalName = TestUtility.Instance.RandomString(14, false);; mock.Dob = TestUtility.Instance.RandomDateTime(); mock.Gender = TestUtility.Instance.RandomString(6, false);; mock.IndigeneousStatus = TestUtility.Instance.RandomString(19, false);; mock.Lbote = TestUtility.Instance.RandomString(3, false);; mock.EslPhase = TestUtility.Instance.RandomString(11, false);; mock.TribalGroup = TestUtility.Instance.RandomString(24, false);; mock.SlpCreatedFlag = TestUtility.Instance.RandomString(3, false);; mock.AddressLine1 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine2 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine3 = TestUtility.Instance.RandomString(24, false);; mock.AddressLine4 = TestUtility.Instance.RandomString(24, false);; mock.Suburb = TestUtility.Instance.RandomString(24, false);; mock.Postcode = TestUtility.Instance.RandomString(4, false);; mock.Phone1 = TestUtility.Instance.RandomString(10, false);; mock.Phone2 = TestUtility.Instance.RandomString(10, false);; mock.SourceSystem = TestUtility.Instance.RandomString(11, false);; mock.PhoneticMatchId = TestUtility.Instance.RandomNumber(); // create a temporary collection and add the item to it TList <StudentMasterIndex> tempMockCollection = new TList <StudentMasterIndex>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((StudentMasterIndex)mock); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance StudentMasterIndex mock = CreateMockInstance(tm); bool result = DataRepository.StudentMasterIndexProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); StudentMasterIndexQuery query = new StudentMasterIndexQuery(); query.AppendEquals(StudentMasterIndexColumn.StudentId, mock.StudentId.ToString()); if (mock.EpassId != null) { query.AppendEquals(StudentMasterIndexColumn.EpassId, mock.EpassId.ToString()); } if (mock.StudentUpn != null) { query.AppendEquals(StudentMasterIndexColumn.StudentUpn, mock.StudentUpn.ToString()); } if (mock.SsabsaId != null) { query.AppendEquals(StudentMasterIndexColumn.SsabsaId, mock.SsabsaId.ToString()); } if (mock.Surname != null) { query.AppendEquals(StudentMasterIndexColumn.Surname, mock.Surname.ToString()); } if (mock.FirstName != null) { query.AppendEquals(StudentMasterIndexColumn.FirstName, mock.FirstName.ToString()); } if (mock.OtherNames != null) { query.AppendEquals(StudentMasterIndexColumn.OtherNames, mock.OtherNames.ToString()); } if (mock.KnownName != null) { query.AppendEquals(StudentMasterIndexColumn.KnownName, mock.KnownName.ToString()); } if (mock.LegalName != null) { query.AppendEquals(StudentMasterIndexColumn.LegalName, mock.LegalName.ToString()); } if (mock.Dob != null) { query.AppendEquals(StudentMasterIndexColumn.Dob, mock.Dob.ToString()); } if (mock.Gender != null) { query.AppendEquals(StudentMasterIndexColumn.Gender, mock.Gender.ToString()); } if (mock.IndigeneousStatus != null) { query.AppendEquals(StudentMasterIndexColumn.IndigeneousStatus, mock.IndigeneousStatus.ToString()); } if (mock.Lbote != null) { query.AppendEquals(StudentMasterIndexColumn.Lbote, mock.Lbote.ToString()); } if (mock.EslPhase != null) { query.AppendEquals(StudentMasterIndexColumn.EslPhase, mock.EslPhase.ToString()); } if (mock.TribalGroup != null) { query.AppendEquals(StudentMasterIndexColumn.TribalGroup, mock.TribalGroup.ToString()); } if (mock.SlpCreatedFlag != null) { query.AppendEquals(StudentMasterIndexColumn.SlpCreatedFlag, mock.SlpCreatedFlag.ToString()); } if (mock.AddressLine1 != null) { query.AppendEquals(StudentMasterIndexColumn.AddressLine1, mock.AddressLine1.ToString()); } if (mock.AddressLine2 != null) { query.AppendEquals(StudentMasterIndexColumn.AddressLine2, mock.AddressLine2.ToString()); } if (mock.AddressLine3 != null) { query.AppendEquals(StudentMasterIndexColumn.AddressLine3, mock.AddressLine3.ToString()); } if (mock.AddressLine4 != null) { query.AppendEquals(StudentMasterIndexColumn.AddressLine4, mock.AddressLine4.ToString()); } if (mock.Suburb != null) { query.AppendEquals(StudentMasterIndexColumn.Suburb, mock.Suburb.ToString()); } if (mock.Postcode != null) { query.AppendEquals(StudentMasterIndexColumn.Postcode, mock.Postcode.ToString()); } if (mock.Phone1 != null) { query.AppendEquals(StudentMasterIndexColumn.Phone1, mock.Phone1.ToString()); } if (mock.Phone2 != null) { query.AppendEquals(StudentMasterIndexColumn.Phone2, mock.Phone2.ToString()); } if (mock.SourceSystem != null) { query.AppendEquals(StudentMasterIndexColumn.SourceSystem, mock.SourceSystem.ToString()); } if (mock.PhoneticMatchId != null) { query.AppendEquals(StudentMasterIndexColumn.PhoneticMatchId, mock.PhoneticMatchId.ToString()); } TList <StudentMasterIndex> results = DataRepository.StudentMasterIndexProvider.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(StudentMasterIndex mock) { //Code your changes to the data object here. }