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 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 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(); }
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"); }
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"); }