public void AddLanguage() { // Arrange Language lang = new Language(); lang.CountryCode = "USA"; lang.IsOfficial = false; lang.Name = "Wakandian"; lang.Percentage = 5; ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); // Act int beforeRowCount = GetRowCount("countrylanguage"); bool result = dao.AddNewLanguage(lang); // Assert Assert.IsTrue(result); ICollection <Language> allUSLanguages = dao.GetLanguages("USA"); CollectionAssert.Contains((ICollection)allUSLanguages, lang); Assert.AreEqual(beforeRowCount + 1, GetRowCount("countrylanguage")); }
private void AddNewLanguage() { string countryCode = CLIHelper.GetString("Enter the country code the language is for:"); bool officialOnly = CLIHelper.GetBool("Is it official only? True/False "); int percentage = CLIHelper.GetInteger("What percentage is it spoken by?"); string name = CLIHelper.GetString("What is the name of the lanaguage?"); Language lang = new Language { CountryCode = countryCode, IsOfficial = officialOnly, Percentage = percentage, Name = name }; bool result = languageDAO.AddNewLanguage(lang); if (result) { Console.WriteLine("Success!"); } else { Console.WriteLine("The new language was not inserted"); } }
public void AddLanguage_FailsBecauseLanguageExists() { //ARRANGE ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); ICollection <Language> allUSLanguages = dao.GetLanguages("USA"); //ACT Language dup = allUSLanguages.ToArray()[0]; dao.AddNewLanguage(dup); }
public void AddLanguageDuplicateTest() { // Arrange LanguageSqlDAO languageSqlDAO = new LanguageSqlDAO(ConnectionString); Language language = new Language { CountryCode = newCountryCode, Name = "Elvish", IsOfficial = true, Percentage = 5 }; // Assert Assert.IsTrue(languageSqlDAO.AddNewLanguage(language)); }
public void AddLanguage_FailsBecauseLanguageExists() { // Arrange ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); ICollection <Language> allUSLanguages = dao.GetLanguages("USA"); Language dup = allUSLanguages.ToArray()[0]; //dup.Name = "something else"; the PK is the language and the countrycode so if we change the name, then it doesn't have a pk dup // Act dao.AddNewLanguage(dup); // Assert // SqlException is expected to be thrown }
public void AddLanguage_FailsBecauseLanguageExists() { // Arrange LanguageSqlDAO dal = new LanguageSqlDAO(ConnectionString); Language language = new Language() { CountryCode = "USA", Name = "Test Language", //already exists IsOfficial = true, Percentage = 80 }; // Act dal.AddNewLanguage(language); }
public void AddLanguageDuplicateTest() { // Arrange LanguageSqlDAO languageSqlDAO = new LanguageSqlDAO(connectionString); Language language = new Language { CountryCode = countryCodeToTest, Name = languageToTest, IsOfficial = true, Percentage = 5 }; // Act bool didItWork = languageSqlDAO.AddNewLanguage(language); // Assert Assert.IsFalse(didItWork); }
public void AddLanguage() { // Arrange Language lang = new Language(); lang.CountryCode = "USA"; lang.IsOfficial = false; lang.Name = "miaw"; lang.Percentage = 5; ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); // Act bool result = dao.AddNewLanguage(lang); // Assert Assert.IsTrue(result); }
public void AddLanguage_FailsBecauseLanguageExists() { // 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.AddNewLanguage(lang); // Assert // should not work }
public void AddLanguage() { // Arrange LanguageSqlDAO dal = new LanguageSqlDAO(ConnectionString); int initialRowCount = GetRowCount("countrylanguage"); Language language = new Language() { CountryCode = "USA", Name = "English", IsOfficial = true, Percentage = 80 }; // Act dal.AddNewLanguage(language); // Assert int finalRowCount = GetRowCount("countrylanguage"); Assert.AreEqual(initialRowCount + 1, finalRowCount); }
public void AddLanguage() { // Arrange LanguageSqlDAO languageDAO = new LanguageSqlDAO(ConnectionString); int initialRowCount = GetRowCount("countrylanguage"); Language lang = new Language(); lang.CountryCode = "USA"; lang.Name = "English"; lang.IsOfficial = true; lang.Percentage = 50; // Act languageDAO.AddNewLanguage(lang); // Assert int finalRowCount = GetRowCount("countrylanguage"); Assert.AreEqual(initialRowCount + 1, finalRowCount); }
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."); }
public void AddLanguageHappyTest() { // Arrange LanguageSqlDAO languageSqlDAO = new LanguageSqlDAO(ConnectionString); IList <Language> allLanguages = languageSqlDAO.GetLanguages(newCountryCode); foreach (Language foo in allLanguages) { if (foo.Name.Equals("Klingon")) { Assert.IsTrue(false); } } Language language = new Language { CountryCode = newCountryCode, Name = "Klingon", IsOfficial = true, Percentage = 5 }; // Assert Assert.IsTrue(languageSqlDAO.AddNewLanguage(language)); }