예제 #1
0
        public void UpdateTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid countryId = new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C");
            // "Spain", "es-ES"

            //Act
            Country country = countryRepository.Single(e => e.Id == countryId);

            country.SetName("Venezuela");
            country.SetIsoCode("VZ");
            countryRepository.Update(country);
            unitwork.SaveChanges();

            Country countryF = countryRepository.SingleOrDefault(e => e.Id == countryId);

            //Assert
            countryF.ShouldNotBeNull();
            countryF.CountryName.ShouldBe("Venezuela");
            countryF.CountryISOCode.ShouldBe("VZ");
        }
예제 #2
0
        public void RemoveRangeTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid countryId1 = new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C");
            Guid countryId2 = new Guid("C3C82D06-6A07-41FB-B7EA-903EC456BFC5");

            //Act
            Country country1 = countryRepository.Single(e => e.Id == countryId1);
            Country country2 = countryRepository.Single(e => e.Id == countryId2);

            List <Country> list = new List <Country>()
            {
                country1,
                country2
            };

            countryRepository.Remove(list);
            unitwork.SaveChanges();

            Country countryF1 = countryRepository.SingleOrDefault(e => e.Id == countryId1);
            Country countryF2 = countryRepository.SingleOrDefault(e => e.Id == countryId2);

            //Assert
            countryF1.ShouldBeNull();
            countryF2.ShouldBeNull();
        }
예제 #3
0
        public void UpdateRangeTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid countryId1 = new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C");
            // "Spain", "es-ES"
            Guid countryId2 = new Guid("C3C82D06-6A07-41FB-B7EA-903EC456BFC5");
            // "EEUU", "en-US"

            //Act
            Country country1 = countryRepository.Single(e => e.Id == countryId1);

            country1.SetName("Venezuela");
            country1.SetIsoCode("VZ");
            Country country2 = countryRepository.Single(e => e.Id == countryId2);

            country2.SetName("Brazil");
            country2.SetIsoCode("Br");

            List <Country> list = new List <Country>()
            {
                country1,
                country2
            };

            countryRepository.Update(list);
            unitwork.SaveChanges();

            Country countryF1 = countryRepository.SingleOrDefault(e => e.Id == countryId1);
            Country countryF2 = countryRepository.SingleOrDefault(e => e.Id == countryId2);

            //Assert
            countryF1.ShouldNotBeNull();
            countryF1.CountryName.ShouldBe("Venezuela");
            countryF1.CountryISOCode.ShouldBe("VZ");
            countryF2.ShouldNotBeNull();
            countryF2.CountryName.ShouldBe("Brazil");
            countryF2.CountryISOCode.ShouldBe("Br");
        }
예제 #4
0
        public void RemoveTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid countryId = new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C");

            //Act
            Country country = countryRepository.Single(e => e.Id == countryId);

            countryRepository.Remove(country);
            unitwork.SaveChanges();

            Country countryF = countryRepository.SingleOrDefault(e => e.Id == countryId);

            //Assert
            countryF.ShouldBeNull();
        }
예제 #5
0
        public void AddRangeTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid    countryId1 = new Guid("A3C82D06-6A07-41FB-B7EA-903EC456BFC5");
            Country country1   = new Country("Colombia", "CO");

            country1.ChangeCurrentIdentity(countryId1);

            Guid    countryId2 = new Guid("B3C82D06-6A07-41FB-B7EA-903EC456BFC5");
            Country country2   = new Country("Venezuela", "VZ");

            country2.ChangeCurrentIdentity(countryId2);

            List <Country> list = new List <Country>()
            {
                country1,
                country2
            };

            //Act
            countryRepository.Add(list);
            unitwork.SaveChanges();

            Country countryF1 = countryRepository.Single(e => e.Id == countryId1);
            Country countryF2 = countryRepository.Single(e => e.Id == countryId2);

            //Assert
            countryF1.ShouldNotBeNull();
            countryF1.CountryName.ShouldBe("Colombia");
            countryF1.CountryISOCode.ShouldBe("CO");
            countryF1.Id.ShouldBe(countryId1);

            countryF2.ShouldNotBeNull();
            countryF2.CountryName.ShouldBe("Venezuela");
            countryF2.CountryISOCode.ShouldBe("VZ");
            countryF2.Id.ShouldBe(countryId2);
        }
예제 #6
0
        public void AddTest()
        {
            //Arrange
            InPortDbContext     context           = InPortContextFactory.Create();
            UnitOfWorkContainer unitwork          = new UnitOfWorkContainer(context);
            ICountryRepository  countryRepository = unitwork.Repository.CountryRepository;

            Guid    countryId = new Guid("F3C82D06-6A07-41FB-B7EA-903EC456BFC5");
            Country country1  = new Country("Colombia", "CO");

            country1.ChangeCurrentIdentity(countryId);

            //Act
            countryRepository.Add(country1);
            unitwork.SaveChanges();

            Country country = countryRepository.Single(e => e.Id == countryId);

            //Assert
            country.ShouldNotBeNull();
            country.CountryName.ShouldBe("Colombia");
            country.CountryISOCode.ShouldBe("CO");
            country.Id.ShouldBe(countryId);
        }