Example #1
0
        public void FetchTravelerShipURI_FromRecievedJObject_FetchCorrectShipURI()
        {
            List <string> expectedURIs = new List <string>()
            {
                "https://swapi.co/api/starships/12/", "https://swapi.co/api/starships/22/"
            };

            JObject testObject = JObject.Parse(@"{
            'count': 1, 
            'next': null, 
            'previous': null, 
            'results': [
                {
                    'name': 'Luke Skywalker',                 
                    'starships': [
                        'https://swapi.co/api/starships/12/',
                        'https://swapi.co/api/starships/22/'
                        ]
                    }
                ]
            }");

            StarWarsApi   api        = new StarWarsApi();
            List <string> actualURIs = api.FetchTravelerShipURI(testObject);

            Assert.Equal(expectedURIs, actualURIs);
        }
Example #2
0
        public void FetchTravelerShipURI_FromRecievedJObject_FetchCorrectShipURI()
        {
            string        name         = "Luke SKYWalKeR";
            List <string> expectedURIs = new List <string>()
            {
                "https://swapi.co/api/starships/12/", "https://swapi.co/api/starships/22/"
            };

            StarWarsApi   api        = new StarWarsApi();
            JObject       jObject    = api.GetTravelerDataAsync(name.ToLower()).Result;
            List <string> actualURIs = api.FetchTravelerShipURI(jObject);

            Assert.Equal(expectedURIs, actualURIs);
        }
Example #3
0
        public void GetShipDataAsync_InsertListOfURI_ReturnShipValues()
        {
            string name = "Luke SKYWalKeR";

            Dictionary <string, double> ExpectedShipData = new Dictionary <string, double>();

            ExpectedShipData.Add("X-wing", 12.5);
            ExpectedShipData.Add("Imperial shuttle", 20);

            StarWarsApi   api      = new StarWarsApi();
            JObject       jObject  = api.GetTravelerDataAsync(name.ToLower()).Result;
            List <string> shipURIs = api.FetchTravelerShipURI(jObject);

            Dictionary <string, double> actualShipData = api.GetShipDataAsync(shipURIs).Result;

            Assert.Equal(ExpectedShipData, actualShipData);
        }