public void Map_HasResultsAndParents_MapsParents() { //Arrange var oneToOneItem = new OneToOneItem { Id = 5 }; var oneToOneItemList = new List<OneToOneItem> { oneToOneItem }; MockGridReader.Setup(gridReader => gridReader.Read<OneToOneItem>()).Returns(oneToOneItemList); var parent = new ParentItem { ChildId = 5 }; var parentDictionary = new Dictionary<int, ParentItem> { [1] = parent }; //Act OneToOneMapping.Map(MockGridReader.Object, parentDictionary, true); //Assert Assert.AreEqual(oneToOneItem, parentDictionary[1].Child); }
public void Map_HasResultsAndShouldContinueThroughEmptyTablesIsFalse_MapsChildren() { //Arrange var oneToOneItem = new OneToOneItem(); var oneToOneItemList = new List<OneToOneItem> { oneToOneItem }; MockGridReader.Setup(gridReader => gridReader.Read<OneToOneItem>()).Returns(oneToOneItemList); OneToOneMapping.AddMapping(MockChildMapping.Object); IDictionary<int, ParentItem> parents = null; //Act OneToOneMapping.Map(MockGridReader.Object, parents, false); //Assert MockChildMapping.Verify(childMapping => childMapping.Map(It.IsAny<IGridReader>(), It.IsAny<IDictionary<int, OneToOneItem>>(), It.IsAny<bool>()), Times.Once); }