public void DataService_UpdateSimpleTerm_Updates_Record_On_Valid_Term() { //Arrange int rowCount = DataUtil.GetRecordCount(DataTestHelper.ConnectionString, ContentDataTestHelper.TermsTableName); DataUtil.AddDatabaseObject(virtualScriptFilePath, updateTerm); Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId); term.TermId = Constants.TERM_UpdateTermId; term.Name = Constants.TERM_UpdateName; term.Weight = Constants.TERM_UpdateWeight; DataService ds = new DataService(); //Act ds.UpdateSimpleTerm(term, Constants.USER_ValidId); //Assert using (SqlConnection connection = new SqlConnection(DataTestHelper.ConnectionString)) { connection.Open(); DatabaseAssert.RecordCountIsEqual(connection, ContentDataTestHelper.TermsTableName, rowCount); //Check Values are updated IDataReader dataReader = DataUtil.GetRecordsByField(connection, ContentDataTestHelper.TermsTableName, keyField, Constants.TERM_UpdateTermId.ToString()); while (dataReader.Read()) { DatabaseAssert.ReaderColumnIsEqual(dataReader, "Name", Constants.TERM_UpdateName); DatabaseAssert.ReaderColumnIsEqual(dataReader, "Weight", Constants.TERM_UpdateWeight); } dataReader.Close(); } }
public void DataService_UpdateSimpleTerm_Throws_On_InValid_VocabularyId() { //Arrange DataUtil.AddDatabaseObject(virtualScriptFilePath, updateTerm); Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_InValidVocabularyId); term.TermId = Constants.TERM_UpdateTermId; term.Name = Constants.TERM_UpdateName; term.Weight = Constants.TERM_UpdateWeight; DataService ds = new DataService(); //Act/Assert Assert.Throws<SqlException>(() => ds.UpdateSimpleTerm(term, Constants.USER_ValidId)); }