我收到错误消息:
找不到指定的成员(SetModelFactory)。您可能需要重新生成私有访问者,或者该成员可能是私有的并在基类上定义。如果后者为真,则需要将定义成员的类型传递给PrivateObject的构造函数。
我在here尝试了这个建议,但是没有用。
public void SetModelFactoryTest()
{
AvailabilityBL target = new AvailabilityBL();
AvailabilityDS ds = new AvailabilityDS();
ds.EnforceConstraints = false;
TestBusinessLogic.BusinessLogic_AvailabilityBLAccessor accessor = new TestBusinessLogic.BusinessLogic_AvailabilityBLAccessor(target);
// SETUP STANDARD TEST DATA
this.SetupTestData(ds, null);
int newModelID = 89;
// ADD A DUMMY MODEL ROW
this.SetupTestModel(newModelID, ds);
accessor.mAvailabilityDS = ds;
int siteID = 22;
int platformID = 33;
string factoryName = "MY COOL FACTORY";
DateTime validUntil = new DateTime(2015, 9, 27);
accessor.SetModelFactory(siteID, platformID, factoryName, validUntil);
Assert.AreEqual(siteID, accessor.mAvailabilityDS.Model[0].SiteID, "SetModelFactory did not set the SiteID.");
Assert.AreEqual(platformID, accessor.mAvailabilityDS.Model[0].PlatformID, "SetModelFactory did not set the PlatformID.");
Assert.AreEqual(factoryName, accessor.mAvailabilityDS.Model[0].FactoryName, "SetModelFactory did not set the FactoryName.");
Assert.AreEqual(validUntil, accessor.mAvailabilityDS.Model[0].ValidUntil, "SetModelFactory did not set the ValidUntil.");
}
VSCodeGenAccessors.cs
internal void SetModelFactory(int siteID, int platformID, string factoryName, global::System.DateTime validUntil) {
object[] args = new object[] {
siteID,
platformID,
factoryName,
validUntil};
m_privateObject.Invoke("SetModelFactory", new System.Type[] {
typeof(int),
typeof(int),
typeof(string),
typeof(global::System.DateTime)}, args);
}