Exemplo n.º 1
0
        public void RentCarFunction_AddDayThatIsRentedIsCalled_WithCorrectListArgument()
        {
            _uut.To      = new DateTime(DateTime.Today.Year + 2, DateTime.Today.Month, DateTime.Today.Day);
            _uut.From    = new DateTime(DateTime.Today.Year + 1, DateTime.Today.Month, DateTime.Today.Day);
            _uut.Message = "Unittest";
            _helper.ConfirmRentingDates(Arg.Any <CarProfileModel>(), Arg.Any <DateTime>(), Arg.Any <DateTime>(), ref Arg.Any <string>()).Returns(true);
            var list = new List <DayThatIsRentedModel>();

            _helper.CreateDayThatIsRentedList(Arg.Any <DateTime>(), Arg.Any <DateTime>(), Arg.Any <CarProfileModel>(), Arg.Any <UserModel>())
            .Returns(list);

            _uut.RentCarCommand.Execute(null);

            _dbContext.Received(1).UpdateCarProfileTask(Arg.Is(_uutCarModel));
        }
        public void CreateDayThatIsRentedList_FromStartDateToAWeekAfter_CorrectList()
        {
            var checkList = new List <DayThatIsRentedModel>();
            var user      = new UserModel();

            for (var date = _startDate; date <= _startDate.AddDays(6); date = date.AddDays(1))
            {
                checkList.Add(new DayThatIsRentedModel()
                {
                    CarProfileModel = _car, Date = date
                });
            }
            DateTime from = _startDate;
            DateTime to   = from.AddDays(6);
            var      list = _helper.CreateDayThatIsRentedList(from, to, _car, user);

            Assert.True(((list[0].Date == checkList[0].Date) && (list[6].Date == checkList[6].Date) &&
                         (list[0].CarProfileModel == checkList[0].CarProfileModel) && (list[6].CarProfileModel == checkList[6].CarProfileModel) &&
                         (list.Count == checkList.Count)));
        }