public async Task Calculate_Values_Correctly()
        {
            // Arrange
            mockRepo.Setup(x => x.GetTrafficInfoAsync(
                               It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(GetMockEntity());

            DateTime timeOfArrival = DateTime.Now.AddSeconds(Duration);

            // Act
            TrafficModel model = await _service.GetTrafficModelAsync(Origin, Destination);

            // Assert
            Assert.Equal(122.31, model.Distance);
            Assert.Equal(DistanceUom.Metric, model.DistanceUom);
            Assert.Equal(timeOfArrival.Hour, model.TimeOfArrival.Hour);
            Assert.Equal(timeOfArrival.Minute, model.TimeOfArrival.Minute);
        }
Exemple #2
0
        private async Task <TrafficModel> GetTrafficModelAsync(string origin, string destination)
        {
            if (string.IsNullOrEmpty(origin))
            {
                throw new ArgumentNullException(nameof(origin));
            }

            if (string.IsNullOrEmpty(destination))
            {
                throw new ArgumentNullException(nameof(destination));
            }

            TrafficModel model = await _trafficService.GetTrafficModelAsync(origin, destination);

            return(model);
        }
Exemple #3
0
        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);
        }