예제 #1
0
        public void SeedData()
        {
            var territories = new List<Territories>
            {
                new Territories { TerritoryDescription = "Territorio Teste"},
                new Territories { TerritoryDescription = "Outro Território Teste"}
            };
            territories.ForEach(t => t.GenerateNewIdentity());

            var region = new Region
            {
                RegionDescription = "Região de Teste",
                Territories = territories
            };
            region.GenerateNewIdentity();

            using (var uow = CreateTransientUnitOfWork())
            {
                var regionRepository = new RegionRepository(uow);

                regionRepository.Incluir(region);
                uow.Commit();

            }
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        public void IncluirRegiao()
        {
            using (var uow = CreateTransientUnitOfWork())
            {
                var region = new Region { RegionDescription = "Região de Teste" };
                region.GenerateNewIdentity();

                var regionRepository = new RegionRepository(uow);
                var qtdOriginalDeRegistrosNaTabelaRegion = regionRepository.Contar();

                regionRepository.Incluir(region);
                uow.Commit();

                Assert.AreEqual(qtdOriginalDeRegistrosNaTabelaRegion + 1, regionRepository.Contar());
            }
        }