public void Install_Successful() { DynamicMock extensionPointMock = new DynamicMock(typeof(IExtensionPoint)); IExtensionPoint extensionPoint = (IExtensionPoint)extensionPointMock.MockInstance; extensionHostMock.ExpectAndReturn("GetExtensionPoint", extensionPoint, "ParameterProviders"); extensionPointMock.Expect("Install"); bool installed = addIn.Install(extensionHost); extensionHostMock.Verify(); extensionPointMock.Verify(); Assert.That(installed, Is.True); }
public void Install_Failure() { #if NMOCK2 IExtensionHost extensionHostMock = (IExtensionHost)_mocks.NewMock(typeof(IExtensionHost)); RowTestAddIn addIn = new RowTestAddIn(); NMock2.Expect.Once.On(extensionHostMock) .Method("GetExtensionPoint").With("TestCaseBuilders") .Will(NMock2.Return.Value(null)); bool installed = addIn.Install(extensionHostMock); _mocks.VerifyAllExpectationsHaveBeenMet(); Assert.That(installed, Is.False); #else DynamicMock extensionHostMock = new DynamicMock(typeof(IExtensionHost)); IExtensionHost extensionHost = (IExtensionHost)extensionHostMock.MockInstance; RowTestAddIn addIn = new RowTestAddIn(); extensionHostMock.ExpectAndReturn("GetExtensionPoint", null, "TestCaseBuilders"); bool installed = addIn.Install(extensionHost); extensionHostMock.Verify(); Assert.That(installed, Is.False); #endif }
public void Install_Successful() { #if NMOCK2 IExtensionHost extensionHostMock = (IExtensionHost)_mocks.NewMock(typeof(IExtensionHost)); IExtensionPoint extensionPointMock = (IExtensionPoint)_mocks.NewMock(typeof(IExtensionPoint)); RowTestAddIn addIn = new RowTestAddIn(); NMock2.Expect.Once.On(extensionHostMock) .Method("GetExtensionPoint").With("TestCaseBuilders") .Will(NMock2.Return.Value(extensionPointMock)); NMock2.Expect.Once.On(extensionPointMock) .Method("Install").With(addIn); bool installed = addIn.Install(extensionHost); _mocks.VerifyAllExpectationsHaveBeenMet(); Assert.That(installed, Is.True); #else DynamicMock extensionHostMock = new DynamicMock(typeof(IExtensionHost)); IExtensionHost extensionHost = (IExtensionHost)extensionHostMock.MockInstance; DynamicMock extensionPointMock = new DynamicMock(typeof(IExtensionPoint)); IExtensionPoint extensionPoint = (IExtensionPoint)extensionPointMock.MockInstance; RowTestAddIn addIn = new RowTestAddIn(); extensionHostMock.ExpectAndReturn("GetExtensionPoint", extensionPointMock.MockInstance, "TestCaseBuilders"); extensionPointMock.Expect("Install", addIn); bool installed = addIn.Install(extensionHost); extensionPointMock.Verify(); extensionHostMock.Verify(); Assert.That(installed, Is.True); #endif }