public StarWarsQuery(StarWarsService service) { Name = "Query"; Field <CharacterType>("hero", resolve: context => service.GetHumanByIdAsync("1")); Field <HumanType>( "human", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id", Description = "id of the human" } ), resolve: context => service.GetHumanByIdAsync(context.GetArgument <string>("id")) ); Field <DroidType>( "droid", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id", Description = "id of the droid" } ), resolve: context => service.GetDroidByIdAsync(context.GetArgument <string>("id")) ); }
public async void GetFilmsTest() { // Arrange var starWarsService = new StarWarsService(); // Act var result = await starWarsService.GetFilms(); // Assert Assert.IsTrue(result.Length > 0, "Retreived data successfully"); Assert.IsFalse(Array.Exists(result, x => x.EpisodeId == 1 || x.EpisodeId == 3 || x.EpisodeId == 5), "Only even number films retreived"); }
public async void GetCharactersByFilmTest() { // Arrange // Episode 4 object id var filmObjectId = "GteveE4ytb"; var starWarsService = new StarWarsService(); // Act var result = await starWarsService.GetCharactersByFilm(filmObjectId); // Assert // we are getting data Assert.IsTrue(result.Length > 0, "Retreived data successfully"); // Ackbar isn't in this film so his name should not be in the list Assert.IsFalse(Array.Exists(result, x => x.Name.Equals("Ackbar")), "Not getting data from other movies"); }
public StarWarsMutation(StarWarsService data) { Name = "Mutation"; Field <HumanType>( "createHuman", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <HumanInputType> > { Name = "human" } ), resolve: context => { var human = context.GetArgument <Human>("human"); return(data.AddHuman(human)); }); }
public async Task CargarPersonajes() { StarWarsService service = new StarWarsService(); DatabaseService dbService = new DatabaseService(); ObservableCollection <People> personajes = new ObservableCollection <People>(await dbService.GetPeoplesAsync()); if (personajes.Count == 0) { List <People> listaPersonajes = await service.GetPeoplesAsync(); personajes = new ObservableCollection <People>(listaPersonajes); dbService.SaveAllPeople(listaPersonajes); } this.Personajes = personajes; OnPropertyChanged("Personajes"); }
public HumanType(StarWarsService service) { Name = "Human"; Interface <CharacterType>(); Description = "A mechanical creature in the Star Wars universe."; Field(h => h.Id).Description("The id of the human."); Field(h => h.Name, nullable: true).Description("The name of the human."); Field <ListGraphType <CharacterType> >( "friends", resolve: context => service.GetFriends(context.Source) ); Field <ListGraphType <EpisodeType> >("appearsIn", "Which movie they appear in."); Field(h => h.HomePlanet, nullable: true).Description("The home planet of the human."); }
public DroidType(StarWarsService service) { Name = "Droid"; Interface <CharacterType>(); Description = "A human character in the Star Wars universe."; Field(d => d.Id).Description("The id of the droid."); Field(d => d.Name, nullable: true).Description("The name of the droid."); Field <ListGraphType <CharacterType> >( "friends", resolve: context => service.GetFriends(context.Source) ); Field <ListGraphType <EpisodeType> >("appearsIn", "Which movie they appear in."); Field(d => d.PrimaryFunction, nullable: true).Description("The primary function of the droid."); }
public async Task SetupData() { try { StarWarsService service = new StarWarsService(); _quotes = await service.GetQuotes(); } catch (Exception ex) { //set list element so that app doesn't seg fault because of null references _quotes = new List <CharacterQuote>(); //add error modal dialog UIAlertView alert = new UIAlertView() { Message = $"Message: {ex.Message.ToString()} {Environment.NewLine} Stack Trace: {ex.StackTrace}", Title = "Error: Getting Information", }; alert.AddButton("OK"); alert.Show(); } }
public StarWarsServiceUnitTesting() { swapiCore = new Mock <ISwapiCore>(); swService = new StarWarsService(swapiCore.Object); }