Beispiel #1
0
        public void IssApiResponseShouldNotBeNull()
        {
            //Arrange
            IAPIMapperService mapperService = new APIMapperService();

            //Act
            Action mapped = () => mapperService.Map(null);

            //Assert
            mapped.Should().Throw <ArgumentException>();
        }
        public void TestNullIssApiResponse()
        {
            //Arrange
            IssApiResponse   apiResult        = null;
            APIMapperService apiMapperservice = new APIMapperService();

            //Act
            Func <PointLatLng> action = () => apiMapperservice.Map(apiResult);

            //Assert
            action.Should().Throw <ArgumentException>().WithMessage("*cannot be null");
        }
Beispiel #3
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();
        }
Beispiel #4
0
        public void CoordinatesShouldBeValid()
        {
            //Arrange
            IAPIMapperService mapperService = new APIMapperService();

            IssApiResponse response = new IssApiResponse();

            response.iss_position           = new IssPosition();
            response.iss_position.latitude  = "95.0";
            response.iss_position.longitude = "160.0";

            //Act
            Action mapped = () => mapperService.Map(response);

            //Assert
            mapped.Should().Throw <ArgumentException>();
        }
        public void TestOutOfBoundsCoordinates(string latitude, string longitude)
        {
            //Arrange
            IssApiResponse apiResult = new IssApiResponse()
            {
                iss_position = new IssPosition()
                {
                    latitude = latitude, longitude = longitude
                }
            };
            APIMapperService apiMapperservice = new APIMapperService();

            //Act
            Func <PointLatLng> action1 = () => apiMapperservice.Map(apiResult);

            //Assert
            action1.Should().Throw <ArgumentException>().WithMessage("Coordinates*are out of bounds");
        }
        public void TestCoordinatesNotConvertible(string latitude, string longitude)
        {
            //Arrange
            IssApiResponse apiResult = new IssApiResponse()
            {
                iss_position = new IssPosition()
                {
                    latitude = latitude, longitude = longitude
                }
            };
            APIMapperService apiMapperservice = new APIMapperService();

            //Act
            Func <PointLatLng> action1 = () => apiMapperservice.Map(apiResult);

            //Assert
            action1.Should().Throw <FormatException>();
        }
        public void TestValidCoordinates(string latitude, string longitude, double expectedLatitude, double expectedLongitude)
        {
            //Arrange
            IssApiResponse apiResult = new IssApiResponse()
            {
                iss_position = new IssPosition()
                {
                    latitude = latitude, longitude = longitude
                }
            };
            APIMapperService apiMapperservice = new APIMapperService();

            //Act
            PointLatLng result = apiMapperservice.Map(apiResult);

            //Assert
            result.Lat.Should().Be(expectedLatitude);
            result.Lng.Should().Be(expectedLongitude);
        }
Beispiel #8
0
        public void TestConversionIsFine()
        {
            //Arrange
            IAPIMapperService mapperService = new APIMapperService();

            IssApiResponse response = new IssApiResponse();

            response.iss_position           = new IssPosition();
            response.iss_position.latitude  = "80.0";
            response.iss_position.longitude = "160.0";

            //Act
            PointLatLng mapped = mapperService.Map(response);

            //Assert
            mapped.Should().NotBeNull();
            mapped.Lat.Should().Be(80);
            mapped.Lng.Should().Be(160);
        }
        public void TestNotWellFormedIssApiResponse(bool nullIssPosition, string latitude, string longitude)
        {
            //Arrange
            IssApiResponse apiResult = new IssApiResponse();

            if (!nullIssPosition)
            {
                apiResult.iss_position = new IssPosition()
                {
                    latitude = latitude, longitude = longitude
                };
            }

            APIMapperService apiMapperservice = new APIMapperService();

            //Act
            Func <PointLatLng> action1 = () => apiMapperservice.Map(apiResult);

            //Assert
            action1.Should().Throw <ArgumentException>().WithMessage("*is not well formed");
        }