public void Add(Setor obj) { try { _dal.BeginTransaction(); _dal.Add(obj); _dal.CommitTransaction(); } catch (Exception ex) { _dal.RollbackTransaction(); throw ex; } }
public void Can_add_new_Setor() { var Setor = new SetorModel { Nome = "added1", Sys_Ativo = true, Sys_DataCadastro = DateTime.Today }; ISetorRepository repository = new SetorRepository(); repository.Add(Setor); // use session to try to load the product using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get <SetorModel>(Setor.Id); // Test that the product was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(Setor, fromDb); Assert.AreEqual(Setor.Nome, fromDb.Nome); // Assert.AreEqual(Setor.Sobrenome, fromDb.Sobrenome); } }