public void RowToIndexConverter_Convert_DoesntFindValue_ReturnsMinusOne() { var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; var multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; var modelItemThatdoesntExist = ModelItemUtils.CreateModelItem(new ActivityDTO("thing", "stuff", 8)); dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); //------------Execute Test--------------------------- if (modelItem.FieldsCollection is ModelItemCollection collection) { var result = converter.Convert(modelItemThatdoesntExist, typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(-1, result); } else { Assert.Fail(); } }
public void RowToIndexConverter_Convert_FindsValue_ReturnsIndex() { //------------Setup for test-------------------------- var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; var multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); //------------Execute Test--------------------------- if (modelItem.FieldsCollection is ModelItemCollection collection) { var result = converter.Convert(collection[1], typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(2, result); } else { Assert.Fail(); } }