public void AddLineItemShouldAddLineItem()
        {
            using (var context = new Entity.MochaMomentDBContext(options)) {
                IRepository _repo = new RepoDB(context);
                _repo.AddCustomer(new Model.Customer("firstName", "lastName", "birthdate", "phone#", "email", "Mailing Address"));
                _repo.AddLocation(new Model.Location("name", "address", "city", "state"));
                _repo.AddProduct(new Model.Product("name", 1.99, "description"));
                _repo.AddOrder(new Model.Order(1, 1, 1, 1.99, ""), new Model.Location("name", "address", "city", "state"), new Model.Customer("firstName", "lastName", "birthdate", "phone#", "email", "Mailing Address"));
                _repo.AddLineItem(new Model.LineItem(1, 1, 1), new Model.Product("name", 1.99, "description"));
            }

            using (var assertContext = new Entity.MochaMomentDBContext(options)) {
                var result = assertContext.LineItems.FirstOrDefault(li => li.LineItemId == 1);
                Assert.NotNull(result);
                Assert.Equal(1, result.Quantity);
            }
        }
예제 #2
0
        public void TestLocationBeingAdded()
        {
            Location c = new Location(){LocationName = "name", Address="address"};
            using (var context = new StoreDBContext(options)){
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                IRepository _repo = new RepoDB(context);
                _repo.AddLocation(c);

            }
            //Using a new context check for Location
            using (var context = new StoreDBContext(options)){
                IRepository _repo = new RepoDB(context);
                List<Location> cs = _repo.GetAllLocations();
                Location cdb = cs.ToArray()[0];
                Assert.Equal(c.LocationID, cdb.LocationID);
                Assert.Equal(c.LocationName, cdb.LocationName);
                Assert.Equal(c.Address, cdb.Address);
                Assert.True(cs.Count == 1);
                context.Database.EnsureDeleted();

               }
        }