コード例 #1
0
ファイル: LanguageSqlDAOTests.cs プロジェクト: jnleon/jleon-c
        public void RemoveLanguage()
        {
            // Arrange
            ILanguageDAO           dao            = new LanguageSqlDAO(ConnectionString);
            ICollection <Language> allUSLanguages = dao.GetLanguages("USA");
            Language lang = allUSLanguages.ToArray()[0];

            // Act
            int  beforeRowCount = GetRowCount("countrylanguage");
            bool result         = dao.RemoveLanguage(lang);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(beforeRowCount - 1, GetRowCount("countrylanguage"));
        }
コード例 #2
0
        public void RemoveLanguage()
        {
            // Arrange
            LanguageSqlDAO languageDAO     = new LanguageSqlDAO(ConnectionString);
            int            initialRowCount = GetRowCount("countrylanguage");
            Language       lang            = new Language();

            lang.CountryCode = "USA";
            lang.Name        = "Test Language";
            lang.IsOfficial  = true;
            lang.Percentage  = 50;

            // Act

            languageDAO.RemoveLanguage(lang);
            int finalRowCount = GetRowCount("countrylanguage");

            // Assert
            Assert.AreEqual(initialRowCount - 1, finalRowCount);
        }
コード例 #3
0
        public void RemoveLanguage()
        {
            // Arrange
            LanguageSqlDAO dal             = new LanguageSqlDAO(ConnectionString);
            int            initialRowCount = GetRowCount("countrylanguage");
            Language       language        = new Language()
            {
                CountryCode = "USA",
                Name        = "Test Language",
                IsOfficial  = true,
                Percentage  = 80
            };

            // Act
            dal.RemoveLanguage(language);

            // Assert
            int finalRowCount = GetRowCount("countrylanguage");

            Assert.AreEqual(initialRowCount - 1, finalRowCount);
        }
コード例 #4
0
        public void RemoveLanguage()
        {
            // Arrange
            LanguageSqlDAO dao = new LanguageSqlDAO(ConnectionString);

            // Act
            Language language = new Language();

            language.Name        = "Test Language";
            language.CountryCode = "USA";

            int  rowsBefore   = GetRowCount("countrylanguage");
            bool isSuccessful = dao.RemoveLanguage(language);
            int  rowsAfter    = GetRowCount("countrylanguage");

            // Assert
            int countChange = rowsAfter - rowsBefore;

            Assert.AreEqual(-1, countChange, "wrong number of rows after deletion");
            Assert.IsTrue(isSuccessful, "returned wrong bool value");
        }
コード例 #5
0
        private void RemoveLanguage()
        {
            string language    = CLIHelper.GetString("Which language should be removed:");
            string countryCode = CLIHelper.GetString("For which country code:");

            Language lang = new Language
            {
                CountryCode = countryCode,
                Name        = language
            };

            bool result = languageDAO.RemoveLanguage(lang);

            if (result)
            {
                Console.WriteLine("Success!");
            }
            else
            {
                Console.WriteLine("The language was not found or removed.");
            }
        }
コード例 #6
0
ファイル: LanguageSqlDAOTests.cs プロジェクト: jnleon/jleon-c
        public void RemoveLanguage()
        {
            // Arrange

            ILanguageDAO dao = new LanguageSqlDAO(ConnectionString);

            Language lang = new Language();

            lang.CountryCode = "USA";
            lang.IsOfficial  = false;
            lang.Name        = "miaw";
            lang.Percentage  = 5;


            // Act
            bool result         = dao.RemoveLanguage(lang);
            int  beforeRowCount = GetRowCount("countrylanguage");

            // Assert
            Assert.IsTrue(result); //remove me
            Assert.AreEqual(beforeRowCount - 1, GetRowCount("countrylanguage"));
        }
コード例 #7
0
        public void Test_RemoveLanguage_Result_and_Count()
        {
            //Arrange
            LanguageSqlDAO dao = new LanguageSqlDAO(ConnectionString);

            Language language = new Language();

            language.CountryCode = "USA";
            language.Name        = "C#";
            language.IsOfficial  = false;

            dao.AddNewLanguage(language);

            int beforeDeleteCount = GetRowCount("countrylanguage");

            //Action
            bool result           = dao.RemoveLanguage(language);
            int  afterDeleteCount = GetRowCount("countrylanguage");

            //Assert
            Assert.IsTrue(result, "RemoveLanguage returned false");
            Assert.AreEqual(beforeDeleteCount - 1, afterDeleteCount, "Row count did not decrease.");
        }