public void CanAddEventListener() { DynamicMock mock = new DynamicMock( typeof(EventListener) ); mock.Expect( "RunStarted" ); mock.Expect( "RunFinished" ); IExtensionPoint ep = host.GetExtensionPoint("EventListeners"); ep.Install( mock.MockInstance ); host.Listeners.RunStarted( "test", 0 ); host.Listeners.RunFinished( new TestSuiteResult(null, "test") ); mock.Verify(); }
void SetUpCurrentVersion(long version, List<long> appliedVersions, bool assertRollbackIsCalled, bool includeBad) { var providerMock = new DynamicMock(typeof (ITransformationProvider)); providerMock.SetReturnValue("get_MaxVersion", version); providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); _migrator = new Migrator((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), false); // Enlève toutes les migrations trouvée automatiquement _migrator.MigrationsTypes.Clear(); _upCalled.Clear(); _downCalled.Clear(); _migrator.MigrationsTypes.Add(typeof (FirstMigration)); _migrator.MigrationsTypes.Add(typeof (SecondMigration)); _migrator.MigrationsTypes.Add(typeof (ThirdMigration)); _migrator.MigrationsTypes.Add(typeof (FourthMigration)); _migrator.MigrationsTypes.Add(typeof (SixthMigration)); if (includeBad) _migrator.MigrationsTypes.Add(typeof (BadMigration)); }
public void ShouldUseFindsByNameToLocateElementsByName() { DynamicMock driver = new DynamicMock(typeof(IAllDriver)); driver.Expect("FindElementByName", new object[] { "cheese" }); By by = By.Name("cheese"); by.FindElement(driver.MockInstance as IAllDriver); }
// TODO (jimevan): This test is disabled in the Java implementation unit tests. // Is the functionality not implemented? public void ShouldUseXPathToFindByNameIfDriverDoesNotImplementFindsByName() { DynamicMock driver = new DynamicMock(typeof(IOnlyXPath)); driver.Expect("FindElementByXPath", new object[] { "//*[@name='cheese']" }); By by = By.Name("cheese"); by.FindElement(driver.MockInstance as IOnlyXPath); }
public void IsLoginOK_WhenCalled_WritesToLog() { DynamicMock mockLog = new DynamicMock(typeof(ILogger)); mockLog.Expect("Write","login ok: user: u"); var loginManager = new LoginManagerWithMock((ILogger)mockLog.MockInstance); loginManager.IsLoginOK("", ""); mockLog.Verify(); }
public void CanAddDecorator() { DynamicMock mock = new DynamicMock( typeof(ITestDecorator) ); mock.Expect( "Decorate" ); IExtensionPoint ep = host.GetExtensionPoint("TestDecorators"); ep.Install( mock.MockInstance ); host.TestDecorators.Decorate( null, null ); mock.Verify(); }
public void CanAddTestCaseBuilder() { DynamicMock mock = new DynamicMock( typeof(ITestCaseBuilder) ); mock.ExpectAndReturn( "CanBuildFrom", true, null ); mock.Expect( "BuildFrom" ); IExtensionPoint ep = host.GetExtensionPoint("TestCaseBuilders"); ep.Install( mock.MockInstance ); host.TestBuilders.BuildFrom( null ); mock.Verify(); }
public void Analyze_TooShortFileName_CallsWebService() { DynamicMock mockController = new DynamicMock(typeof (IWebService)); mockController.Expect("LogError", "Filename too short:abc.ext"); IWebService mockService = mockController.MockInstance as IWebService; LogAnalyzer log = new LogAnalyzer(mockService); string tooShortFileName="abc.ext"; log.Analyze(tooShortFileName); mockController.Verify(); }
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 IsLoginOK_LoggerThrowsException_WritesToWebService() { DynamicMock stubLog = new DynamicMock(typeof(ILogger)); DynamicMock mockService = new DynamicMock(typeof(IWebService)); stubLog.ExpectAndThrow("Write",new LoggerException("fake exception"),"yo" ); mockService.Expect("Write","got exception"); var loginManager = new LoginManagerWithMockAndStub((ILogger)stubLog.MockInstance, (IWebService) mockService.MockInstance); loginManager.IsLoginOK("", ""); mockService.Verify(); }
public void TestDeleteCity() { List<City> cities = new List<City>(); City city = new City { Name = "New York", DistrictId = 12 }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.ExpectAndReturn("AddCity", 3,city); dynamicMock.SetReturnValue("GetCities", cities); dynamicMock.Expect("DeleteCityById", 2); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); locationService.DeleteCity(2); Assert.AreEqual(3, locationService.AddCity(city)); Assert.AreEqual(0, locationService.GetCities().Count); }
void SetUpCurrentVersion(int version, bool assertRollbackIsCalled) { var providerMock = new DynamicMock(typeof (ITransformationProvider)); providerMock.SetReturnValue("get_CurrentVersion", version); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); _migrationLoader = new MigrationLoader((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), true); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.NonIgnoredMigration)); }
public void TestExport() { m_FileSystem = new DynamicMock(typeof(IFileSystem)); List<Context> selected = new List<Context>(); Context result = new Context(); result.Tokens.Add("a"); result.Tokens.Add("b"); result.Tokens.Add("c"); Context branch = result.Branch("b1"); branch.Tokens.Add("d"); selected.Add(result); IExporter exporter = new CsvExporter(); m_FileSystem.Expect("WriteAllText", @"c:\abc.csv", string.Format(".Word.;b1{0}abc;abcd{0}", Environment.NewLine)); exporter.Export(selected, @"c:\abc.csv", (IFileSystem)m_FileSystem.MockInstance); m_FileSystem.Verify(); }
public void testCommitTransactionCalled() { //STOP -- check with instructor before beginning this test~ //now go break your code -- don't call the 'commit transaction' or the 'update account' methods. Does the test above fail? //use dynamic mocks to verify that these methods are called. //here's an example of creating the credit card service. You'll need another thing just like this for //the account update. These mocks will replace the stub code from the happyPathTest DynamicMock mockCreditCardService = new DynamicMock(typeof (ICreditCardService)); //some expectations int token = 42; String ccNum = "4324 3924 4382 3888"; Decimal amount = 199.99M; mockCreditCardService.ExpectAndReturn("ReserveFunds", token, new Object[2] { ccNum, amount }); mockCreditCardService.Expect("CommitTransaction", new Object[1] { token }); ICreditCardService creditCardServiceInstance = (ICreditCardService) mockCreditCardService.MockInstance; //calls to the actual class under test goes here AccountUpdater au = new AccountUpdater(new StubBalanceService(), creditCardServiceInstance); au.UpdateAccount(ccNum, amount, 3982834); //this should be the last line. mockCreditCardService.Verify(); }
public void ShouldApplyBackgroundToStoppedStreams() { const string units = "V"; const MultiClampInterop.OperatingMode vclampMode = MultiClampInterop.OperatingMode.VClamp; const MultiClampInterop.OperatingMode iclampMode = MultiClampInterop.OperatingMode.IClamp; var c = new Controller(); var mc = new FakeMulticlampCommander(); var vclampBackground = new Measurement(2, -3, units); var background = new Dictionary<MultiClampInterop.OperatingMode, IMeasurement>() { { vclampMode, vclampBackground } }; var dataVClamp = new MultiClampInterop.MulticlampData() { OperatingMode = vclampMode, ExternalCommandSensitivity = 2.5, ExternalCommandSensitivityUnits = MultiClampInterop.ExternalCommandSensitivityUnits.V_V }; var daq = new DynamicMock(typeof(IDAQController)); var s = new DAQOutputStream("test", daq.MockInstance as IDAQController); var mcd = new MultiClampDevice(mc, c, background); mcd.BindStream(s); daq.ExpectAndReturn("get_Running", false); daq.Expect("ApplyStreamBackground", new object[] {s}); mc.FireParametersChanged(DateTimeOffset.Now, dataVClamp); daq.Verify(); }
public void GetParametersFor_CallsParameterSetFilter() { DynamicMock parameterSetFilterMock = new DynamicMock(typeof(IParameterSetFilter)); IParameterSetFilter parameterSetFilter = (IParameterSetFilter) parameterSetFilterMock.MockInstance; parameterProvider.AddParameterSetFilter(parameterSetFilter); parameterSetFilterMock.Expect("Filter", Is.TypeOf(typeof(ParameterSet)), Is.Not.Null); parameterSetFilterMock.Expect("Filter", Is.TypeOf(typeof(ParameterSet)), Is.Not.Null); parameterProvider.GetTestCasesFor(GetTestClassMethod("RowTestMethodWith2Rows")); parameterSetFilterMock.Verify(); }
public void SaveLoan_UpdateLoan_Person_NoGuarantor() { DynamicMock mockInstalmentManager = new DynamicMock(typeof(InstallmentManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Id = 1, Amount = 11, Code = "Test", InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2, StartDate = new DateTime(2009, 1, 1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment> { _installment1, _installment2 }, Guarantors = new List<Guarantor>() }; EntryFee prodEntryFee = new EntryFee(); prodEntryFee.Value = 2; prodEntryFee.Id = 21; prodEntryFee.Name = "Tested"; LoanEntryFee loanEntryFee = new LoanEntryFee(); loanEntryFee.FeeValue = 2; loanEntryFee.ProductEntryFee = prodEntryFee; loanEntryFee.ProductEntryFeeId = 21; loan.LoanEntryFeesList = new List<LoanEntryFee>(); loan.LoanEntryFeesList.Add(loanEntryFee); IClient person = new Person { Active = false }; mockInstalmentManager.Expect("DeleteInstallments", loan.Id, null); mockInstalmentManager.Expect("AddInstallments", loan.InstallmentList, loan.Id, null); mockLoanManager.Expect("UpdateLoan", loan, null); LoanServices loanServices = new LoanServices((InstallmentManager)mockInstalmentManager.MockInstance, null, (LoanManager)mockLoanManager.MockInstance); loanServices.SaveLoan(ref loan, 2, ref person); }
public void SaveLoan_AddLoan_Person_RaisedException_RollBackObjects() { DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Amount = 11, InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2, StartDate = new DateTime(2009, 1, 1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Events = new EventStock(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment> { _installment1, _installment2 } }; IClient person = new Person { Active = false, LoanCycle = 1 }; mockLoanManager.ExpectAndReturn("Add", 1, loan, 2, null); mockClientManager.Expect("UpdateClientStatus", person, null); mockClientManager.Expect("UpdateClientLoanCycle", person, null); LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance); try { loanServices.SaveLoan(ref loan, 2, ref person); //Exception because branchCode is null Assert.Fail(); } catch (Exception) { Assert.AreEqual(0, loan.Id); Assert.AreEqual(DateTime.MinValue, loan.CloseDate); Assert.AreEqual(DateTime.MinValue, loan.CreationDate); Assert.AreEqual(1, person.LoanCycle); } }
public void SaveLoan_AddLoan_Person() { DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Amount = 11, Code = "Test", InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, Events = new EventStock(), NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), LoanEntryFeesList = new List<LoanEntryFee>(), GracePeriod = 2, StartDate = new DateTime(2009,1,1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment>{_installment1,_installment2} }; IClient person = new Person { Active = false, LoanCycle = 1, Branch = new Branch() { Code = "test" } }; mockLoanManager.ExpectAndReturn("Add", 1, loan, 2, null); mockClientManager.Expect("UpdateClientStatus", person, null); mockClientManager.Expect("UpdateClientLoanCycle", person, null); LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance); loanServices.SaveLoan(ref loan, 2, ref person); Assert.AreEqual(1, loan.Id); Assert.AreEqual(new DateTime(2009,2,1),loan.CloseDate); Assert.AreEqual(OContractStatus.Pending, loan.ContractStatus); Assert.AreEqual(1, person.LoanCycle); }
public void UpdateAllInstalmentsDate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, false); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true); NonWorkingDateSingleton.GetInstance("").PublicHolidays = new Dictionary<DateTime, string> {{DateTime.Today.AddDays(-1), "dfsdf"}}; Installment installment = new Installment { Number = 1, CapitalRepayment = 200, InterestsRepayment = 100, FeesUnpaid = 0, ExpectedDate = DateTime.Today.AddDays(-1) }; DynamicMock mockInstalmentManager = new DynamicMock(typeof(InstallmentManager)); mockInstalmentManager.Expect("UpdateInstallment",installment, 1, null, true); List<KeyValuePair<int, Installment>> list = new List<KeyValuePair<int, Installment>> { new KeyValuePair<int, Installment>(1, installment) }; LoanServices loanServices = new LoanServices((InstallmentManager)mockInstalmentManager.MockInstance, null, null); Assert.AreEqual(1, loanServices.UpdateAllInstallmentsDate(list)); }
public void UpdateEconomicActivityButNewNameAlreadyExist() { _dynamicMock = new DynamicMock(typeof(EconomicActivityManager)); EconomicActivity activity = new EconomicActivity { Name = "Services", Parent = new EconomicActivity { Id = 1 } }; _dynamicMock.Expect("UpdateEconomicActivity", activity); _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", true, "Services", 1); _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance; _economicActivityServices = new EconomicActivityServices(_economicActivityManager); _economicActivityServices.ChangeDomainOfApplicationName(activity, "Services"); }
public void TestDeleteDistrictWithCityIn() { List<City> cities = _GetCities(); DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetCities", cities); dynamicMock.Expect("DeleteDistrictById", 2); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual(false, locationService.DeleteDistrict(2)); }
public void TestDeleteDomainWhenDomainHasNoChildrens() { _dynamicMock = new DynamicMock(typeof(EconomicActivityManager)); EconomicActivity activity = new EconomicActivity { Id = 1, Name = "Services", Childrens = new List<EconomicActivity>()}; _dynamicMock.Expect("UpdateEconomicActivity",activity); _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance; _economicActivityServices = new EconomicActivityServices(_economicActivityManager); _economicActivityServices.DeleteEconomicActivity(activity); }
public void TestChangeDomainOfApplicationNameWhenNotInUse() { _dynamicMock = new DynamicMock(typeof(EconomicActivityManager)); EconomicActivity activity = new EconomicActivity { Id = 2, Name = "Services",Parent = new EconomicActivity { Id = 1 }}; _dynamicMock.Expect("UpdateEconomicActivity", activity); _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", false, "GMO agriculture", 1); _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance; _economicActivityServices = new EconomicActivityServices(_economicActivityManager); Assert.AreEqual(true, _economicActivityServices.ChangeDomainOfApplicationName(activity, "GMO agriculture")); }
public void TestDeleteProvinceWithoutDistrictIn() { Province provinceOne = new Province(2, "Pekin"); Province provinceTwo = new Province(8, "Qhinghua"); List<District> districts = new List<District> { new District("Paris",provinceOne), new District("Pekin",provinceOne), new District("Pau",provinceOne) }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetDistricts", districts); dynamicMock.Expect("DeleteProvinceById", 8); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual(true, locationService.DeleteProvince(provinceTwo)); }
public void TestSave() { Document dm = new Document(); dm.Text = "abc"; dm.FileName = @"c:\abc.wordo"; DynamicMock fs = new DynamicMock(typeof (IFileSystem)); fs.Expect("WriteAllText", @"c:\abc.wordo", "abc"); dm.Save((IFileSystem)fs.MockInstance); fs.Verify(); }
public void TestSavingIsValid_TransferAmountIsInvalid() { Assert.Ignore(); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { Id = 1, InterestRate = 0.13, Product = _savingsProduct }; SavingBookContract savingTarget = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { Id = 2, InterestRate = 0.13, Product = _savingsProduct }; _savingManagerMock = new DynamicMock(typeof(SavingManager)); _savingServices = new SavingServices((SavingManager)_savingManagerMock.MockInstance, null, new User { Id = 6 }); _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 99, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (transfer amount < transfer.min)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.TransferAmountIsInvalid, (int)exception.Code); } _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 301, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (transfer amount > transfer.max)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.TransferAmountIsInvalid, (int)exception.Code); } _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 200, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (balance < balance.min)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.BalanceIsInvalid, (int)exception.Code); } }
private void SetUpCurrentVersion(long version, bool assertRollbackIsCalled, bool includeBad) { DynamicMock providerMock = new DynamicMock(typeof(ITransformationProvider)); List<long> appliedVersions = new List<long>(); for (long i = 1; i <= version; i++) { appliedVersions.Add(i); } providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); migrator = new Migrator((ITransformationProvider)providerMock.MockInstance, false, Assembly.GetExecutingAssembly()); // Enlève toutes les migrations trouvée automatiquement migrator.MigrationsTypes.Clear(); UpCalled.Clear(); DownCalled.Clear(); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(FirstMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(SecondMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(ThirdMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(ForthMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(SixthMigration))); if (includeBad) { migrator.MigrationsTypes.Add(new MigrationInfo(typeof(BadMigration))); } }
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 }
public void OutputStreamShouldPropagateOutputConfiguration() { var s = new DAQOutputStream("test"); var device = new DynamicMock(typeof (IExternalDevice)); DateTimeOffset time = DateTime.Now; var config = new List<IPipelineNodeConfiguration>(); device.Expect("DidOutputData", new object[] {s, time, TimeSpan.FromSeconds(0.1), config}); s.Device = device.MockInstance as IExternalDevice; s.DidOutputData(time, TimeSpan.FromSeconds(0.1), config); device.Verify(); }