public void SetUp() { _eventAggregator = Substitute.For <IEventAggregator>(); _application = Substitute.For <IApplication>(); _carProfileDataEvent = Substitute.For <CarProfileDataEvent>(); _eventAggregator.GetEvent <CarProfileDataEvent>().Returns(_carProfileDataEvent); _uut = new SearchResultItemViewModel(_eventAggregator, _application); }
public void Setup() { _user = new UserModel(); var possibleDates = new List <PossibleToRentDayModel>(); var alreadyRentedDates = new List <DayThatIsRentedModel>(); for (var date = _startDate; date <= _startDate.AddMonths(1); date = date.AddDays(1)) { possibleDates.Add(new PossibleToRentDayModel() { CarProfile = _car, Date = date }); if (date <= _startDate.AddDays(6)) { alreadyRentedDates.Add(new DayThatIsRentedModel() { Renter = _user, CarProfileModel = _car, Date = date }); } } _uutCarModel = new CarProfileModel { CarEquipment = new CarEquipment { AudioPlayer = true, ChildSeat = false, Gps = true, Smoking = false }, Model = "Mustang", Brand = "Ford", Age = 2010, CarDescription = "Bilen har kun været brugt 5 gange i løbet af de 10 år jeg har eget den, så den er så god som ny.", Owner = new UserModel() { Email = "*****@*****.**" }, RegNr = "1107959", RentalPrice = 5000, FuelType = "Premium91", Seats = 5, Price = 200000, Location = "Århus", StartLeaseTime = new DateTime(2019, 4, 25), EndLeaseTime = new DateTime(2019, 5, 25), PossibleToRentDays = possibleDates, DayThatIsRented = alreadyRentedDates }; _car = new CarProfileModel() { Model = "Mustang", Brand = "Ford", Age = 2010, CarDescription = "Bilen har kun været brugt 5 gange i løbet af de 10 år jeg har eget den, så den er så god som ny.", Owner = new UserModel() { Address = "Århus", Email = "*****@*****.**", FirstName = "Martin", LastName = "Jespersen", }, RegNr = "1107959", RentalPrice = 5000, FuelType = "Premium91", Seats = 5, Price = 200000, Location = "Århus", PossibleToRentDays = possibleDates, DayThatIsRented = alreadyRentedDates //StartLeaseTime = new DateTime(2019, 4, 25), mangler i database //EndLeaseTime = new DateTime(2019, 5, 25) mangler i database }; _event = Substitute.For <IEventAggregator>(); _application = Substitute.For <IApplication>(); _dbContext = Substitute.For <IQueryDatabase>(); _helper = Substitute.For <ISendRequestViewModelHelperFunction>(); _dataEvent = Substitute.For <CarProfileDataEvent>(); _event.GetEvent <CarProfileDataEvent>().Returns(_dataEvent); //EventAggregator events=new EventAggregator(); _uut = new CarnGo.SendRequestViewModel(_event, _application, _dbContext, _helper); _uut.Car = _uutCarModel; _dbContext.GetCarProfileTask(Arg.Any <string>()).Returns(_car); _application.CurrentUser.Returns(_uutCarModel.Owner); }