public void CalculateSpeedTest()
        {
            //Arrange
            long         timeDiff     = 3600;
            SpeedService speedService = new SpeedService();

            //IDistanceService distanceService = new DistanceService();
            PointLatLng nortPole           = new PointLatLng(90, 0);
            PointLatLng greenwichOnEquator = new PointLatLng(0, 0);

            var distanceServiceMock = new Mock <IDistanceService>();

            distanceServiceMock
            .Setup(ds => ds.CalculateDistanceBetweenPoints(nortPole, greenwichOnEquator, 6376500, 412000))
            .Returns(10000000);

            var distanceService = distanceServiceMock.Object;

            double distance      = distanceService.CalculateDistanceBetweenPoints(nortPole, greenwichOnEquator) / 1000;
            double expectedSpeed = 10000;

            //Act
            double speed = speedService.CalculateSpeed(distance, timeDiff);

            //Assert
            speed.Should().Be(expectedSpeed);
        }
        public void TestCalculateSpeed(double distance, long timeDiff, double expectedSpeed)
        {
            //Arrange
            SpeedService speedService = new SpeedService();

            //Act
            double speed = speedService.CalculateSpeed(distance, timeDiff);

            //Assert
            speed.Should().Be(expectedSpeed);
        }
        public void TestInvalidNegativeOrZeroValues(double distance, long timeDiff)
        {
            //Arrange
            SpeedService speedService = new SpeedService();

            //Act
            Action action = () => speedService.CalculateSpeed(distance, timeDiff);

            //Assert
            action.Should().Throw <ArgumentException>().WithMessage($"Invalid value of*for parameter*");
        }
示例#4
0
        private void BtnStartTracking_Click(object sender, EventArgs e)
        {
            HttpClient        client          = new HttpClient();
            string            url             = ConfigurationManager.AppSettings["ISSApiURL"];
            ITrackerService   trackerService  = new TrackerService(client, url);
            IMapService       mapService      = new MapService();
            IAPIMapperService converter       = new APIMapperService();
            IDistanceService  distanceService = new DistanceService();
            ISpeedService     speedService    = new SpeedService();

            MapForm map = new MapForm(trackerService, mapService, converter, distanceService, speedService);

            map.Show();
        }