public void CerereValidatorTest() { try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = "", Stare = "TEST" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = TipComponenta.GlobuleRosii.ToString(), Stare = "" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = "", Stare = "" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = TipComponenta.GlobuleRosii.ToString(), Stare = "TEST" }; _cerereMedicPacientValidator.Validate(cerereTest); // Test passed } catch (ValidationException) { Assert.Fail(); } }
public void Add(CerereMedicPacient entity) { _validator.Validate(entity); _context.CerereMedicPacients.Add(entity); _context.SaveChanges(); }