public void TestCreateResultAsync() { var rbo = new ResultBusinessObject(); var qbo = new QuizBusinessObject(); var vbo = new VisitorBusinessObject(); var quiz = new Quiz("Quiz 1"); qbo.Create(quiz); var countrybo = new CountryBusinessObject(); var pbo = new ProfileBusinessObject(); var companybo = new CompanyBusinessObject(); var country = new Country("Holanda"); var profile = new Profile("a", "b"); var company = new Company("a", "b", "c", "d", profile.Id); countrybo.Create(country); pbo.Create(profile); companybo.Create(company); var visitor = new Visitor("B", "N", DateTime.Now, "Male", profile.Id, country.Id); vbo.Create(visitor); var result = new Result("Q1 Result", DateTime.UtcNow, quiz.Id, visitor.Id); var resCreate = rbo.CreateAsync(result).Result; var resGet = rbo.ReadAsync(result.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdateQuizAnswer() { BoraNowSeeder.Seed(); var qabo = new QuizAnswerBusinessObject(); var qqbo = new QuizQuestionBusinessObject(); var quizbo = new QuizBusinessObject(); var resList = qabo.List(); var quizAnswer = resList.Result.FirstOrDefault(); var newQuiz = new Quiz("Where you wanna go?"); var newQuizQuestion = new QuizQuestion("Where you wanna go?", newQuiz.Id); quizbo.Create(newQuiz); qqbo.Create(newQuizQuestion); quizAnswer.QuizQuestionId = newQuizQuestion.Id; quizAnswer.Answer = "yes"; var resUpdate = qabo.Update(quizAnswer); resList = qabo.List(); Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Answer == "yes" && resList.Result.First().QuizQuestionId == newQuizQuestion.Id); }
public ActionResult Create([FromBody] QuizViewModel vm) { var c = new Quiz(vm.Title); var res = _bo.Create(c); var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError; return(new ObjectResult(code)); }
public void TestCreateQuiz() { BoraNowSeeder.Seed(); var _quiz = new Quiz("Questionário BoraNow"); var _bo = new QuizBusinessObject(); var resCreate = _bo.Create(_quiz); var resGet = _bo.Read(_quiz.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdateResultInterestPointAsync() { BoraNowSeeder.Seed(); var ripbo = new ResultInterestPointBusinessObject(); var resList = ripbo.List(); var item = resList.Result.FirstOrDefault(); var rbo = new ResultBusinessObject(); var ipbo = new InterestPointBusinessObject(); var vbo = new VisitorBusinessObject(); var qbo = new QuizBusinessObject(); var quiz = new Quiz("Quiz 1"); qbo.Create(quiz); var countrybo = new CountryBusinessObject(); var pbo = new ProfileBusinessObject(); var companybo = new CompanyBusinessObject(); var country = new Country("Holanda"); var profile = new Profile("a", "b"); var company = new Company("a", "b", "c", "d", profile.Id); countrybo.Create(country); pbo.Create(profile); companybo.Create(company); var visitor = new Visitor("A", "E", DateTime.Now, "M", profile.Id, country.Id); vbo.Create(visitor); var result = new Result("Quiz 2", DateTime.UtcNow, quiz.Id, visitor.Id); var interestPoint = new InterestPoint("Bar do Rui", "Pesticos&Cocktails", "-", "C://images", "14h", "00h", "D", true, true, company.Id); rbo.Create(result); ipbo.Create(interestPoint); var resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id); item.ResultId = resultInterestPoint.ResultId; item.InterestPointId = resultInterestPoint.InterestPointId; var resUpdate = ripbo.UpdateAsync(item).Result; resList = ripbo.ListAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().ResultId == item.ResultId && resList.Result.First().InterestPointId == item.InterestPointId); }
public void TestCreateQuizQuestionAsync() { BoraNowSeeder.Seed(); var qqbo = new QuizQuestionBusinessObject(); var qbo = new QuizBusinessObject(); var quiz = new Quiz("This quiz rocks"); qbo.Create(quiz); var quizQuestion = new QuizQuestion("do u like wine?", quiz.Id); var resCreate = qqbo.CreateAsync(quizQuestion).Result; var resGet = qqbo.ReadAsync(quizQuestion.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdateResultAsync() { BoraNowSeeder.Seed(); var rbo = new ResultBusinessObject(); var resList = rbo.List(); var item = resList.Result.FirstOrDefault(); var qbo = new QuizBusinessObject(); var quiz = new Quiz("Quiz 2"); qbo.Create(quiz); var countrybo = new CountryBusinessObject(); var pbo = new ProfileBusinessObject(); var companybo = new CompanyBusinessObject(); var country = new Country("Holanda"); var profile = new Profile("a", "b"); var company = new Company("a", "b", "c", "d", profile.Id); countrybo.Create(country); pbo.Create(profile); companybo.Create(company); var vbo = new VisitorBusinessObject(); var visitor = new Visitor("B", "N", DateTime.Now, "Male", profile.Id, country.Id); vbo.Create(visitor); var result = new Result("Q1 Result", DateTime.UtcNow, quiz.Id, visitor.Id); item.Title = result.Title; item.Date = result.Date; item.QuizId = result.QuizId; item.VisitorId = result.VisitorId; var resUpdate = rbo.Update(item); resList = rbo.ListAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Title == item.Title && resList.Result.First().Date == item.Date && resList.Result.First().QuizId == item.QuizId && resList.Result.First().VisitorId == item.VisitorId); }
public void TestCreateResultInterestPointAsync() { var ripbo = new ResultInterestPointBusinessObject(); var rbo = new ResultBusinessObject(); var ipbo = new InterestPointBusinessObject(); var vbo = new VisitorBusinessObject(); var qbo = new QuizBusinessObject(); var quiz = new Quiz("Quiz 1"); qbo.Create(quiz); var countrybo = new CountryBusinessObject(); var pbo = new ProfileBusinessObject(); var companybo = new CompanyBusinessObject(); var country = new Country("Holanda"); var profile = new Profile("a", "b"); var company = new Company("a", "b", "c", "d", profile.Id); countrybo.Create(country); pbo.Create(profile); companybo.Create(company); var visitor = new Visitor("A", "C", DateTime.Now, "M", profile.Id, country.Id); vbo.Create(visitor); var result = new Result("Quiz 1", DateTime.UtcNow, quiz.Id, visitor.Id); var interestPoint = new InterestPoint("Bar do Rui", "Pesticos&Cocktails", "Rua dos Anjos", "C://images", "14h", "00h", "Sabados", true, true, company.Id); rbo.Create(result); ipbo.Create(interestPoint); var _resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id); var resCreate = ripbo.CreateAsync(_resultInterestPoint).Result; var resGet = ripbo.ReadAsync(_resultInterestPoint.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreateQuizAnswerAsync() { BoraNowSeeder.Seed(); var qabo = new QuizAnswerBusinessObject(); var qqbo = new QuizQuestionBusinessObject(); var quizbo = new QuizBusinessObject(); var newQuiz = new Quiz("Where you wanna go?"); var newQuizQuestion = new QuizQuestion("Where you wanna go?", newQuiz.Id); quizbo.Create(newQuiz); qqbo.Create(newQuizQuestion); var newQuizAnswer = new QuizAnswer("Beach", newQuizQuestion.Id); var resCreate = qabo.CreateAsync(newQuizAnswer).Result; var resGet = qabo.ReadAsync(newQuizAnswer.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdateQuizQuestion() { BoraNowSeeder.Seed(); var qqbo = new QuizQuestionBusinessObject(); var resList = qqbo.List(); var item = resList.Result.FirstOrDefault(); var qbo = new QuizBusinessObject(); var quiz = new Quiz("This quiz rocks"); qbo.Create(quiz); item.QuizId = quiz.Id; item.Question = "viewpoint?"; var resUpdate = qqbo.Update(item); resList = qqbo.List(); Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Question == "viewpoint?" && resList.Result.First().QuizId == quiz.Id); }