public virtual ActionResult Index(string calendarId, int year, int month) { try { var calendarService = this.GetAgendaService(); var importer = new AgendaImporter(calendarService); var events = importer.GetEventsModel(calendarId); var locationOptimizer = new LocationOptimizer(); events = locationOptimizer.OptimizeLocations(events); var start = new DateTime(year, month, 1); var end = start.AddMonths(1); var eventsOfSelectedMonth = events.Where(e => e.Start >= start && e.End <= end); var routes = routeCalculator.CalculateRoutes(eventsOfSelectedMonth, "Van koetsveldstraat 39, Utrecht"); var model = routeCalculator.CalculateTravelCosts(routes); return(View(model)); } catch (NoAuthenticatorException) { return(RedirectToRoute("GoogleAuthentication", new { callbackurl = Request.Url })); } }
public void Optimizer_copies_location_if_summary_is_equal() { var events = GetEvents(); var optimizer = new LocationOptimizer(); var optimizedEvents = optimizer.OptimizeLocations(events); Assert.AreEqual(events.First().Location, optimizedEvents.ElementAt(1).Location); Assert.AreEqual("", optimizedEvents.ElementAt(2).Location); Assert.AreEqual(events.Count, optimizedEvents.Count()); }