public int AddUser(string name, string email, string password){ _context.Customers.Add(new Customer{ Name = name, Email = email, Password = password }); _context.SaveChanges(); return GetUserID(email, password); }
//When testing operations that change the state of the db (i.e manipulate the data inside the db) //make sure to check if the change has persisted even when accessing the db using a different context/connection //This means that you create another instance of your context when testing to check that the method has //definitely affected the db. //What operations affect the state of the db? Create, Update, Delete private void Seed() { using (var context = new DataLogic.StoreDBContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Locations.Add( new Location { LocationId = 1, Name = "Scranton", Address = "5354 West Pickle St. Scranton, OH 99849" } ); context.Products.Add( new Product { ProductId = 1, Name = "Dirt", Price = 5.99 } ); context.SaveChanges(); } }