public void AddUpdateDeleteChildren_Gets_The_Old_Items_And_Calls_The_Helper_Correctly() { //arrange var id = 5; var oldAssetTypeProperties = new List<AssetTypeProperty>(); var dbItems = new List<AssetType>() { new AssetType() { Id = id, Properties = oldAssetTypeProperties } }; _dbSet.SetData(dbItems); var newAssetTypeProperties = new List<AssetTypeProperty>(); var itemToUpdate = new AssetType() { Id = id, Properties = newAssetTypeProperties }; var mockDataHelper = new Mock<IDataHelper>(); HelperFactory.SetDataHelper(mockDataHelper.Object); //act _assetTypeRepo.Update(itemToUpdate); //assert mockDataHelper.Verify(m => m.DoAddUpdateDelete(_mockAssetTypePropertyRepo.Object, oldAssetTypeProperties, newAssetTypeProperties), Times.Once(), "The helper method was not called correctly"); }
public void Add_Calls_Add_For_All_Items_In_Properties() { //arrange var assetTypeProperty1 = new AssetTypeProperty(); var assetTypeProperty2 = new AssetTypeProperty(); var itemToAdd = new AssetType() { Properties = new List<AssetTypeProperty>() { assetTypeProperty1, assetTypeProperty2 } }; //act _assetTypeRepo.Add(itemToAdd); //assert _mockAssetTypePropertyRepo.Verify(m => m.Add(assetTypeProperty1), Times.Once(), "Add was not called for each Properties"); _mockAssetTypePropertyRepo.Verify(m => m.Add(assetTypeProperty2), Times.Once(), "Add was not called for each item in Properties"); }