static async Task Main(string[] args) { DistanceService dst = new DistanceService(); // Add drone depots await dst.AddDepot("Depot1", "Metrostrasse 12, 40235 Düsseldorf"); await dst.AddDepot("Depot2", "Ludenberger Str. 1, 40629 Düsseldorf"); // Add stores await dst.AddStore("Store1", "Willstätterstraße 24, 40549 Düsseldorf"); await dst.AddStore("Store2", "Bilker Allee 128, 40217 Düsseldorf"); await dst.AddStore("Store3", "Hammer Landstraße 113, 41460 Neuss"); await dst.AddStore("Store4", "Gladbacher Str. 471, 41460 Neuss"); await dst.AddStore("Store5", "Lise-Meitner-Straße 1, 40878 Ratingen"); //C1 DeliveryPlan plan1 = await dst.Calculate("Friedrichstraße 133, 40217 Düsseldorf"); PrintPlan(plan1); //C2 DeliveryPlan plan2 = await dst.Calculate("Fischerstraße 23, 40477 Düsseldorf"); PrintPlan(plan2); //C3 DeliveryPlan plan3 = await dst.Calculate("Wildenbruchstraße 2, 40545 Düsseldorf"); PrintPlan(plan3); //C4 DeliveryPlan plan4 = await dst.Calculate("Reisholzer Str. 48, 40231 Düsseldorf"); PrintPlan(plan4); }
public void ShouldThrowCalculationException_OnCalculate_IfNoCalculator() { // arrange var unitService = new UnitServiceStub(); var service = new DistanceService(new IDistanceCalculator[] { }, unitService); var c1 = new Coordinate { Longitude = 0, Latitude = 0 }; var c2 = new Coordinate { Longitude = 1, Latitude = 1 }; // act and arrange Assert.Throws <CalculationException>(() => service.Calculate(c1, c2)); }
public async Task <DeliveryPlanResult> Get([Required] string address) { DeliveryPlan plan = await _distanceService.Calculate(address); return(new DeliveryPlanResult() { Customer = plan.Customer.Address, Depot = plan.Depot.Address, Store = plan.Store.Address, DeliveryTime = new DeliveryTime() { Minutes = (int)plan.TotalDeliveryTime.TotalMinutes, Seconds = plan.TotalDeliveryTime.Seconds } }); }
public void ShouldNotFail_OnCalculate_IfValidCalculatorExists() { // arrange var calculator1 = new DistanceFailureCalculatorStub(); var calculator2 = new DistanceSuccessCalculatorStub(); var unitService = new UnitServiceStub(); var service = new DistanceService(new IDistanceCalculator[] { calculator1, calculator2 }, unitService); var c1 = new Coordinate { Longitude = 0, Latitude = 0 }; var c2 = new Coordinate { Longitude = 1, Latitude = 1 }; // act var value = service.Calculate(c1, c2); // assert Assert.NotNull(value); Assert.Equal(Units.Meters, value.Units); Assert.Equal(10, value.Value); }