public void CreateAnswerRedirectsAsync() { DbContextOptions <FunemploymentDbContext> options = new DbContextOptionsBuilder <FunemploymentDbContext>() .UseInMemoryDatabase("CreateAnswerRedirect") .Options; using (FunemploymentDbContext context = new FunemploymentDbContext(options)) { BehavioralController bc = new BehavioralController(context); Player player = new Player(); player.Username = "******"; player.Location = "testLocation"; player.About = "testAbout"; Answer answer = new Answer(); CreateAnswerViewModel cavm = new CreateAnswerViewModel(); try { var x = bc.CreateAnswer(cavm); } catch (Exception ex) { Assert.True(ex is NullReferenceException); } } }
public void CreateAnswerWorks() { DbContextOptions <FunemploymentDbContext> options = new DbContextOptionsBuilder <FunemploymentDbContext>() .UseInMemoryDatabase("BehaviorIndexRedirects") .Options; using (FunemploymentDbContext context = new FunemploymentDbContext(options)) { BehavioralController bc = new BehavioralController(context); Player player = new Player(); player.Username = "******"; player.Location = "testLocation"; player.About = "testAbout"; Answer answer = new Answer(); answer.Content = "testContent"; answer.BQID = 100; var x = bc.CreateAnswer(100); Assert.Equal("testContent", answer.Content); } }