コード例 #1
0
 public void SetUp()
 {
     _user = Substitute.For<IConsumer>();
     _mail = Substitute.For<IMail>();
     _uut = new GeneratedShoppingListModel(_user, _mail);
 }
コード例 #2
0
        public void SetUp()
        {
            _context = new DataContext();
            _unit = new UnitOfWork(_context);

            _context.Database.Connection.ConnectionString =
                "Server=.\\SQLEXPRESS;Database=Pristjek220Data.DataContext; Trusted_Connection=True;MultipleActiveResultSets=True;";
            _context.Database.ExecuteSqlCommand("dbo.TestCleanTable");

            var store = new Store() {StoreName = "TestStore"};
            var store2 = new Store() { StoreName = "TestStore2" };
            _context.Stores.Add(store);
            _context.Stores.Add(store2);
            _context.SaveChanges();

            _product = new Product() {ProductName = "Test"};
            _product2 = new Product() {ProductName = "Test2"};
            var hasA = new HasA() {Price = 4, Product = _product, Store = store};
            var hasA2 = new HasA() {Price = 6, Product = _product2, Store = store};
            var hasA3 = new HasA() { Price = 5, Product = _product, Store = store2 };

            _context.Products.Add(_product);
            _context.Products.Add(_product2);
            _context.HasARelation.Add(hasA2);
            _context.HasARelation.Add(hasA);
            _context.HasARelation.Add(hasA3);
            _context.SaveChanges();

            _consumer = new global::Consumer.Consumer(_unit);
            _mail = Substitute.For<IMail>();
            _autocomplete = new Autocomplete(_unit);
            _generatedShoppingList = new GeneratedShoppingListModel(_consumer, _mail);
            _shoppingList = new ShoppingListModel(_consumer, _autocomplete);
            _findProduct = new FindProductModel(_consumer, _autocomplete);

            _shoppingList.ClearShoppingListCommand.Execute(this);
        }