Example #1
0
 public void AddCustomer(Customer customer)
 {
     if (!_customersView.ConfirmNewCustomer())
     {
         return;
     }
     _context.Customers.Add(customer);
     _context.SaveChanges();
     _customersView.RedrawCustomers(_context.Customers);
 }
        public void UpdateMovie(int movieId, MovieOriginal updatedMovie)
        {
            var movie = _context.MoviesOriginal.Single(m => m.Id == movieId);

            movie.Description  = updatedMovie.Description;
            movie.Title        = updatedMovie.Title;
            movie.YearReleased = updatedMovie.YearReleased;

            _context.SaveChanges();

            _mainView.RedrawMovies(_context.MoviesOriginal);
        }
Example #3
0
        public void ReturnEarly(DateTime returnDate)
        {
            if (!_returnView.ConfirmReturnEarly())
            {
                return;
            }
            var leasing = _returnView.CurrentLeasing;

            leasing.ReturnEarly(returnDate);

            _context.SaveChanges();
            _returnView.Close();
        }
Example #4
0
 public void AddMovie(MovieOriginal movie)
 {
     if (!_movieView.ConfirmNewMovie())
     {
         return;
     }
     _context.MoviesOriginal.Add(movie);
     _context.SaveChanges();
     _movieView.Close();
 }
        public void Run()
        {
            //arrange
            // добавляем и сразу же сохраняем по цепочке чтобы последующие элементы получили актуальное значение необходимого Id
            var testMovie = new MovieOriginal("TEST TITLE", "TEST DESCR", 9999);

            _context.MoviesOriginal.Add(testMovie);
            _context.SaveChanges();
            var testMovieCopy = new MovieCopy(testMovie.Id, "TEST COMMENT", 9999);

            _context.MoviesCopies.Add(testMovieCopy);
            _context.SaveChanges();
            var testCustomer = new Customer("TEST NAME");

            _context.Customers.Add(testCustomer);
            _context.SaveChanges();
            var testLeasing = new Leasing(DateTime.Now, DateTime.Now, testCustomer.Id, testMovieCopy.Id, 9999);

            _context.LeasedCopies.Add(testLeasing);
            _context.SaveChanges();

            //act
            _presenter.Run(testLeasing.Id);

            //assert
            Assert.AreEqual(testLeasing.StartDate, _view.CurrentLeasing.StartDate);
            Assert.AreEqual(testLeasing.ExpectedEndDate, _view.CurrentLeasing.ExpectedEndDate);
            Assert.AreEqual(testLeasing.CustomerId, _view.CurrentLeasing.CustomerId);
            Assert.AreEqual(testLeasing.MovieCopyId, _view.CurrentLeasing.MovieCopyId);
            Assert.AreEqual(testLeasing.TotalPrice, _view.CurrentLeasing.TotalPrice);

            Assert.AreEqual(testMovieCopy.MovieId, _view.CurrentMovieCopy.MovieId);
            Assert.AreEqual(testMovieCopy.Commentary, _view.CurrentMovieCopy.Commentary);
            Assert.AreEqual(testMovieCopy.PricePerDay, _view.CurrentMovieCopy.PricePerDay);

            Assert.AreEqual(testMovie.Title, _view.CurrentMovie.Title);
            Assert.AreEqual(testMovie.Description, _view.CurrentMovie.Description);
            Assert.AreEqual(testMovie.YearReleased, _view.CurrentMovie.YearReleased);

            Assert.AreEqual(testCustomer.Name, _view.CurrentCustomer.Name);

            _view.Received().Show();
        }
Example #6
0
        public void AddMovieCopy(MovieCopy movieCopy)
        {
            if (!_movieCopyView.ConfirmNewMovieCopy())
            {
                return;
            }
            _context.MoviesCopies.Add(movieCopy);
            _context.SaveChanges();

            _movieCopyView.Close();
        }
Example #7
0
        public void LeasingAdd_Confirmed()
        {
            //arrange
            _view.ConfirmNewLeasing().Returns(true); // юзер соглашается "Подтвердить нового пользователя" (MessageBox)

            var testMovieCopy = new MovieCopy(9999, "TEST", 9999);

            _context.MoviesCopies.Add(testMovieCopy);
            _context.SaveChanges();

            var testLeasing = new Leasing(DateTime.Now, DateTime.Now, 9999, testMovieCopy.Id, 9999);

            //act
            _presenter.AddLeasing(testLeasing);

            //assert
            Assert.AreEqual(false, testMovieCopy.Available);
            Assert.AreEqual(true, _context.LeasedCopies.Any());
            _view.Received().Close();
        }
        public void AddLeasing(Leasing leasing)
        {
            if (!_leasingView.ConfirmNewLeasing())
            {
                return;
            }
            var movieCopy = _context.MoviesCopies.Single(c => c.Id == leasing.MovieCopyId);

            movieCopy.Available = false;
            _context.LeasedCopies.Add(leasing);
            _context.SaveChanges();
            _leasingView.Close();
        }
Example #9
0
        public void UploadMovies()
        {
            if (!_importMoviesView.ConfirmUploadMovies())
            {
                return;
            }
            foreach (var movie in MoviesList)
            {
                _context.MoviesOriginal.Add(movie);
            }

            _context.SaveChanges();
            _importMoviesView.Close();
        }
        public void CustomerUpdate()
        {
            // arrange
            var initialCustomer = new Customer("Initial Customer", 50);

            _context.Customers.Add(initialCustomer);
            _context.SaveChanges();
            var updatedCustomer = new Customer("Updated Customer Name", 99);

            //act
            _presenter.UpdateCustomer(initialCustomer.Id, updatedCustomer);

            //assert
            Assert.AreEqual(initialCustomer.Name, updatedCustomer.Name);
            Assert.AreEqual(initialCustomer.Rating, initialCustomer.Rating);
        }
        public void OpenMovieCopy()
        {
            //arrange
            var testMovie = new MovieOriginal("TEST", "TEST", 9999);

            _context.MoviesOriginal.Add(testMovie);
            _context.MoviesCopies.Add(new MovieCopy(9999, "TEST", 9999));
            _context.SaveChanges();

            //act
            _presenter.OpenMovieCopy(testMovie.Id);

            //assert
            _movieCopyPresenter.Received().Run(Arg.Any <MovieOriginal>());
            _view.Received().RedrawCopies(Arg.Any <IQueryable <MovieCopy> >());
        }