Mocked object doesn't have all properties shown in Intellisense - in one project but has them in the other

前端 未结 4 1988
既然无缘
既然无缘 2021-01-16 03:24

I\'m mocking VSTO objects and in one project (I didn\'t write) it has this code:

var listOfSheets = new List();
var mockSheets = Substitute.         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-16 03:45

    This is a wild guess, but Office Interop arrays are 1 based, not 0 based. I havent looked into it but this may be defined in the metadata. Try this:

    for (int i = 0; i < numSheets; i++)
    {
        listOfSheets.Add(Sheet);
        listOfSheets[i].Name = MockSheetName + (i + 1);
        `mockSheets[i + 1].Returns(listOfSheets[i]);`
    }
    

提交回复
热议问题