コード例 #1
0
        public void GetLanguagesTest()
        {
            //Arrange
            LanguageSqlDAL languageDal = new LanguageSqlDAL(connectionString);

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

            //Assert
            Assert.AreEqual(1, languages.Count);
            Assert.AreEqual("OfficialLanguage", languages[0].Name);
        }
コード例 #2
0
        private void GetLanguagesForCountry()
        {
            string countryCode  = CLIHelper.GetString("Enter the country code you want to retrieve:");
            bool   officialOnly = CLIHelper.GetBool("Retrieve official languages only? True/False ");

            LanguageSqlDAL  languageDal = new LanguageSqlDAL(DatabaseConnectionString);
            List <Language> languages   = languageDal.GetLanguages(countryCode, officialOnly);

            Console.WriteLine();
            Console.WriteLine($"Printing {languages.Count} languages for {countryCode}");

            foreach (var language in languages)
            {
                Console.WriteLine(language);
            }
        }
コード例 #3
0
        private void GetLanguagesForCountry()
        {
            string countryCode = CLIHelper.GetString("Enter the country code you want to retrieve:");


            LanguageSqlDAL  languageDal = new LanguageSqlDAL(DatabaseConnectionString);
            List <Language> languages   = languageDal.GetLanguages(countryCode);

            Console.WriteLine();
            Console.WriteLine($"Printing {languages.Count} languages for {countryCode}");

            foreach (Language l in languages)
            {
                Console.WriteLine(l.Name.PadRight(30) + l.CountryCode.PadRight(5) + (l.IsOfficial ? "Official" : "Unofficial").PadRight(15) + (l.Percentage / 100.00).ToString("P").PadRight(5));
            }
        }
コード例 #4
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);
            }
        }