Exemplo n.º 1
0
        public void ContinentRepositoryFunction_AddContinent_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(false);
            ContinentRepository  repo    = new ContinentRepository(context);

            Continent continent  = new Continent("Continent");
            Continent continent2 = new Continent("Continent2");

            Continent continent3 = new Continent("Continent4");

            continent3.AddCountry(new Country(12, "Country1", 20.0f, continent3));

            repo.AddContinent(continent);
            context.SaveChanges();

            repo.AddContinent(continent2);
            context.SaveChanges();

            repo.AddContinent(continent3);
            context.SaveChanges();


            repo.GetContinent(1).Name.Should().Be(continent.Name);
            repo.GetContinent(2).Name.Should().Be(continent2.Name);

            var continentWithCountries = repo.GetContinent(3);

            continentWithCountries.Name.Should().Be(continent3.Name);

            continentWithCountries.Countries.Count.Should().Be(1);
            continentWithCountries.Countries[0].Name.Should().Be("Country1");
            continentWithCountries.Countries[0].Population.Should().Be(12);
            continentWithCountries.Countries[0].Surface.Should().Be(20.0f);
        }
        public void CountryRepositoryFunction_AddCountry_FunctionalityTest()
        {
            GeographyContextTest context       = new GeographyContextTest(true);
            CountryRepository    countryRepo   = new CountryRepository(context);
            ContinentRepository  continentRepo = new ContinentRepository(context);

            Continent continent = new Continent("Continent60");

            context.SaveChanges();

            continentRepo.AddContinent(continent);
            context.SaveChanges();

            countryRepo.AddCountry(4, "Country60", 20, 30.0f);
            context.SaveChanges();

            var countryFromRepo = countryRepo.GetCountry(4, 2);

            continentRepo.HasCountries(4).Should().BeTrue();

            countryFromRepo.Name.Should().Be("Country60");
            countryFromRepo.Population.Should().Be(20);
            countryFromRepo.Surface.Should().Be(30.0f);
            countryFromRepo.Continent.Name.Should().Be("Continent60");
        }
        public void CountryRepositoryFunction_IsInDatabaseWithId_FunctionalityTest()
        {
            GeographyContextTest context     = new GeographyContextTest(true);
            CountryRepository    countryRepo = new CountryRepository(context);

            countryRepo.IsInDatabase(2).Should().BeTrue();
            countryRepo.IsInDatabase(10).Should().BeFalse();
        }
Exemplo n.º 4
0
        public void ContinentRepositoryFunction_HasCountries_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);

            repo.HasCountries(1).Should().BeFalse();
            repo.HasCountries(3).Should().BeTrue();
        }
Exemplo n.º 5
0
        public void ContinentRepositoryFunction_GetContinentWithName_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);

            Continent continent = repo.GetContinent("Continent");

            continent.Name.Should().Be("Continent");
        }
Exemplo n.º 6
0
        public void ContinentRepositoryFunction_IsInDatabaseWithName_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);

            repo.IsInDatabase(1).Should().BeTrue();

            repo.IsInDatabase(29).Should().BeFalse();
        }
        public void CountryRepositoryFunction_GetCountryWithId_FunctionalityTest()
        {
            GeographyContextTest context     = new GeographyContextTest(true);
            CountryRepository    countryRepo = new CountryRepository(context);

            Country country = countryRepo.GetCountry(4, 2);

            country.Name.Should().Be("Country60");
            country.Population.Should().Be(20);
            country.Surface.Should().Be(30.0f);
            country.Continent.Name.Should().Be("Continent60");
        }
Exemplo n.º 8
0
        public void ContinentRepositoryFunction_DeleteContinent_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);

            repo.DeleteContinent(2);

            context.SaveChanges();

            repo.IsInDatabase(1).Should().BeTrue();
            repo.IsInDatabase(2).Should().BeFalse();
        }
        public void CountryRepositoryFunction_DeleteCountry_FunctionalityTest()
        {
            GeographyContextTest context     = new GeographyContextTest(true);
            CountryRepository    countryRepo = new CountryRepository(context);

            Country country = countryRepo.GetCountry(4, 2);

            country.Name.Should().Be("Country60");
            country.Population.Should().Be(20);
            country.Surface.Should().Be(30.0f);
            country.Continent.Name.Should().Be("Continent60");

            countryRepo.DeleteCountry(1);
            context.SaveChanges();

            countryRepo.IsInDatabase(1).Should().BeFalse();
            countryRepo.IsInDatabase(2).Should().BeTrue();
        }
Exemplo n.º 10
0
        public void ContinentRepositoryFunction_GetContinentWithId_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);

            Continent continent = repo.GetContinent(1);

            continent.Name.Should().Be("Continent");

            var continentWithCountries = repo.GetContinent(3);

            continentWithCountries.Name.Should().Be("Continent4");

            continentWithCountries.Countries.Count.Should().Be(1);
            continentWithCountries.Countries[0].Name.Should().Be("Country1");
            continentWithCountries.Countries[0].Population.Should().Be(12);
            continentWithCountries.Countries[0].Surface.Should().Be(20.0f);
        }
Exemplo n.º 11
0
        public void ContinentRepositoryFunction_UpdateContinent_FunctionalityTest()
        {
            GeographyContextTest context = new GeographyContextTest(true);
            ContinentRepository  repo    = new ContinentRepository(context);



            Continent continent = repo.GetContinent(1);

            continent.Name.Should().Be("Continent");

            repo.UpdateContinent(1, new Continent("Continent3"));
            context.SaveChanges();

            continent = repo.GetContinent(1);

            continent.Name.Should().Be("Continent3");
        }
Exemplo n.º 12
0
        public void CountryRepositoryFunction_UpdateCountry_FunctionalityTest()
        {
            GeographyContextTest context     = new GeographyContextTest(true);
            CountryRepository    countryRepo = new CountryRepository(context);

            Country country = countryRepo.GetCountry(4, 2);

            country.Name.Should().Be("Country60");
            country.Population.Should().Be(20);
            country.Surface.Should().Be(30.0f);
            country.Continent.Name.Should().Be("Continent60");

            countryRepo.UpdateCountry(2, 4, "NewCountry60", 99, 55.5f);
            context.SaveChanges();

            country = countryRepo.GetCountry(4, 2);

            country.Name.Should().Be("NewCountry60");
            country.Population.Should().Be(99);
            country.Surface.Should().Be(55.5f);
            country.Continent.Name.Should().Be("Continent60");
        }