Example #1
0
 public void GetInventoriesShouldGetAllInventories()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         var inventories        = _repo.GetInventories();
         Assert.Equal(6, inventories.Count);
     }
 }
Example #2
0
 public void GetProductsShouldGetAllProducts()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         var products           = _repo.GetProducts();
         Assert.Equal(3, products.Count);
     }
 }
 public void SearchForProductShouldReturnProduct()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IProductRepository _repo = new ProductRepoDB(context, new StoreMapper());
         var product = _repo.GetProducts();
         Assert.Equal(2, product.Count());
     }
 }
 public void SearchForItemShouldReturnItem()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IItemRepository _repo = new ItemRepoDB(context, new StoreMapper());
         var             item  = _repo.GetItems();
         Assert.Equal(2, item.Count());
     }
 }
 public void SearchForItemShouldReturnSpecificItem()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IItemRepository _repo = new ItemRepoDB(context, new StoreMapper());
         var             item  = _repo.GetItemByID(0);
         Assert.Equal(item, item);
     }
 }
 public void SearchSpecificLocationShouldReturnLocation()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         ILocationRepository _repo = new LocationRepoDB(context, new StoreMapper());
         var location = _repo.GetSpecificLocation(0);
         Assert.Equal(location, location);
     }
 }
Example #7
0
 public void GetLocationsShouldReturnAllLocations()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         var locations          = _repo.GetLocations();
         Assert.Equal(2, locations.Count);
     }
 }
Example #8
0
        public void SearchCustomerNameShouldReturnCustomer()
        {
            using (var context = new Entity.StoreDBContext(options))
            {
                IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
                var foundCustomer      = _repo.SearchCustomerName("Joe");

                Assert.NotNull(foundCustomer);
                Assert.Equal("Joe", foundCustomer.CustomerName);
            }
        }
 public void GetAllCustomersShouldReturnAllCustomers()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         //Arrange
         ICustomerRepository _repo = new CustomerRepoDB(context, new StoreMapper());
         //Act
         var customer = _repo.GetCustomers();
         Assert.Equal(2, customer.Count);
     }
 }
Example #10
0
        public void SetLocationShouldReturnLocation()
        {
            using (var context = new Entity.StoreDBContext(options))
            {
                IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
                var foundLocation      = _repo.SetLocation(2);

                Assert.NotNull(foundLocation);
                Assert.Equal(2, foundLocation.LocationID);
            }
        }
Example #11
0
 public void CreateCustomerShouldCreateCustomer()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         _repo.CreateCustomer
         (
             new Model.Customer
         {
             CustomerName  = "Zach",
             CustomerEmail = "*****@*****.**"
         }
         );
     }
     using (var assertContext = new Entity.StoreDBContext(options))
     {
         var result = assertContext.Customers.FirstOrDefault(customer => customer.CustomerName == "Zach");
         Assert.NotNull(result);
         Assert.Equal("Zach", result.CustomerName);
     }
 }
Example #12
0
 public void CreateProductShouldCreateProduct()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         _repo.CreateProduct
         (
             new Model.Product
         {
             ProductName  = "Bat Tears",
             ProductPrice = 5
         }
         );
     }
     using (var assertContext = new Entity.StoreDBContext(options))
     {
         var result = assertContext.Products.FirstOrDefault(product => product.ProductName == "Bat Tears");
         Assert.NotNull(result);
         Assert.Equal("Bat Tears", result.ProductName);
     }
 }
Example #13
0
 public void DeleteCustomerShouldDeleteCustomer()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         _repo.DeleteCustomer
         (
             new Model.Customer
         {
             CustomerID    = 1,
             CustomerName  = "Joe",
             CustomerEmail = "*****@*****.**"
         }
         );
     }
     using (var assertContext = new Entity.StoreDBContext(options))
     {
         var result = assertContext.Customers.FirstOrDefault(customer => customer.CustomerName == "Joe");
         Assert.Null(result);
     }
 }
