Пример #1
0
        public void GetTravelerDataAsunc_SearchByName_ExpectJObjectReturned(string name)
        {
            StarWarsApi api = new StarWarsApi();

            JObject jObjectReturned = api.GetTravelerDataAsync(name.ToLower()).Result;

            Assert.IsType <JObject>(jObjectReturned);
        }
Пример #2
0
        public void ValidateTraveler_IncorrectInput_ExpectFalse(string name)
        {
            StarWarsApi api     = new StarWarsApi();
            JObject     jObject = api.GetTravelerDataAsync(name.ToLower()).Result;

            bool isTraveler = api.ValidateTraveler(jObject, name.ToLower());

            Assert.False(isTraveler);
        }
Пример #3
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);
        }
Пример #4
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);
        }