public async Task <IActionResult> Create([Bind("TestemonyId,Title,Content,StudentId,Valid,CreationDate")] Testemony testemony) { if (ModelState.IsValid) { _context.Add(testemony); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Testemonies", new { userId = testemony.StudentId })); } ViewData["StudentId"] = testemony.StudentId; ViewData["CreationDate"] = testemony.CreationDate; return(View(testemony)); }
public async Task TestingCreateTestemonySuccessfull() { InitializeDatabaseWithDataTest(); TestemoniesController controller = new TestemoniesController(_context); // Act Testemony testemonyTest = new Testemony { Title = "Testing", Content = "Testing", StudentId = _context.Students.Where(s => s.UserFullname.Equals("Teste User 1")).FirstOrDefault().Id, Valid = false, CreationDate = new DateTime(2018, 02, 05) }; await controller.Create(testemonyTest); int currentInterviewNumber = _context.Testemonies.Count(); Assert.Equal(2, currentInterviewNumber); }