public void DataService_DeleteHeirarchicalTerm_Does_Not_Modify_Terms_From_Other_Vocabularies() { //Arrange DataUtil.AddDatabaseObject(virtualScriptFilePath, deleteHeirarchicalTerm); Term term = new Term(3) { TermId = 16, Name = "Test Delete", ParentTermId = null, Weight = 0, Description = "Test Delete" }; DataService ds = new DataService(); //Act ds.DeleteHeirarchicalTerm(term); //Assert that electronics terms are untouched //Televisions, Id = 1, Left=12, Right=17 TestTerm(1, 12, 17); //Flash, Id = 9, Left=8, Right=9 TestTerm(9, 8, 9); //Electronics, Id = 12, Left=1, Right=18 TestTerm(12, 1, 18); }
public void DataService_DeleteHeirarchicalTerm_Should_Do_Nothing_On_InValid_Term() { //Arrange int rowCount = DataUtil.GetRecordCount(DataTestHelper.ConnectionString, ContentDataTestHelper.TermsTableName); DataUtil.AddDatabaseObject(virtualScriptFilePath, deleteHeirarchicalTerm); Term term = ContentTestHelper.CreateValidHeirarchicalTerm(Constants.VOCABULARY_ValidVocabularyId, Constants.TERM_ValidParentTermId); term.TermId = Constants.TERM_InValidTermId; DataService ds = new DataService(); //Act ds.DeleteHeirarchicalTerm(term); //Assert using (SqlConnection connection = new SqlConnection(DataTestHelper.ConnectionString)) { connection.Open(); DatabaseAssert.RecordCountIsEqual(connection, ContentDataTestHelper.TermsTableName, rowCount); } }
public void DataService_DeleteHeirarchicalTerm_Delete_Record_On_Valid_Term() { //Arrange int rowCount = DataUtil.GetRecordCount(DataTestHelper.ConnectionString, ContentDataTestHelper.TermsTableName); DataUtil.AddDatabaseObject(virtualScriptFilePath, deleteHeirarchicalTerm); int termId = 7; Term term = new Term(2) { TermId = 7, Name = "CD Players", ParentTermId = 2 /*Portable Electronics*/, Weight = 0, Description = "CD Players" }; DataService ds = new DataService(); //Act ds.DeleteHeirarchicalTerm(term); //Assert DatabaseAssert.RecordCountIsEqual(DataTestHelper.ConnectionString, ContentDataTestHelper.TermsTableName, rowCount - 1); DatabaseAssert.RecordDoesNotExist(DataTestHelper.ConnectionString, ContentDataTestHelper.TermsTableName, keyField, termId.ToString()); //Assert that existing terms are correct //Televisions, Id = 1, Left=12, Right=17 - should be Left=10, Right=15 TestTerm(1, 10, 15); //2-Way, Id = 8, Left=3, Right=4 - should be Left=3, Right=4 TestTerm(8, 3, 4); //Electronics, Id = 12, Left=1, Right=18 - should be Left=1, Right=16 TestTerm(12, 1, 16); }