public void ReturnEarly_Confirmed() { //arrange _view.ConfirmReturnEarly().Returns(true); // юзер соглашается "Вернуть фильм" var testMovieCopy = new MovieCopy(9999, "TEST COMMENT", 50) { Available = false }; // копия у кого-то в аренде // взяли 20 января, договорились вернуть 25, но вернули 23 var startDate = new DateTime(2020, 01, 20); var expectedEndDate = new DateTime(2020, 01, 25); var returnDate = new DateTime(2020, 01, 23); var testLeasing = new Leasing(startDate, expectedEndDate, 0, 0, 50) { MovieCopy = testMovieCopy }; _view.CurrentLeasing = testLeasing; testLeasing.ReturnEarly(returnDate); //act _presenter.ReturnEarly(returnDate); //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(); }
public void ReturnEarly(DateTime returnDate) { if (!_returnView.ConfirmReturnEarly()) { return; } var leasing = _returnView.CurrentLeasing; leasing.ReturnEarly(returnDate); _context.SaveChanges(); _returnView.Close(); }