public void GetListStarShipsAsync_WrongMethod() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["baseURL"] != null) { config.AppSettings.Settings.Remove("baseURL"); } config.AppSettings.Settings.Add("baseURL", "https://swapi.co/api/"); if (config.AppSettings.Settings["getMethodName"] != null) { config.AppSettings.Settings.Remove("getMethodName"); } config.AppSettings.Settings.Add("getMethodName", "noexist1/"); config.Save(ConfigurationSaveMode.Modified, true); ConfigurationManager.RefreshSection("appSettings"); IStarShipsOperations swAPI = GetNewFactoryStarWarsAPI(); Assert.That(() => { IList <StarShip> listStarShip = swAPI.GetListStarShipsAsync().Result; }, Throws.Exception); }
public void GetListStarShipsAsync_ValidAccess() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["baseURL"] != null) { config.AppSettings.Settings.Remove("baseURL"); } config.AppSettings.Settings.Add("baseURL", "https://swapi.co/api/"); if (config.AppSettings.Settings["getMethodName"] != null) { config.AppSettings.Settings.Remove("getMethodName"); } config.AppSettings.Settings.Add("getMethodName", "starships/"); config.Save(ConfigurationSaveMode.Modified, true); ConfigurationManager.RefreshSection("appSettings"); IStarShipsOperations swAPI = GetNewFactoryStarWarsAPI(); IList <StarShip> listStarShip = swAPI.GetListStarShipsAsync().Result; Assert.Pass(); }