public void CrudQuestion() { try { QuestionsFacade facade = new QuestionsFacade(); Question question = new Question() { Description = "Where and When?", Number = 99 }; // Create facade.Save(question); // Read by ID question = facade.GetQuestion(question.ID); // Update question.Description = "***" + question.Description; question.Number = question.Number + 1000; facade.Update(question); // Delete facade.Delete(question.ID); Assert.AreEqual(true, true, "Sucesso!!"); } catch (Exception ex) { Assert.AreEqual(true, false, ex.Message); } }
public bool Delete(long id) { bool returnValue = false; QuestionsFacade facade = new QuestionsFacade(); returnValue = facade.Delete(id); return(returnValue); }
public IList <Question> Get(int limit, int offset, string filter) { IList <Question> questions = null; QuestionsFacade facade = new QuestionsFacade(); questions = facade.GetQuestion(filter, limit, offset); return(questions); }
public Question Post(Question question) { Question returnValue = null; QuestionsFacade facade = new QuestionsFacade(); returnValue = facade.SaveOrUpdate(question); return(returnValue); }
// GET api/health /// <summary> /// Check the server health, testing if it is possible to query an item in the database /// </summary> public bool Get() { bool returnValue = false; QuestionsFacade facade = new QuestionsFacade(); returnValue = facade.Health(); return(returnValue); }
public Question Get(long id) { Question question = null; QuestionsFacade facade = new QuestionsFacade(); question = facade.GetQuestion(id); return(question); }
public void ServerHealth() { try { QuestionsFacade facade = new QuestionsFacade(); bool health = facade.Health(); Assert.AreEqual(true, true, "Sucesso!!"); } catch (Exception ex) { Assert.AreEqual(true, false, ex.Message); } }
public void GetQuestionByID() { try { QuestionsFacade facade = new QuestionsFacade(); Question question = facade.GetQuestion(5); Assert.AreEqual(true, true, "Sucesso!"); } catch (Exception ex) { Assert.AreEqual(true, false, ex.Message); } }
public void SendMail() { try { QuestionsFacade facade = new QuestionsFacade(); //bool returnValue = facade.ShareByEmail("*****@*****.**", null); bool returnValue = facade.ShareByEmail("*****@*****.**", "https://ajuda.sapo.pt/"); Assert.AreEqual(true, returnValue); } catch (Exception ex) { Assert.AreEqual(true, false, ex.Message); } }
public void GetQuestions() { try { QuestionsFacade facade = new QuestionsFacade(); // Get all IList <Question> questions = facade.GetQuestion(); // Get by description questions = facade.GetQuestion("Is Your"); // Get by description, and offset questions = facade.GetQuestion("a"); questions = facade.GetQuestion("a", 10, 10); Assert.AreEqual(true, true, "Sucesso!!"); } catch (Exception ex) { Assert.AreEqual(true, false, ex.Message); } }
private static void InitContext() { var builder = new DbContextOptionsBuilder <GameContext>(); InMemoryDbContextOptionsExtensions.UseInMemoryDatabase(builder, "testDB"); var context = new GameContext(builder.Options); var questionsFacade = new QuestionsFacade(_gameContext); context.Database.EnsureCreated(); var team1 = new Team() { Name = "TopTestTeam", Score = 3000 }; var team2 = new Team() { Name = "Teletubbies", Score = 101 }; var team3 = new Team() { Name = "NotSoAnonymous", Score = 4999 }; var location1 = new Location() { Name = "Centraal Station", Street = "Koningin Astridplein 27,2018 Antwerpen,Belgium" }; var location2 = new Location() { Name = "David Teniers II", Street = "Teniersplaats 4, 2000 Antwerpen, Belgium" }; var location3 = new Location() { Name = "Paleis op de Meir", Street = "Meir 50, 2000 Antwerpen, Belgium" }; var Question1 = new Question() { Content = "In welk jaar is het dit station geopend?", Answer = "1905", Options = new string[] { "1908", "1901", "1905" }, Location = location1 }; var Question2 = new Question() { Content = "Hoe heet de schilder die op dit monument is afgebeeld?", Answer = "David Teniers II", Options = new string[] { "David Teniers II", "David Teniers I", "Robert Campin" }, Location = location2 }; var Question3 = new Question() { Content = "In welke eeuw is deze schilder geboren?", Answer = "17e", Options = new string[] { "18e", "17e", "16e" }, Location = location2 }; var Question4 = new Question() { Content = "In welk jaar is dit paleis gebouwd?", Answer = "1745", Options = new string[] { "1690", "1710", "1745" }, Location = location3 }; var Question5 = new Question() { Content = "Welke koning liet er de Spiegelzaal aanleggen?", Answer = "Leopold II", Options = new string[] { "Leopold II", "Napoleon Bonaparte", "Willem I" }, Location = location3 }; context.Locations.Add(location1); context.Locations.Add(location2); context.Locations.Add(location3); context.Questions.Add(Question1); context.Questions.Add(Question2); context.Questions.Add(Question3); context.Questions.Add(Question4); context.Questions.Add(Question5); context.Teams.Add(team1); context.Teams.Add(team2); context.Teams.Add(team3); context.SaveChanges(); _gameContext = context; }
static QuestionsFacadeTest() { InitContext(); _questionsFacade = new QuestionsFacade(_gameContext); }
public void OldFetchQuestionsTest() { IQueryable <Question> questions = new List <Question> { new Question { Content = "In welk jaar is het dit station geopend?", Answer = "1905", Options = new string[] { "1908", "1901", "1905" }, Location = new Location { Name = "Centraal Station", Street = "Koningin Astridplein 27,2018 Antwerpen,Belgium" } }, new Question { Content = "Hoe heet de schilder die op dit monument is afgebeeld?", Answer = "David Teniers II", Options = new string[] { "David Teniers II", "David Teniers I", "Robert Campin" }, Location = new Location { Name = "David Teniers II", Street = "Teniersplaats 4, 2000 Antwerpen, Belgium" } }, new Question { Content = "Werkt de methode?", Answer = "hopelijk", Options = new string[] { "ja", "nee", "hopelijk" }, Location = new Location { Name = "Thuis", Street = "Straat 24" } } }.AsQueryable(); var mockSet = new Mock <DbSet <Question> >(); mockSet.As <IQueryable <Question> >().Setup(m => m.Provider).Returns(questions.Provider); mockSet.As <IQueryable <Question> >().Setup(m => m.Expression).Returns(questions.Expression); mockSet.As <IQueryable <Question> >().Setup(m => m.ElementType).Returns(questions.ElementType); mockSet.As <IQueryable <Question> >().Setup(m => m.GetEnumerator()).Returns(questions.GetEnumerator()); var mockContext = new Mock <GameContext>(); mockContext.Setup(c => c.Questions).Returns(mockSet.Object); var facade = new QuestionsFacade(mockContext.Object); var actual = facade.GetAllQuestions(); Assert.Equal(3, actual.Count()); Assert.Equal("1905", actual.First().Answer); }
public QuestionsController(QuestionsFacade _facade) { this.facade = _facade; }
// POST api/share?destination_email={destination_email}&content_url={content_url} /// <summary> /// Share the content of a URL in email /// </summary> public void Post([FromBody] string destination_email, [FromBody] string content_url) { QuestionsFacade facade = new QuestionsFacade(); facade.ShareByEmail(destination_email, content_url); }