public SearchViewModel(IEventAggregator eventAggregator, IApplication application, ISearchViewModelHelper helper, ISearchQueries dbContext) { _application = application; _helper = helper; _dbContext = dbContext; _eventAggregator = eventAggregator; DateFrom = DateTime.Today; DateTo = DateTime.Today; PageIndex = 0; _itemsPerPage = 10; _criteria = new List <Predicate <SearchResultItemViewModel> >(); _searchResultItems = new ObservableCollection <SearchResultItemViewModel>(); _eventAggregator.GetEvent <SearchEvent>().Subscribe(SearchEventHandler); _eventAggregator.GetEvent <InitializeSearchResultItemsEvent>().Subscribe(InitializeSearchResultItems); }
public void SetUp() { _eventAggregator = Substitute.For <IEventAggregator>(); _application = Substitute.For <IApplication>(); _dbContext = Substitute.For <ISearchQueries>(); _helper = Substitute.For <ISearchViewModelHelper>(); _initializeSearchResultItemsEvent = Substitute.For <InitializeSearchResultItemsEvent>(); _searchEvent = new SearchEvent(); _eventAggregator.GetEvent <SearchEvent>().Returns(_searchEvent); _eventAggregator.GetEvent <InitializeSearchResultItemsEvent>().Returns(_initializeSearchResultItemsEvent); _uut = new SearchViewModel(_eventAggregator, _application, _helper, _dbContext); _today = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day); _uut.SearchResultItems.Clear(); UserModel jensJensen = new UserModel { FirstName = "Jens", LastName = "Jensen", Address = "Finlandsgade 1", Email = "*****@*****.**", UserType = UserType.Lessor }; _car1 = new SearchResultItemViewModel(_eventAggregator, _application) { Model = "CLA 250", Brand = "Mercedes", Location = "Aarhus", RegNr = "AF75903", Seats = 2, Price = 400, StartLeaseTime = _today, EndLeaseTime = _today.AddMonths(1), Owner = jensJensen, }; _car2 = new SearchResultItemViewModel(_eventAggregator, _application) { Model = "Model S", Brand = "Tesla", Location = "Odense", RegNr = "AF75903", Seats = 5, Price = 600, StartLeaseTime = _today.AddMonths(1), EndLeaseTime = _today.AddMonths(2), Owner = jensJensen }; _car3 = new SearchResultItemViewModel(_eventAggregator, _application) { Model = "Berlingo", Brand = "Citroen", Location = "Copenhagen", RegNr = "AF75903", Seats = 5, Price = 200, StartLeaseTime = _today.AddMonths(2), EndLeaseTime = _today.AddMonths(3), Owner = jensJensen }; _uut.SearchResultItems.Add((SearchResultItemViewModel)_car1); _uut.SearchResultItems.Add((SearchResultItemViewModel)_car2); _uut.SearchResultItems.Add((SearchResultItemViewModel)_car3); }
public SearchDesignModel(IEventAggregator eventAggregator, IApplication application, ISearchViewModelHelper helper, ISearchQueries dbContext) : base(eventAggregator, application, helper, dbContext) { UserModel jensJensen = new UserModel { FirstName = "Jens", LastName = "Jensen", Address = "Finlandsgade 1", Email = "*****@*****.**", UserType = UserType.Lessor }; SearchResultItems = new ObservableCollection <SearchResultItemViewModel> { new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "CLA 250", Brand = "Mercedes", Location = "Aarhus", RegNr = "AF75903", Seats = 2, Price = 400, StartLeaseTime = new DateTime(2019, 07, 07), EndLeaseTime = new DateTime(2019, 08, 07), Owner = jensJensen, }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "CLA 250", Brand = "Mercedes", Location = "Aarhus", RegNr = "AF75903", Seats = 2, Price = 400, StartLeaseTime = new DateTime(2019, 12, 01), EndLeaseTime = new DateTime(2019, 12, 15), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "Model S", Brand = "Tesla", Location = "Aarhus", RegNr = "AF75903", Seats = 5, Price = 600, StartLeaseTime = new DateTime(2019, 09, 01), EndLeaseTime = new DateTime(2019, 09, 15), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "Fortwo", Brand = "Smart", Location = "Padborg", RegNr = "AF75903", Seats = 2, Price = 150, StartLeaseTime = new DateTime(2019, 10, 01), EndLeaseTime = new DateTime(2019, 10, 30), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "CLA 250", Brand = "Mercedes", Location = "Aarhus", RegNr = "AF75903", Seats = 2, Price = 400, StartLeaseTime = new DateTime(2019, 06, 05), EndLeaseTime = new DateTime(2019, 06, 20), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "CLA 250", Brand = "Mercedes", Location = "Aarhus", RegNr = "AF75903", Seats = 2, Price = 400, StartLeaseTime = new DateTime(2019, 04, 25), EndLeaseTime = new DateTime(2019, 5, 17), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "Berlingo", Brand = "Citroen", Location = "Aarhus", RegNr = "AF75903", Seats = 5, Price = 200, StartLeaseTime = new DateTime(2019, 05, 01), EndLeaseTime = new DateTime(2019, 05, 30), Owner = jensJensen }, new SearchResultItemViewModel(IoCContainer.Resolve <IEventAggregator>(), IoCContainer.Resolve <IApplication>()) { Model = "A6", Brand = "Audi", Location = "Odense", RegNr = "AF75903", Seats = 5, Price = 200, StartLeaseTime = new DateTime(2019, 05, 03), EndLeaseTime = new DateTime(2019, 05, 17), Owner = jensJensen }, }; }