public void ReturnDelayed_Confirmed()
        {
            //arrange
            _view.ConfirmReturnDelayed().Returns(true); // юзер соглашается "Вернуть фильм"

            var testMovieCopy = new MovieCopy(9999, "TEST COMMENT", 50)
            {
                Available = false
            };                                                                               // копия у кого-то в аренде

            // взяли 20 января, договорились вернуть 25, но вернули 28
            var startDate       = new DateTime(2020, 01, 20);
            var expectedEndDate = new DateTime(2020, 01, 25);
            var returnDate      = new DateTime(2020, 01, 28);
            var testLeasing     = new Leasing(startDate, expectedEndDate, 0, 0, 50)
            {
                MovieCopy = testMovieCopy
            };

            _view.CurrentLeasing = testLeasing;

            const decimal fineMultiplier = 2;

            testLeasing.ReturnDelayed(returnDate);

            //act
            _presenter.ReturnDelayed(returnDate, fineMultiplier);

            //assert
            Assert.AreEqual(testLeasing.TotalPrice, _view.CurrentLeasing.TotalPrice);
            Assert.AreEqual(testLeasing.MovieCopy.Available, _view.CurrentLeasing.MovieCopy.Available);
            Assert.AreEqual(testLeasing.ReturnDate, _view.CurrentLeasing.ReturnDate);

            _view.Received().Close();
        }
Example #2
0
        public void ReturnDelayed(DateTime returnDate, decimal fineMultiplier)
        {
            if (!_returnView.ConfirmReturnDelayed())
            {
                return;
            }
            var leasing = _returnView.CurrentLeasing;

            leasing.ReturnDelayed(returnDate, fineMultiplier);

            _context.SaveChanges();
            _returnView.Close();
        }