public void ExcluirTerritoriosDeUmaRegiao() { using (var uow = CreateTransientUnitOfWork()) { var regionRepository = new RegionRepository(uow); var territoriesRepository = new TerritoriesRepository(uow); var region = regionRepository.Listar().FirstOrDefault(); var qtdOriginalDeRegistrosNaTabelaTerritories = territoriesRepository.Contar(); if (region != null) { var qtdTerritoriesRegion = region.Territories.Count; region.Territories.ToList().ForEach(territoriesRepository.Excluir); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories - qtdTerritoriesRegion , territoriesRepository.Contar()); } else { uow.Rollback(); Assert.IsTrue(false); } } }
public void IncluirTerritorioDeUmaRegiao() { using (var uow = CreateTransientUnitOfWork()) { var region = new Region { RegionDescription = "Região de Teste" }; region.GenerateNewIdentity(); var regionRepository = new RegionRepository(uow); regionRepository.Incluir(region); uow.Commit(); } using (var uow = CreateTransientUnitOfWork()) { var territoriesRepository = new TerritoriesRepository(uow); var regionRepository = new RegionRepository(uow); var region = regionRepository.Listar().FirstOrDefault(r => r.Territories.Count.Equals(0)); var qtdOriginalDeRegistrosNaTabelaTerritories = territoriesRepository.Contar(); if (region != null) { var territories = new Territories { TerritoryDescription = "Território de Teste" }; territories.GenerateNewIdentity(); region.Territories = (new List <Territories> { territories }); regionRepository.Alterar(region); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories + 1 , territoriesRepository.Contar()); Assert.IsNotNull(region.Territories); } else { uow.Rollback(); Assert.IsTrue(false); } } }
public void IncluirRegiaoComTerritorios() { var territorieses = new List <Territories> { new Territories { TerritoryDescription = "Territorio Teste" }, new Territories { TerritoryDescription = "Outro Território Teste" } }; territorieses.ForEach(t => t.GenerateNewIdentity()); var region = new Region { RegionDescription = "Região de Teste", Territories = territorieses }; region.GenerateNewIdentity(); using (var uow = CreateTransientUnitOfWork()) { var regionRepository = new RegionRepository(uow); var terrotoriesRepository = new TerritoriesRepository(uow); var qtdOriginalDeRegistrosNaTabelaRegion = regionRepository.Contar(); var qtdOriginalDeRegistrosNaTabelaTerritories = terrotoriesRepository.Contar(); regionRepository.Incluir(region); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaRegion + 1, regionRepository.Contar()); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories + territorieses.Count, terrotoriesRepository.Contar()); } }
public void IncluirTerritorioDeUmaRegiao() { using (var uow = CreateTransientUnitOfWork()) { var region = new Region { RegionDescription = "Região de Teste" }; region.GenerateNewIdentity(); var regionRepository = new RegionRepository(uow); regionRepository.Incluir(region); uow.Commit(); } using (var uow = CreateTransientUnitOfWork()) { var territoriesRepository = new TerritoriesRepository(uow); var regionRepository = new RegionRepository(uow); var region = regionRepository.Listar().FirstOrDefault(r => r.Territories.Count.Equals(0)); var qtdOriginalDeRegistrosNaTabelaTerritories = territoriesRepository.Contar(); if (region != null) { var territories = new Territories { TerritoryDescription = "Território de Teste" }; territories.GenerateNewIdentity(); region.Territories = (new List<Territories> { territories }); regionRepository.Alterar(region); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories + 1 , territoriesRepository.Contar()); Assert.IsNotNull(region.Territories); } else { uow.Rollback(); Assert.IsTrue(false); } } }
public void IncluirRegiaoComTerritorios() { var territorieses = new List<Territories> { new Territories { TerritoryDescription = "Territorio Teste"}, new Territories { TerritoryDescription = "Outro Território Teste"} }; territorieses.ForEach(t => t.GenerateNewIdentity()); var region = new Region { RegionDescription = "Região de Teste", Territories = territorieses }; region.GenerateNewIdentity(); using (var uow = CreateTransientUnitOfWork()) { var regionRepository = new RegionRepository(uow); var terrotoriesRepository = new TerritoriesRepository(uow); var qtdOriginalDeRegistrosNaTabelaRegion = regionRepository.Contar(); var qtdOriginalDeRegistrosNaTabelaTerritories = terrotoriesRepository.Contar(); regionRepository.Incluir(region); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaRegion + 1, regionRepository.Contar()); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories + territorieses.Count, terrotoriesRepository.Contar()); } }
public void ExcluirTerritoriosDeUmaRegiao() { using (var uow = CreateTransientUnitOfWork()) { var regionRepository = new RegionRepository(uow); var territoriesRepository = new TerritoriesRepository(uow); var region = regionRepository.Listar().FirstOrDefault(); var qtdOriginalDeRegistrosNaTabelaTerritories = territoriesRepository.Contar(); if (region != null) { var qtdTerritoriesRegion = region.Territories.Count; region.Territories.ToList().ForEach(territoriesRepository.Excluir); uow.Commit(); Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaTerritories - qtdTerritoriesRegion , territoriesRepository.Contar()); } else { uow.Rollback(); Assert.IsTrue(false); } } }