Example #14
0
 public void CreateLocationShouldCreateLocation()
 {
     using (var context = new Entity.StoreDBContext(options))
     {
         IStoreRepository _repo = new StoreRepoDB(context, new StoreMapper());
         _repo.CreateLocation
         (
             new Model.Location
         {
             LocationName    = "Mandrakes R US",
             LocationAddress = "69 Floral Dr."
         }
         );
     }
     using (var assertContext = new Entity.StoreDBContext(options))
     {
         var result = assertContext.Locations.FirstOrDefault(location => location.LocationName == "Mandrakes R US");
         Assert.NotNull(result);
         Assert.Equal("Mandrakes R US", result.LocationName);
     }
 }
 public ProductRepoDB(Entity.StoreDBContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #16
0
 public CustomerOrderHistoryRepoDB(Entity.StoreDBContext context, ICustomerOrderHistoryMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
        private void Seed()
        {
            using (var context = new Entity.StoreDBContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                context.Customers.AddRange
                (
                    new Entity.Customer
                {
                    CustId      = 0,
                    FirstName   = "Jack",
                    LastName    = "Long",
                    PhoneNumber = "123-444-5678"
                },
                    new Entity.Customer
                {
                    CustId      = 1,
                    FirstName   = "Tom",
                    LastName    = "Brady",
                    PhoneNumber = "145-464-5690"
                }
                );

                context.Locations.AddRange
                (
                    new Entity.Location
                {
                    LocationId   = 0,
                    Address      = "123 Way",
                    State        = "VA",
                    LocationName = "Ski Store"
                },
                    new Entity.Location
                {
                    LocationId   = 1,
                    Address      = "42 Way",
                    State        = "VA",
                    LocationName = "Ski Buy"
                }
                );
                context.Products.AddRange
                (
                    new Entity.Product
                {
                    ProductId   = 0,
                    ProductName = "Skis",
                    Price       = 22,
                    Description = "They are skis"
                },
                    new Entity.Product
                {
                    ProductId   = 1,
                    ProductName = "Boots",
                    Price       = 10,
                    Description = "They are boots"
                }
                );
                context.Items.AddRange
                (
                    new Entity.Item
                {
                    ItemId     = 0,
                    Quantity   = 20,
                    ProductId  = 1,
                    LocationId = 1
                },
                    new Entity.Item
                {
                    ItemId     = 1,
                    Quantity   = 10,
                    ProductId  = 0,
                    LocationId = 0
                }
                );
                context.SaveChanges();
            }
        }
Example #18
0
 public LocationRepoDB(Entity.StoreDBContext context, ILocationMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public CustomerRepoDB(Entity.StoreDBContext context, ICustomerMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public OrderRepoDB(Entity.StoreDBContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #21
0
        private void Seed()
        {
            using (var context = new Entity.StoreDBContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                context.Customers.AddRange
                (
                    new Entity.Customer
                {
                    Id            = 1,
                    CustomerName  = "Joe",
                    CustomerEmail = "*****@*****.**"
                },
                    new Entity.Customer
                {
                    Id            = 2,
                    CustomerName  = "Sally",
                    CustomerEmail = "*****@*****.**"
                }
                );
                context.Locations.AddRange
                (
                    new Entity.Location
                {
                    Id              = 1,
                    LocationName    = "Bats and Brews",
                    LocationAddress = "55 Bat Dr."
                },
                    new Entity.Location
                {
                    Id              = 2,
                    LocationName    = "Goblin's and Ghouls",
                    LocationAddress = "42 Universe St"
                }
                );
                context.Products.AddRange
                (
                    new Entity.Product
                {
                    Id           = 1,
                    ProductName  = "Eye of Newt",
                    ProductPrice = 1
                },
                    new Entity.Product
                {
                    Id           = 2,
                    ProductName  = "Bat Wool",
                    ProductPrice = 3
                },
                    new Entity.Product
                {
                    Id           = 3,
                    ProductName  = "Mandrake",
                    ProductPrice = 12
                }
                );
                context.Inventories.AddRange
                (
                    new Entity.Inventory
                {
                    Id = 1,
                    InventoryProduct  = 1,
                    InventoryLocation = 1,
                    Quantity          = 12
                },
                    new Entity.Inventory
                {
                    Id = 2,
                    InventoryProduct  = 2,
                    InventoryLocation = 1,
                    Quantity          = 9
                },
                    new Entity.Inventory
                {
                    Id = 3,
                    InventoryProduct  = 3,
                    InventoryLocation = 1,
                    Quantity          = 3
                },
                    new Entity.Inventory
                {
                    Id = 4,
                    InventoryProduct  = 1,
                    InventoryLocation = 2,
                    Quantity          = 5
                },
                    new Entity.Inventory
                {
                    Id = 5,
                    InventoryProduct  = 2,
                    InventoryLocation = 2,
                    Quantity          = 10
                },
                    new Entity.Inventory
                {
                    Id = 6,
                    InventoryProduct  = 3,
                    InventoryLocation = 2,
                    Quantity          = 5
                }
                );
                context.SaveChanges();
            }
        }
Example #22
0
 public CustomerOrderLineItemRepoDB(Entity.StoreDBContext context, ICustomerOrderLineItemMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #23
0
 public InventoryLineItemRepoDB(Entity.StoreDBContext context, IInventoryLineItemMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public InventoryRepoDB(Entity.StoreDBContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }