/// <summary> /// Convert a nettiers entity to the ws proxy entity. /// </summary> public static WsProxy.StateProvince Convert(Nettiers.AdventureWorks.Entities.StateProvince item) { WsProxy.StateProvince outItem = new WsProxy.StateProvince(); outItem.StateProvinceId = item.StateProvinceId; outItem.StateProvinceCode = item.StateProvinceCode; outItem.CountryRegionCode = item.CountryRegionCode; outItem.IsOnlyStateProvinceFlag = item.IsOnlyStateProvinceFlag; outItem.Name = item.Name; outItem.TerritoryId = item.TerritoryId; outItem.Rowguid = item.Rowguid; outItem.ModifiedDate = item.ModifiedDate; return(outItem); }
/// <summary> /// Inserts a mock StateProvince entity into the database. /// </summary> private void Step_01_Insert_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); Assert.IsTrue(DataRepository.StateProvinceProvider.Insert(tm, mock), "Insert failed"); System.Console.WriteLine("DataRepository.StateProvinceProvider.Insert(mock):"); System.Console.WriteLine(mock); //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
/// <summary> /// Convert a nettiers collection to the ws proxy collection. /// </summary> public static Nettiers.AdventureWorks.Entities.StateProvince Convert(Nettiers.AdventureWorks.Entities.StateProvince outItem, WsProxy.StateProvince item) { if (item != null && outItem != null) { outItem.StateProvinceId = item.StateProvinceId; outItem.StateProvinceCode = item.StateProvinceCode; outItem.CountryRegionCode = item.CountryRegionCode; outItem.IsOnlyStateProvinceFlag = item.IsOnlyStateProvinceFlag; outItem.Name = item.Name; outItem.TerritoryId = item.TerritoryId; outItem.Rowguid = item.Rowguid; outItem.ModifiedDate = item.ModifiedDate; outItem.AcceptChanges(); } return(outItem); }
/// <summary> /// Inserts a Nettiers.AdventureWorks.Entities.StateProvince object into the datasource using a transaction. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="entity">Nettiers.AdventureWorks.Entities.StateProvince object to insert.</param> /// <remarks></remarks> /// <returns>Returns true if operation is successful.</returns> public override bool Insert(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.StateProvince entity) { WsProxy.AdventureWorksServices proxy = new WsProxy.AdventureWorksServices(); proxy.Url = Url; try { WsProxy.StateProvince result = proxy.StateProvinceProvider_Insert(Convert(entity)); Convert(entity, result); return(true); } catch (SoapException soex) { System.Diagnostics.Debug.WriteLine(soex); throw soex; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); throw ex; } }
/// <summary> /// Convert a nettiers collection to the ws proxy collection. /// </summary> public static Nettiers.AdventureWorks.Entities.StateProvince Convert(WsProxy.StateProvince item) { Nettiers.AdventureWorks.Entities.StateProvince outItem = item == null ? null : new Nettiers.AdventureWorks.Entities.StateProvince(); Convert(outItem, item); return(outItem); }
/// <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(StateProvince mock) { //Code your changes to the data object here. }
///<summary> /// Update the Typed StateProvince Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, StateProvince mock) { StateProvinceTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
///<summary> /// Update the Typed StateProvince Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, StateProvince mock) { mock.StateProvinceCode = TestUtility.Instance.RandomString(3, false);; mock.IsOnlyStateProvinceFlag = TestUtility.Instance.RandomBoolean(); mock.Name = TestUtility.Instance.RandomString(24, false);; mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); int count0 = 0; TList<CountryRegion> _collection0 = DataRepository.CountryRegionProvider.GetPaged(tm, 0, 10, out count0); //_collection0.Shuffle(); if (_collection0.Count > 0) { mock.CountryRegionCode = _collection0[0].CountryRegionCode; } int count1 = 0; TList<SalesTerritory> _collection1 = DataRepository.SalesTerritoryProvider.GetPaged(tm, 0, 10, out count1); //_collection1.Shuffle(); if (_collection1.Count > 0) { mock.TerritoryId = _collection1[0].TerritoryId; } }
///<summary> /// Returns a Typed StateProvince Entity with mock values. ///</summary> static public StateProvince CreateMockInstance_Generated(TransactionManager tm) { StateProvince mock = new StateProvince(); mock.StateProvinceCode = TestUtility.Instance.RandomString(3, false);; mock.IsOnlyStateProvinceFlag = TestUtility.Instance.RandomBoolean(); mock.Name = TestUtility.Instance.RandomString(24, false);; mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); int count0 = 0; TList<CountryRegion> _collection0 = DataRepository.CountryRegionProvider.GetPaged(tm, 0, 10, out count0); //_collection0.Shuffle(); if (_collection0.Count > 0) { mock.CountryRegionCode = _collection0[0].CountryRegionCode; } int count1 = 0; TList<SalesTerritory> _collection1 = DataRepository.SalesTerritoryProvider.GetPaged(tm, 0, 10, out count1); //_collection1.Shuffle(); if (_collection1.Count > 0) { mock.TerritoryId = _collection1[0].TerritoryId; } // create a temporary collection and add the item to it TList<StateProvince> tempMockCollection = new TList<StateProvince>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return (StateProvince)mock; }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); StateProvince entity = mock.Copy() as StateProvince; entity = (StateProvince)mock.Clone(); Assert.IsTrue(StateProvince.ValueEquals(entity, mock), "Clone is not working"); } }
/// <summary> /// Serialize a StateProvince 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_StateProvinceCollection.xml"); mock = CreateMockInstance(tm); TList<StateProvince> mockCollection = new TList<StateProvince>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<StateProvince> correctly serialized to a temporary file."); } }
/// <summary> /// Serialize the mock StateProvince 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_StateProvince.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> /// Deep load all StateProvince children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.StateProvinceProvider.GetPaged(tm, 0, 10, out count); DataRepository.StateProvinceProvider.DeepLoading += new EntityProviderBaseCore<StateProvince, StateProvinceKey>.DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) e.Cancel = true; } ); if (mockCollection.Count > 0) { DataRepository.StateProvinceProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("StateProvince instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.StateProvinceProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }