public void DiagnosticsTest1() { Diagnostic diagnostic; int id; using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); diagnostic = new Diagnostic { DiagnosticText = "text", CreationDate = DateTime.Now, DateOfLastConfirmation = DateTime.Now, Comment = "comment", }; id = ctrl.CreateDiagnostic(diagnostic); var diagnosticRes = ctrl.GetDiagnostic(id); Assert.IsNotNull(diagnosticRes); Assert.AreEqual("text", diagnosticRes.DiagnosticText); Assert.AreEqual("comment", diagnosticRes.Comment); } using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); diagnostic.DiagnosticID = id; diagnostic.DiagnosticText = "text1111"; ctrl.EditDiagnostic(diagnostic); var diagnosticRes = ctrl.GetDiagnostic(id); Assert.IsNotNull(diagnosticRes); Assert.AreEqual("text1111", diagnosticRes.DiagnosticText); Assert.AreEqual("comment", diagnosticRes.Comment); } using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); ctrl.DeleteDiagnostic(diagnostic.DiagnosticID); var diagnosticRes = ctrl.GetDiagnostic(id); Assert.IsNull(diagnosticRes); } }