public void SetCompany() { Address newTemp = new Address(); Supplier tempSupplier = new Supplier(); SupplierAddress supdataspec = new SupplierAddress(); //create supplier tempSupplier.Name = "Neato Labs"; tempSupplier.Phone = "541-555-1122"; tempSupplier.Note = "Very neat."; tempSupplier.ContactFirstName = "Christy"; tempSupplier.ContactLastName = "Wear"; tempSupplier.ContactPhone = "541-555-1123"; //create address newTemp.StreetLine1 = "123 neato st."; newTemp.StreetLine2 = "Suite 1"; newTemp.City = "Eugene"; newTemp.State = "Oregon"; newTemp.Country = "USA"; //add primary data (supplier, and address) if (!supList.Exists(x => x.Name == tempSupplier.Name)) { dbContext.Supplier.Add(tempSupplier); } if (!addresses.Exists(x => x.StreetLine1 == newTemp.StreetLine1)) { dbContext.Address.Add(newTemp); } dbContext.SaveChanges(); //update supplier adddress table sup = dbContext.Supplier.SingleOrDefault(x => x.Name == "Neato Labs"); addr = dbContext.Address.SingleOrDefault(x => x.StreetLine1 == "123 neato st."); SupplierAddress supMapAddr = new SupplierAddress(); supMapAddr.AddressId = addr.AddressId; supMapAddr.SupplierId = sup.SupplierId; supMapAddr.AddressTypeId = addTypeList[addTypeList.FindIndex(x => x.Name == "mailing")].AddressTypeId; // mailing dbContext.SupplierAddress.Add(supMapAddr); dbContext.SaveChanges(); supMapAddr = dbContext.SupplierAddress.SingleOrDefault(x => x.SupplierId == sup.SupplierId); //verify Assert.IsNotNull(supMapAddr); //Verify and output sup = dbContext.Supplier.SingleOrDefault(x => x.Name == tempSupplier.Name); addr = dbContext.Address.SingleOrDefault(x => x.StreetLine1 == newTemp.StreetLine1); Assert.IsNotNull(sup); Assert.IsNotNull(addr); Assert.AreEqual("Neato Labs", sup.Name); Assert.AreEqual("123 neato st.", addr.StreetLine1); PrintInfo(addr, sup); }
public void CreateTest() { Y = new Yeast(); Y.ProductId = "EE101RED"; Y.MinTemp = 2.0; Y.MaxTemp = 44.22; Y.Form = "Non-Newtonian"; Y.Laboratory = "S.T.A.R. Labs"; Y.Flocculation = "I'm not giggling you are.."; Y.Attenuation = 1.21; Y.MaxReuse = Int32.MaxValue; Y.Type = "Flux Capacitance"; Y.BestFor = "Time travel"; I = new Ingredient(); I.Name = "The Time Traveler"; I.IngredientTypeId = 4; I.Version = 1; I.OnHandQuantity = 0; I.UnitCost = 0.00m; I.UnitTypeId = 2; I.Notes = "A swirling mass of wibbly wobbly colourful time stuff"; dbContext.Ingredient.Add(I); dbContext.SaveChanges(); Y.IngredientId = I.IngredientId; dbContext.Yeast.Add(Y); dbContext.SaveChanges(); List <Ingredient> myIngredient = dbContext.Ingredient.Where(I => I.Name == "The Time Traveler").ToList(); Assert.IsNotNull(dbContext.Ingredient.Find(I.IngredientId)); List <Yeast> myyeast = dbContext.Yeast.Where(Y => Y.ProductId == "EE101RED").ToList(); Assert.IsNotNull(dbContext.Yeast.Find(Y.IngredientId)); }