public void TestMethod1() { // Arrange LanguageSqlDAO dao = new LanguageSqlDAO(connectionString); // Act IList <Language> list = dao.GetLanguages("ZZZ"); IList <Language> list2 = dao.GetLanguages("AAA"); // Assert Assert.AreEqual(1, list.Count); Assert.AreEqual(0, list2.Count); }
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")); }
public void GetLanguageByCountryCode() { // Arrange LanguageSqlDAO languageSqlDAO = new LanguageSqlDAO(connectionString); // Act IList <Language> languages = languageSqlDAO.GetLanguages(countryCodeToTest); // Assert Assert.IsTrue(languages.Count > 0); }
public void GetLanguageBySpecificCountryCode(string countryCode, int expectedCount) { // Arrange LanguageSqlDAO languageSqlDAO = new LanguageSqlDAO(ConnectionString); // Act IList <Language> languages = languageSqlDAO.GetLanguages(countryCode); // Assert Assert.AreEqual(expectedCount, languages.Count); }
public void TestUpdateLanguage() { //Arrange ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); ICollection <Language> allUSLanguages = dao.GetLanguages("USA"); Language lang = allUSLanguages.ToArray()[0]; lang.Percentage = 50; //Act bool result = dao.UpdateLanguage(lang); //Assert Assert.IsTrue(result); Assert.AreEqual(50, lang.Percentage);//this is NOT checkign the DAO ICollection <Language> updatedLanguages = dao.GetLanguages("USA"); CollectionAssert.Contains((ICollection)updatedLanguages, lang); }
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 GetLanguagesTest(string countryCode, int expectedCount) { // Arrange LanguageSqlDAO dal = new LanguageSqlDAO(ConnectionString); // Act IList <Language> languages = dal.GetLanguages(countryCode); // Assert Assert.AreEqual(expectedCount, languages.Count); }
public void GetLanguagesTest(string continent, int expectedNumberOfRows) { // Arrange LanguageSqlDAO dao = new LanguageSqlDAO(ConnectionString); // Act IList <Language> languages = dao.GetLanguages(continent); // Assert Assert.AreEqual(expectedNumberOfRows, languages.Count); }
private void GetLanguagesForCountry() { string countryCode = CLIHelper.GetString("Enter the country code you want to retrieve:"); IList <Language> languages = languageDAO.GetLanguages(countryCode); Console.WriteLine(); Console.WriteLine($"Printing {languages.Count} languages for {countryCode}"); foreach (var language in languages) { Console.WriteLine(language); } }
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")); }
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 GetLanguagesTest(string countryCode, int expectedCount) { // Arrange ILanguageDAO dao = new LanguageSqlDAO(ConnectionString); //Act IList <Language> list = dao.GetLanguages(countryCode); //Assert Assert.AreEqual(expectedCount, list.Count); /* Not using DataRow attributes * // Act * IList<Language> list = dao.GetLanguages("USA"); * // Assert * Assert.AreEqual(1, list.Count); * list = dao.GetLanguages("XYZ"); * // Assert * Assert.AreEqual(0, list.Count); */ }
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)); }