public void Constructor_setWithUnitOfWork_()
 {
     _unitWork = Substitute.For<IUnitOfWork>();
     _uut = new DatabaseFunctions(_unitWork);
     _uut.ConnectToDb();
     _unitWork.Products.Received(1).ConnectToDb();
 }
 public void SetUp()
 {
     _context = new DataContext();
     _unit = new UnitOfWork(_context);
     _databaseFunctions = new DatabaseFunctions(_unit);
     _context.Database.Connection.ConnectionString = "Server=.\\SQLEXPRESS;Database=Pristjek220Data.DataContext; Trusted_Connection=True;";
     _context.Database.ExecuteSqlCommand("dbo.TestCleanTable");
 }
        public void SetUp()
        {
            _logIn = Substitute.For<ILogIn>();
            _autocomplete = Substitute.For<IAutocomplete>();
            _storemanager = Substitute.For<IStoremanager>();
            _admin = Substitute.For<IAdmin>();
            _databaseFunctions = Substitute.For<IDatabaseFunctions>();

            _databaseFunctions.ConnectToDb().Returns(true);
            _uut = new LogInViewModel(_autocomplete, _logIn, _databaseFunctions, _storemanager, _admin);
        }
        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");

            _databaseFunctions = new DatabaseFunctions(_unit);

            _consumerView = new ConsumerViewModel(new global::Consumer.Consumer(_unit), new Autocomplete(_unit), _databaseFunctions  );
        }
        /// <summary>
        ///     ConsumerViewModel constructor creates a Consumer, adds the user controlls to a list and connects to the database 
        /// </summary>
        public ConsumerViewModel(IConsumer user, IAutocomplete autocomplete, IDatabaseFunctions databaseFunctions)
        {
            // Add available pages
            PageViewModels.Add(new HomeModel());
            PageViewModels.Add(new FindProductModel(user, autocomplete));
            PageViewModels.Add(new ShoppingListModel(user, autocomplete));
            PageViewModels.Add(new GeneratedShoppingListModel(user,
                new Mail(new SmtpClientWrapper("Smtp.gmail.com", 587,
                    new NetworkCredential("[email protected]", "pristjek"), true))));

            if (!databaseFunctions.ConnectToDb())
                //Force database to connect at startup, and close application if it cant connect
            {
                MessageBox.Show("Der kan ikke tilsluttes til serveren", "ERROR", MessageBoxButton.OK);
                Application.Current.MainWindow.Close();
            }

            // Set starting page
            MainWindowTekst = "Pristjek220 - Forbruger - Startside";
            CurrentPageViewModel = PageViewModels[0];
        }
 public void SetUp()
 {
     _consumer = Substitute.For<IConsumer>();
     _autocomplete = Substitute.For<IAutocomplete>();
     _databaseFunctions = Substitute.For<IDatabaseFunctions>();
     _databaseFunctions.ConnectToDb().Returns(true);
     _uut = new ConsumerViewModel(_consumer, _autocomplete, _databaseFunctions);
 }