///<summary> /// Returns a Typed SalesOrderDetail Entity with mock values. ///</summary> static public SalesOrderDetail CreateMockInstance_Generated(TransactionManager tm) { SalesOrderDetail mock = new SalesOrderDetail(); mock.CarrierTrackingNumber = TestUtility.Instance.RandomString(11, false);; mock.OrderQty = TestUtility.Instance.RandomShort(); mock.UnitPrice = TestUtility.Instance.RandomShort(); mock.UnitPriceDiscount = TestUtility.Instance.RandomShort(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship SalesOrderHeader mockSalesOrderHeaderBySalesOrderId = SalesOrderHeaderTest.CreateMockInstance(tm); DataRepository.SalesOrderHeaderProvider.Insert(tm, mockSalesOrderHeaderBySalesOrderId); mock.SalesOrderId = mockSalesOrderHeaderBySalesOrderId.SalesOrderId; //OneToOneRelationship SpecialOfferProduct mockSpecialOfferProductBySpecialOfferIdProductId = SpecialOfferProductTest.CreateMockInstance(tm); DataRepository.SpecialOfferProductProvider.Insert(tm, mockSpecialOfferProductBySpecialOfferIdProductId); mock.SpecialOfferId = mockSpecialOfferProductBySpecialOfferIdProductId.SpecialOfferId; mock.ProductId = mockSpecialOfferProductBySpecialOfferIdProductId.ProductId; // create a temporary collection and add the item to it TList <SalesOrderDetail> tempMockCollection = new TList <SalesOrderDetail>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((SalesOrderDetail)mock); }
/// <summary> /// Deep load all SpecialOfferProduct children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.SpecialOfferProductProvider.GetPaged(tm, 0, 10, out count); DataRepository.SpecialOfferProductProvider.DeepLoading += new EntityProviderBaseCore <SpecialOfferProduct, SpecialOfferProductKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.SpecialOfferProductProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("SpecialOfferProduct instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.SpecialOfferProductProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
public SpecialOfferProduct GetSpecialOfferProduct(int SpecialOfferID) { IDBManager dbm = new DBManager(); SpecialOfferProduct SOP = new SpecialOfferProduct(); try { dbm.CreateParameters(1); dbm.AddParameters(0, "@SpecialOfferID", SpecialOfferID); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferProduct"); while (reader.Read()) { SOP.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString()); SOP.ProductID = Int32.Parse(reader["ProductID"].ToString()); SOP.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); } } catch (Exception ex) { log.Write(ex.Message, "GetSpecialOfferProduct"); throw (ex); } finally { dbm.Dispose(); } return(SOP); }
public SpecialOfferProductCollection GetAllSpecialOfferProductsDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); SpecialOfferProductCollection cols = new SpecialOfferProductCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferProductsDynamic"); while (reader.Read()) { SpecialOfferProduct SOP = new SpecialOfferProduct(); SOP.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString()); SOP.ProductID = Int32.Parse(reader["ProductID"].ToString()); SOP.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(SOP); } } catch (Exception ex) { log.Write(ex.Message, "GetAllSpecialOfferProductsDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
public void AddOrderLine_NoOrderLinesWithProductFound_NewOrderLineWithQuantity( SalesOrder salesOrder, string productNumber, string productName, decimal unitPrice, SpecialOfferProduct specialOfferProduct, short quantity ) { //Arrange //Act salesOrder.AddOrderLine( productNumber, productName, unitPrice, 0, specialOfferProduct, quantity ); //Assert var orderLines = salesOrder.OrderLines.ToList(); orderLines.Count.Should().Be(1); orderLines[0].OrderQty.Should().Be(quantity); }
public void Create_ZeroQuantity_ThrowSalesOrderDomainException( string productNumber, string productName, decimal unitPrice, decimal unitPriceDiscount, SpecialOfferProduct specialOfferProduct ) { //Arrange //Act Action act = () => { var salesOrderLine = new SalesOrderLine( productNumber, productName, unitPrice, unitPriceDiscount, specialOfferProduct, 0 ); }; //Assert act.Should().Throw <SalesDomainException>(); }
public void AddOrderLineWithDiscount_OrderLineWithProductFound_UpdatedOrderLine( SalesOrder salesOrder, SalesOrderLine salesOrderLine, SpecialOfferProduct specialOfferProduct ) { //Arrange salesOrder.AddOrderLine( salesOrderLine.ProductNumber, salesOrderLine.ProductName, salesOrderLine.UnitPriceDiscount, 0, specialOfferProduct ); var orderLines = salesOrder.OrderLines.ToList(); var existingOrderLine = orderLines[0]; var originalQuantity = existingOrderLine.UnitPriceDiscount; //Act salesOrder.AddOrderLine( existingOrderLine.ProductNumber, existingOrderLine.ProductName, existingOrderLine.UnitPrice, existingOrderLine.UnitPriceDiscount + 1, specialOfferProduct ); //Assert orderLines.Count.Should().Be(1); orderLines[0].UnitPriceDiscount.Should().Be((short)(originalQuantity + 1)); }
private void PopulateSpecialOfferGrid(int productID) { SpecialOfferProduct sop = new SpecialOfferProduct(); SpecialOffer so = new SpecialOffer(); try { SetupSpecialOfferGrid(); string where = string.Format("startDate <= getdate() and endDate >= getdate() and exists(select 1 from SpecialOfferProduct where specialofferid=SpecialOffer.specialofferid and productID={0})", productID); string orderBy = "enddate"; SpecialOfferCollection soc = so.GetSpecialOffersCollection(where, orderBy); DataTable dt = new DataTable(); foreach (SpecialOffer s in soc) { DataRow dr = dsSpeicalOffer.Tables[0].NewRow(); dr[0] = s.Description; dr[1] = s.DiscountPct; dsSpeicalOffer.Tables[0].Rows.Add(dr); } } catch (Exception ex) { MessageBox.Show("Error. Failed to load Speical Offers for this product"); MessageBox.Show(ex.ToString()); } }
///<summary> /// Returns a Typed SpecialOfferProduct Entity with mock values. ///</summary> static public SpecialOfferProduct CreateMockInstance_Generated(TransactionManager tm) { SpecialOfferProduct mock = new SpecialOfferProduct(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Product mockProductByProductId = ProductTest.CreateMockInstance(tm); DataRepository.ProductProvider.Insert(tm, mockProductByProductId); mock.ProductId = mockProductByProductId.ProductId; //OneToOneRelationship SpecialOffer mockSpecialOfferBySpecialOfferId = SpecialOfferTest.CreateMockInstance(tm); DataRepository.SpecialOfferProvider.Insert(tm, mockSpecialOfferBySpecialOfferId); mock.SpecialOfferId = mockSpecialOfferBySpecialOfferId.SpecialOfferId; // create a temporary collection and add the item to it TList <SpecialOfferProduct> tempMockCollection = new TList <SpecialOfferProduct>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((SpecialOfferProduct)mock); }
public SpecialOfferProductCollection GetAllSpecialOfferProductsCollection() { IDBManager dbm = new DBManager(); SpecialOfferProductCollection cols = new SpecialOfferProductCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferProductAll"); while (reader.Read()) { SpecialOfferProduct SOP = new SpecialOfferProduct(); SOP.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString()); SOP.ProductID = Int32.Parse(reader["ProductID"].ToString()); SOP.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(SOP); } } catch (Exception ex) { log.Write(ex.Message, "GetAllSpecialOfferProductsCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
///<summary> /// Update the Typed SpecialOfferProduct Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, SpecialOfferProduct mock) { SpecialOfferProductTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); SpecialOfferProduct entity = mock.Copy() as SpecialOfferProduct; entity = (SpecialOfferProduct)mock.Clone(); Assert.IsTrue(SpecialOfferProduct.ValueEquals(entity, mock), "Clone is not working"); } }
// PUT api/awbuildversion/5 public void Put(SpecialOfferProduct value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) adventureWorks_BC.SpecialOfferProductDelete(value); if (GetActionType.Value.ToList()[0].Equals("UPDATE")) adventureWorks_BC.SpecialOfferProductUpdate(value); } }
///<summary> /// Returns a Typed SpecialOfferProduct Entity with mock values. ///</summary> static public SpecialOfferProduct CreateMockInstance(TransactionManager tm) { // get the default mock instance SpecialOfferProduct mock = SpecialOfferProductTest.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); }
public virtual SpecialOfferProduct MapBOToEF( BOSpecialOfferProduct bo) { SpecialOfferProduct efSpecialOfferProduct = new SpecialOfferProduct(); efSpecialOfferProduct.SetProperties( bo.ModifiedDate, bo.ProductID, bo.Rowguid, bo.SpecialOfferID); return(efSpecialOfferProduct); }
public virtual BOSpecialOfferProduct MapEFToBO( SpecialOfferProduct ef) { var bo = new BOSpecialOfferProduct(); bo.SetProperties( ef.SpecialOfferID, ef.ModifiedDate, ef.ProductID, ef.Rowguid); return(bo); }
/// <summary> /// Serialize the mock SpecialOfferProduct 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_SpecialOfferProduct.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."); } }
public bool SpecialOfferProductDelete(SpecialOfferProduct specialofferproduct) { return(Execute <bool>(dal => { SpecialOfferProduct specialofferproductDelete = dal.SpecialOfferProduct.Where(x => x.SpecialOfferID == specialofferproduct.SpecialOfferID).FirstOrDefault(); if (specialofferproductDelete != null) { dal.SpecialOfferProduct.DeleteOnSubmit(specialofferproductDelete); dal.SubmitChanges(); return true; } return false; })); }
public void MapEFToBO() { var mapper = new DALSpecialOfferProductMapper(); SpecialOfferProduct entity = new SpecialOfferProduct(); entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1); BOSpecialOfferProduct response = mapper.MapEFToBO(entity); response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ProductID.Should().Be(1); response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.SpecialOfferID.Should().Be(1); }
public void MapEFToBOList() { var mapper = new DALSpecialOfferProductMapper(); SpecialOfferProduct entity = new SpecialOfferProduct(); entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1); List <BOSpecialOfferProduct> response = mapper.MapEFToBO(new List <SpecialOfferProduct>() { entity }); response.Count.Should().Be(1); }
public void MapBOToEF() { var mapper = new DALSpecialOfferProductMapper(); var bo = new BOSpecialOfferProduct(); bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); SpecialOfferProduct response = mapper.MapBOToEF(bo); response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ProductID.Should().Be(1); response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.SpecialOfferID.Should().Be(1); }
/// <summary> /// Serialize a SpecialOfferProduct 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_SpecialOfferProductCollection.xml"); mock = CreateMockInstance(tm); TList <SpecialOfferProduct> mockCollection = new TList <SpecialOfferProduct>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<SpecialOfferProduct> correctly serialized to a temporary file."); } }
///<summary> /// Update the Typed SpecialOfferProduct Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, SpecialOfferProduct mock) { mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Product mockProductByProductId = ProductTest.CreateMockInstance(tm); DataRepository.ProductProvider.Insert(tm, mockProductByProductId); mock.ProductId = mockProductByProductId.ProductId; //OneToOneRelationship SpecialOffer mockSpecialOfferBySpecialOfferId = SpecialOfferTest.CreateMockInstance(tm); DataRepository.SpecialOfferProvider.Insert(tm, mockSpecialOfferBySpecialOfferId); mock.SpecialOfferId = mockSpecialOfferBySpecialOfferId.SpecialOfferId; }
// PUT api/awbuildversion/5 public void Put(SpecialOfferProduct value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) { adventureWorks_BC.SpecialOfferProductDelete(value); } if (GetActionType.Value.ToList()[0].Equals("UPDATE")) { adventureWorks_BC.SpecialOfferProductUpdate(value); } } }
public async void Get() { var mock = new ServiceMockFacade <ISpecialOfferProductRepository>(); var record = new SpecialOfferProduct(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new SpecialOfferProductService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.SpecialOfferProductModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLSpecialOfferProductMapperMock, mock.DALMapperMockFactory.DALSpecialOfferProductMapperMock); ApiSpecialOfferProductResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public bool SpecialOfferProductUpdate(SpecialOfferProduct specialofferproduct) { return(Execute <bool>(dal => { SpecialOfferProduct specialofferproductUpdate = dal.SpecialOfferProduct.Where(x => x.SpecialOfferID == specialofferproduct.SpecialOfferID).FirstOrDefault(); if (specialofferproductUpdate != null) { specialofferproductUpdate.SpecialOfferID = specialofferproduct.SpecialOfferID; specialofferproductUpdate.ProductID = specialofferproduct.ProductID; specialofferproductUpdate.rowguid = specialofferproduct.rowguid; specialofferproductUpdate.ModifiedDate = specialofferproduct.ModifiedDate; dal.SubmitChanges(); return true; } return false; })); }
public void ExportSpecialOffers() { SqlCompactConnection conn = new SqlCompactConnection(); SpecialOffer so = new SpecialOffer(); SpecialOfferCollection soCol = new SpecialOfferCollection(); SpecialOfferProduct sop = new SpecialOfferProduct(); SpecialOfferProductCollection sopCol = new SpecialOfferProductCollection(); string where = "startdate <= getdate() and enddate >= getdate()"; string orderby = "specialofferid"; try { //ds = q.GetDataSet(false, sql); soCol = so.GetSpecialOffersCollection(where, orderby); conn.SynchForm = this; conn.DropSepcialOfferTable(); conn.CreateSpecialOfferTable(); conn.AddSpecialOffer(soCol); where = "specialofferid in (select specialofferid from specialoffer where startdate <= getdate() and enddate >= getdate())"; orderby = "specialofferid"; sopCol = sop.GetSpecialOfferProductsCollection(where, orderby); conn.DropSepcialOfferProductTable(); conn.CreateSpecialOfferProductTable(); conn.AddSpecialOfferProduct(sopCol); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; so = null; soCol = null; sop = null; sopCol = null; //ds.Dispose(); // q = null; } }
public void Create_Ok_OrderLineCreated( string productNumber, string productName, decimal unitPrice, SpecialOfferProduct specialOfferProduct ) { //Arrange //Act var salesOrderLine = new SalesOrderLine( productNumber, productName, unitPrice, unitPrice / 2, specialOfferProduct ); //Assert salesOrderLine.Should().NotBeNull(); }
///<summary> /// Update the Typed SalesOrderDetail Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, SalesOrderDetail mock) { mock.CarrierTrackingNumber = TestUtility.Instance.RandomString(11, false);; mock.OrderQty = TestUtility.Instance.RandomShort(); mock.UnitPrice = TestUtility.Instance.RandomShort(); mock.UnitPriceDiscount = TestUtility.Instance.RandomShort(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship SalesOrderHeader mockSalesOrderHeaderBySalesOrderId = SalesOrderHeaderTest.CreateMockInstance(tm); DataRepository.SalesOrderHeaderProvider.Insert(tm, mockSalesOrderHeaderBySalesOrderId); mock.SalesOrderId = mockSalesOrderHeaderBySalesOrderId.SalesOrderId; //OneToOneRelationship SpecialOfferProduct mockSpecialOfferProductBySpecialOfferIdProductId = SpecialOfferProductTest.CreateMockInstance(tm); DataRepository.SpecialOfferProductProvider.Insert(tm, mockSpecialOfferProductBySpecialOfferIdProductId); mock.SpecialOfferId = mockSpecialOfferProductBySpecialOfferIdProductId.SpecialOfferId; mock.ProductId = mockSpecialOfferProductBySpecialOfferIdProductId.ProductId; }
public bool DeleteSpecialOfferProduct(SpecialOfferProduct SOP) { IDBManager dbm = new DBManager(); try { dbm.CreateParameters(1); dbm.AddParameters(0, "@SpecialOfferID", SOP.SpecialOfferID); dbm.ExecuteNonQuery(CommandType.StoredProcedure, "DeleteSpecialOfferProduct"); } catch (Exception ex) { log.Write(ex.Message, "DeleteSpecialOfferProduct"); throw (ex); } finally { dbm.Dispose(); } return(true); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance SpecialOfferProduct mock = CreateMockInstance(tm); bool result = DataRepository.SpecialOfferProductProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); SpecialOfferProductQuery query = new SpecialOfferProductQuery(); query.AppendEquals(SpecialOfferProductColumn.SpecialOfferId, mock.SpecialOfferId.ToString()); query.AppendEquals(SpecialOfferProductColumn.ProductId, mock.ProductId.ToString()); query.AppendEquals(SpecialOfferProductColumn.Rowguid, mock.Rowguid.ToString()); query.AppendEquals(SpecialOfferProductColumn.ModifiedDate, mock.ModifiedDate.ToString()); TList <SpecialOfferProduct> results = DataRepository.SpecialOfferProductProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
/// <summary> /// Serialize the mock SpecialOfferProduct 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_SpecialOfferProduct.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 SpecialOfferProduct children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.SpecialOfferProductProvider.GetPaged(tm, 0, 10, out count); DataRepository.SpecialOfferProductProvider.DeepLoading += new EntityProviderBaseCore<SpecialOfferProduct, SpecialOfferProductKey>.DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) e.Cancel = true; } ); if (mockCollection.Count > 0) { DataRepository.SpecialOfferProductProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("SpecialOfferProduct instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.SpecialOfferProductProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Update the Typed SpecialOfferProduct Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, SpecialOfferProduct mock) { mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Product mockProductByProductId = ProductTest.CreateMockInstance(tm); DataRepository.ProductProvider.Insert(tm, mockProductByProductId); mock.ProductId = mockProductByProductId.ProductId; //OneToOneRelationship SpecialOffer mockSpecialOfferBySpecialOfferId = SpecialOfferTest.CreateMockInstance(tm); DataRepository.SpecialOfferProvider.Insert(tm, mockSpecialOfferBySpecialOfferId); mock.SpecialOfferId = mockSpecialOfferBySpecialOfferId.SpecialOfferId; }
///<summary> /// Returns a Typed SpecialOfferProduct Entity with mock values. ///</summary> static public SpecialOfferProduct CreateMockInstance_Generated(TransactionManager tm) { SpecialOfferProduct mock = new SpecialOfferProduct(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Product mockProductByProductId = ProductTest.CreateMockInstance(tm); DataRepository.ProductProvider.Insert(tm, mockProductByProductId); mock.ProductId = mockProductByProductId.ProductId; //OneToOneRelationship SpecialOffer mockSpecialOfferBySpecialOfferId = SpecialOfferTest.CreateMockInstance(tm); DataRepository.SpecialOfferProvider.Insert(tm, mockSpecialOfferBySpecialOfferId); mock.SpecialOfferId = mockSpecialOfferBySpecialOfferId.SpecialOfferId; // create a temporary collection and add the item to it TList<SpecialOfferProduct> tempMockCollection = new TList<SpecialOfferProduct>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return (SpecialOfferProduct)mock; }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); SpecialOfferProduct entity = mock.Copy() as SpecialOfferProduct; entity = (SpecialOfferProduct)mock.Clone(); Assert.IsTrue(SpecialOfferProduct.ValueEquals(entity, mock), "Clone is not working"); } }
/// <summary> /// Serialize a SpecialOfferProduct 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_SpecialOfferProductCollection.xml"); mock = CreateMockInstance(tm); TList<SpecialOfferProduct> mockCollection = new TList<SpecialOfferProduct>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<SpecialOfferProduct> correctly serialized to a temporary file."); } }
// POST api/awbuildversion public void Post(SpecialOfferProduct value) { adventureWorks_BC.SpecialOfferProductAdd(value); }
/// <summary> /// There are no comments for SpecialOfferProduct in the schema. /// </summary> public void AddToSpecialOfferProduct(SpecialOfferProduct specialOfferProduct) { base.AddObject("SpecialOfferProduct", specialOfferProduct); }
/// <summary> /// Create a new SpecialOfferProduct object. /// </summary> /// <param name="specialOfferID">Initial value of SpecialOfferID.</param> /// <param name="productID">Initial value of ProductID.</param> /// <param name="rowguid">Initial value of rowguid.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static SpecialOfferProduct CreateSpecialOfferProduct(int specialOfferID, int productID, global::System.Guid rowguid, global::System.DateTime modifiedDate) { SpecialOfferProduct specialOfferProduct = new SpecialOfferProduct(); specialOfferProduct.SpecialOfferID = specialOfferID; specialOfferProduct.ProductID = productID; specialOfferProduct.rowguid = rowguid; specialOfferProduct.ModifiedDate = modifiedDate; return specialOfferProduct; }
///<summary> /// Update the Typed SpecialOfferProduct Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, SpecialOfferProduct mock) { SpecialOfferProductTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
/// <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(SpecialOfferProduct mock) { //Code your changes to the data object here. }