public void TestCanFailUpdateTQ() { DbContextOptions <FunemploymentDBContext> options = new DbContextOptionsBuilder <FunemploymentDBContext>() .UseInMemoryDatabase("TestCanFailUpdateTQ") .Options; using (FunemploymentDBContext context = new FunemploymentDBContext(options)) { TechnicalQuestion TQ = new TechnicalQuestion(); TQ.ID = 1; TQ.ProblemDomain = "Problem Domain"; TQ.Input = "Input"; TQ.Output = "Output"; TQ.Difficulty = 7; TQController tc = new TQController(context); var test = tc.Create(TQ); TechnicalQuestion TQ2 = new TechnicalQuestion(); TQ2.ProblemDomain = "no Domain"; TQ2.Input = "out"; TQ2.Output = "in"; TQ2.Difficulty = 7; var test2 = tc.Update(2, TQ2); var answer = test2.Result; Assert.IsType <CreatedAtRouteResult>(answer); } }
public void TestCanUpdateTQ() { DbContextOptions <FunemploymentDBContext> options = new DbContextOptionsBuilder <FunemploymentDBContext>() .UseInMemoryDatabase("TestCanUpdateTQ") .Options; using (FunemploymentDBContext context = new FunemploymentDBContext(options)) { TechnicalQuestion TQ = new TechnicalQuestion(); TQ.ID = 1; TQ.ProblemDomain = "Problem Domain"; TQ.Input = "Input"; TQ.Output = "Output"; TQ.Difficulty = 7; TQController tc = new TQController(context); var test = tc.Create(TQ); TechnicalQuestion TQ2 = new TechnicalQuestion(); TQ2.ProblemDomain = "no Domain"; TQ2.Input = "out"; TQ2.Output = "in"; TQ2.Difficulty = 7; var test2 = tc.Update(1, TQ2); var answer = test2.Result; var results = context.TechnicalQuestions.FirstOrDefault(a => a.ID == 1); Assert.Equal("no Domain", results.ProblemDomain); } }