Esempio n. 1
0
        public void AddLanguage_ThrowsExceptionIfRowExists()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                //Arrange
                CountrySqlDALTests.InsertFakeCountry("JRT", "Fake Country", "North America");
                LanguageSqlDALTests.InsertFakeLanguage("JRT", "TEST LANGUAGE", true);
                LanguageSqlDAL testClass   = new LanguageSqlDAL(connectionString);
                Language       newLanguage = new Language();
                newLanguage.CountryCode = "JRT";
                newLanguage.Name        = "TEST LANGUAGE";
                newLanguage.IsOfficial  = true;
                newLanguage.Percentage  = 100;

                //Act
                bool output = testClass.AddNewLanguage(newLanguage);
            }
        }
Esempio n. 2
0
        public void LanguagesByCountry_OfficialLanguages()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                // Arrange
                CountrySqlDALTests.InsertFakeCountry("JRT", "Joshtopia", "North America");
                LanguageSqlDALTests.InsertFakeLanguage("JRT", "Official Language", true);
                LanguageSqlDALTests.InsertFakeLanguage("JRT", "Unofficial Languauge", false);
                LanguageSqlDAL testClass = new LanguageSqlDAL(connectionString);

                // Act
                List <Language> languages = testClass.GetLanguages("JRT", true);

                // Assert
                Assert.AreEqual(1, languages.Count);
                Assert.AreEqual("Official Language", languages[0].Name);
            }
        }
Esempio n. 3
0
        public void CitiesByCountryCode_Country_With_Cities()
        {
            // Rolls back the data when done with the test.
            using (TransactionScope transaction = new TransactionScope())
            {
                //Arrange
                CountrySqlDALTests.InsertFakeCountry("JRT", "Joshtopia", "North America");
                int        cityId    = CitySqlDALTests.InsertFakeCity("Joshville", "JRT");
                CitySqlDAL testClass = new CitySqlDAL(connectionString);

                //Act
                List <City> cities = testClass.GetCitiesByCountryCode("JRT");

                //Assert
                Assert.AreEqual(1, cities.Count);
                Assert.AreEqual("Joshville", cities[0].Name);
                Assert.AreEqual(cityId, cities[0].CityId);
            }
        }