private TrafficEntity GetMockEntity() { var element = new Element { Distance = new Distance { Value = Distance }, Duration = new Duration { Value = Duration } }; var entity = new TrafficEntity { Origin_addresses = new[] { Origin }, Destination_addresses = new[] { Destination }, Rows = new[] { new Row { Elements = new [] { element } } } }; return(entity); }
public async Task <TrafficModel> GetTrafficModelAsync(string origin, string destination) { TrafficEntity entity = await _repo.GetTrafficInfoAsync(origin, destination); TrafficModel model = MapFromEntity(entity); return(model); }
public void Can_Map_From_Entity() { // Arrange TrafficEntity entity = GetMockEntity(); // Act _model = _service.MapFromEntity(entity); // Assert Assert.Equal(Distance, _model.Distance); Assert.Equal(Duration, _model.Duration); Assert.Equal(Destination, _model.Destination); Assert.Equal(Origin, _model.Origin); }
public async Task Can_Convert_Json_To_Entity() { // Act TrafficEntity result = await _repo.GetEntityAsync(); // Assert Assert.NotNull(result); Assert.NotEqual("NOT_FOUND", result.Status); Assert.NotEqual("ZERO_RESULTS", result.Status); Assert.Equal("OK", result.Status); Assert.NotEqual(0, result.Routes.Count); Assert.NotNull(result.Routes[0].Legs[0].Duration); Assert.NotEqual(0, result.Routes[0].Legs[0].Duration.Value); }
public async Task Can_Retrieve_Traffic_Data() { // Arrange TrafficEntity entity = null; string start = "London, UK"; string destination = "Brighton, UK"; // Act entity = await _repo.GetTrafficInfoAsync(start, destination); // Assert Assert.NotNull(entity); Assert.Equal("OK", entity.Status); }
public async Task Calculate_Values_Correctly() { // Arrange TrafficEntity entity = GetMockEntity(); DateTime timeOfArrival = DateTime.Now.AddSeconds(Duration); // Act TrafficModel model = await _service.GetTrafficModelAsync(Origin, Destination); model.InitializeModel(); // Assert Assert.Equal(122.31, model.Distance); Assert.Equal(timeOfArrival.Hour, model.TimeOfArrival.Hour); Assert.Equal(timeOfArrival.Minute, model.TimeOfArrival.Minute); }
/// <summary> /// 仅仅初始化不做赋值 /// </summary> /// <param name="roadE"></param> /// <param name="ce"></param> public RunCtx(TrafficEntity te, Cell ce) { Out = new RunCtxParam(); this.Container = te; }
public void GetRunCtx(TrafficEntity way) { }