private IDictionary <string, string> BuildItemDictionary(TItem line) { try { return(_pivot .ListAccess(line) .ToDictionary( key => _pivot.ColumnNameAccess(key), value => _pivot.ColumnValueAccess(value))); } catch (ArgumentException ex) { throw new InvalidOperationException( "cannot have two identical column names", ex); } }
public void GetAllRegistrationChildrenMapsEventTitleToColumnNameTest() { ListPivot <RegisteredChildModel, RegisteredChildEventModel> listPivot = null; _csvWriterMock.Setup(x => x.GetAsCsv <RegisteredChildModel, RegisteredChildEventModel>( It.IsAny <IList <RegisteredChildModel> >(), It.IsAny <ListPivot <RegisteredChildModel, RegisteredChildEventModel> >())) .Callback <ICollection <RegisteredChildModel>, ListPivot <RegisteredChildModel, RegisteredChildEventModel> >( (x, y) => listPivot = y); var testName = Guid.NewGuid().ToString(); _eventAccessorMock.Setup(x => x.GetName(It.IsAny <int>())) .Returns(testName); var registeredChildModel = new RegisteredChildModel { Events = new List <RegisteredChildEventModel> { new RegisteredChildEventModel { EventId = 1, Answer = Answer.Yes } } }; _manager.GetRegisteredChildren(1234); var name = listPivot.ColumnNameAccess(registeredChildModel.Events[0]); Assert.Equal(testName, name); _eventAccessorMock.Verify( x => x.GetName( It.Is <int>(y => y == registeredChildModel.Events[0].EventId)), Times.Once); }