public void SetUp() { modelMock = new DynamicMock(typeof(ILoadImageModel)) { Strict = true }; model = modelMock.MockInstance as ILoadImageModel; imageListChangedConstraint = new SavedTypeOf(typeof(EventDelegate)); modelMock.Expect("SubscribeImageListChanged", imageListChangedConstraint); startConstraint = new SavedTypeOf(typeof(EventDelegate)); modelMock.Expect("SubscribeStart", startConstraint); finishConstraint = new SavedTypeOf(typeof(EventDelegate)); modelMock.Expect("SubscribeFinish", finishConstraint); viewMock = new DynamicMock(typeof(ILoadImageView)) { Strict = true }; view = viewMock.MockInstance as ILoadImageView; loadCommandConstraint = new SavedTypeOf(typeof(EventDelegate)); viewMock.Expect("SubscribeLoadCommand", loadCommandConstraint); new LoadImagePresenter(model, view); }
private void PrepareGoToTransferPageMocks(String actionExt) { browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance); documentMock.ExpectAndReturn("get_url", String.Format("https://www.pekao24.pl/CurrentAccounts.{0}?subpage=93", actionExt)); DynamicMock window = AddElementMock(typeof(IHTMLWindow2)); if (paymentInfo.IsDefinedTransfer == false) { if (actionExt.Equals(".jsp")) { window.Expect("execScript", Settings.Default.Pekao24NotPredefinedJspUrl, "JScript"); } else { window.Expect("execScript", Settings.Default.Pekao24NotPredefinedHtmUrl, "JScript"); } } else { if (actionExt.Equals(".jsp")) { window.Expect("execScript", Settings.Default.Pekao24PredefinedJspUrl, "JScript"); } else { window.Expect("execScript", Settings.Default.Pekao24PredefinedHtmUrl, "JScript"); } } documentMock.ExpectAndReturn("get_parentWindow", window.MockInstance); }
public void PlaysTheCorrectSoundFileWhenBuildTransitionsOccur() { AudioFiles files = new AudioFiles(); files.StillFailingBuildSound = "anotherFailed.wav"; files.StillSuccessfulBuildSound = "anotherSuccess.wav"; files.BrokenBuildSound = "broken.wav"; files.FixedBuildSound = "fixed.wav"; new BuildTransitionSoundPlayer( stubProjectMonitor, (IAudioPlayer)mockAudioPlayer.MockInstance, files); mockAudioPlayer.Expect("Play", files.BrokenBuildSound); stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.Broken)); mockAudioPlayer.Expect("Play", files.FixedBuildSound); stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.Fixed)); mockAudioPlayer.Expect("Play", files.StillFailingBuildSound); stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.StillFailing)); mockAudioPlayer.Expect("Play", files.StillSuccessfulBuildSound); stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.StillSuccessful)); mockAudioPlayer.Verify(); }
public void ShouldSetDifferentHtmlElementsValue() { Dictionary <String, List <int> > expected = PrepareHtmlSelectMock(); DynamicMock inputMock = new DynamicMock(typeof(IHTMLInputElement)); inputMock.Expect("set_value", "inputValue"); inputMock.Expect("set_value", "inputValue"); DynamicMock textAreaMock = new DynamicMock(typeof(IHTMLTextAreaElement)); textAreaMock.Expect("set_value", "textAreaValue"); DynamicMock elementsMock = new DynamicMock(typeof(IHTMLElementCollection)); elementsMock.ExpectAndReturn("get_length", 1); elementsMock.ExpectAndReturn("item", inputMock.MockInstance, null, 0); Util.SetElementValue(inputMock.MockInstance, "inputValue"); Util.SetElementValue(textAreaMock.MockInstance, "textAreaValue"); Util.SetElementValue(elementsMock.MockInstance, "inputValue"); inputMock.Verify(); textAreaMock.Verify(); elementsMock.Verify(); }
public void StopSpecificProject() { stateManagerMock.Expect("RecordProjectAsStopped", "Project 1"); integratorMock1.Expect("Stop", false); server.CruiseManager.Stop("Project 1"); integratorMock1.Verify(); stateManagerMock.Verify(); }
public void ForceBuildIsForwardedOn() { mockServerMonitor.ExpectAndReturn("SessionToken", null); var parameters = new Dictionary <string, string>(); mockProjectManager.Expect("ForceBuild", (string)null, parameters, (string)null); monitor.ForceBuild(parameters, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets up the text we expect to be added to the view in place of the empty paragraph /// </summary> /// <param name="vc">view constructor to use</param> /// <param name="hvo">hvo of the object to create a prompt for</param> /// <param name="frag">fragment id indicating the type of user prompt</param> /// <param name="flid">field id for the view system note dependency</param> /// ------------------------------------------------------------------------------------ private void CreateExpectedUserPrompt(TeStVc vc, int hvo, int frag, int flid) { // Set expectations m_vwenvMock.Expect("NoteDependency", new int[] { hvo }, new int[] { (int)flid }, 1); m_vwenvMock.Expect("AddProp", new object[] { SimpleRootSite.kTagUserPrompt, vc, frag }, new string[] { typeInt, typeof(IVwViewConstructor).FullName, typeInt }); }
public void test_MoveRequest_fromView() { Point point = new Point(1, 2); modelMock.Expect("MoveRequest", point); PointDelegate trigger = moveRequestConstraint.GetInstance as PointDelegate; trigger(point); }
public void PassesThroughLabelSourceControl() { //// SETUP IntegrationResult result = new IntegrationResult(); _mockSC.Expect("LabelSourceControl", result); //// EXECUTE _filteredSourceControl.LabelSourceControl(result); }
public void test_ListOfImagesChanged_inModel() { string[] images = new string[] { "one", "two", "three" }; modelMock.ExpectAndReturn("GetImageNames", images); viewMock.Expect("SetImageList", new IsListEqual(images)); EventDelegate trigger = imageListChangedConstraint.GetInstance as EventDelegate; trigger(); }
public void Synchronize() { m_mainWnd.Expect("PreSynchronize", new IsAnything()); m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything()); m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance); // This should call (Pre)Synchronize m_app.Synchronize(SyncMsg.ksyncUndoRedo, Cache); m_mainWnd.Verify(); }
public void ForceBuildInvokesForceBuildOnTheSelectedProject() { mockProjectMonitor.ExpectAndReturn("ProjectState", ProjectState.Success); mockProjectMonitor.ExpectAndReturn("ListBuildParameters", null); controller.SelectedProject = projectMonitor; mockProjectMonitor.Expect("ForceBuild", (Dictionary <string, string>)null, (string)null); controller.ForceBuild(); mockProjectMonitor.Verify(); }
private void AssertPollingGeneratesAppropriateLights(IntegrationStatus status, ProjectState state, bool redLightOn, bool yellowLightOn, bool greenLightOn) { stubProjectMonitor.IntegrationStatus = status; stubProjectMonitor.ProjectState = state; mockLampController.Expect("RedLightOn", redLightOn); mockLampController.Expect("YellowLightOn", yellowLightOn); mockLampController.Expect("GreenLightOn", greenLightOn); stubProjectMonitor.OnPolled(new MonitorPolledEventArgs(stubProjectMonitor)); mockLampController.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 shouldInvokeStart() { mockProcessor.Expect("Start"); ISelenium selenium = (ISelenium)mockProcessor.MockInstance; FlashSelenium.FlashSelenium flashSelenium = new FlashSelenium.FlashSelenium(selenium, "test"); try { flashSelenium.Start(); } catch { Assert.Fail("Should Not Fail"); } }
public void StartCruiseServerProject() { ConsoleRunnerArguments consoleArgs = new ConsoleRunnerArguments(); Mock mockCruiseServer = new DynamicMock(typeof(ICruiseServer)); mockCruiseServer.Expect("Start"); mockCruiseServer.Expect("WaitForExit"); Mock mockCruiseServerFactory = new DynamicMock(typeof(ICruiseServerFactory)); mockCruiseServerFactory.ExpectAndReturn("Create", mockCruiseServer.MockInstance, consoleArgs.UseRemoting, consoleArgs.ConfigFile); new ConsoleRunner(consoleArgs, (ICruiseServerFactory)mockCruiseServerFactory.MockInstance).Run(); mockCruiseServer.Verify(); }
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(); }
public void ShouldCallPurgerWithGivenWorkingDirectoryIfAlternativeNotSet() { // Setup P4 p4 = CreateP4(); p4.View = "//depot/myproject/..."; p4PurgerMock.Expect("Purge", p4, "workingDirFromProject"); projectMock.ExpectAndReturn("WorkingDirectory", "workingDirFromProject"); // Execute p4.Purge(project); // Verify VerifyAll(); }
private void PrepareGoToTransferPageMocks() { browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance); DynamicMock window = AddElementMock(typeof(IHTMLWindow2)); documentMock.ExpectAndReturn("get_parentWindow", window.MockInstance); if (paymentInfo.IsDefinedTransfer == false) { window.Expect("execScript", MBankProvider.ANY_TRANSFER_SCRIPT, "JScript"); } else { window.Expect("execScript", MBankProvider.DEFINED_TRANSFERS_SCRIPT, "JScript"); } }
private void PrepareGoToTransferPageMocks() { browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance); DynamicMock window = AddElementMock(typeof(IHTMLWindow2)); documentMock.ExpectAndReturn("get_parentWindow", window.MockInstance); if (paymentInfo.IsDefinedTransfer == false) { window.Expect("execScript", "clickMenu('onetime_transfer')", "JScript"); } else { window.Expect("execScript", "clickMenu('payments')", "JScript"); } }
public void ShouldCreateDirectoryBuilderAndPassControlToGeneratorUsingMbUnit() { var expectedOutputPath = Path.Combine( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "TreeSurgeon"), "newProject"); _mockDirectoryBuilder.Expect("CreateDirectory", expectedOutputPath); _mockGenerator.Expect("Generate", "newProject", expectedOutputPath, "treeSurgeonDirectory", "MbUnit"); var outputDirectory = _frontEnd.GenerateDevelopmentTree("newProject", "MbUnit"); Assert.AreEqual(expectedOutputPath, outputDirectory); VerifyAll(); }
public void FormatString() { string s = "this is a test string"; Stream ms = new MemoryStream(); mock1.ExpectAndReturn("get_BodyStream", ms); mock1.ExpectAndReturn("get_BodyStream", ms); mock1.Expect("set_BodyType", 768); mock2.ExpectAndReturn("get_BodyStream", ms); mock2.ExpectAndReturn("get_BodyStream", ms); Message m = TestUtils.CreateMessage(msg1); m.Formatter = new BinaryMessageFormatter(); m.Formatter.Write(m, s); Stream stream = m.BodyStream; Assert.IsTrue(stream.Length > 0); Message m2 = TestUtils.CreateMessage(msg2); m2.Formatter = new BinaryMessageFormatter(); Assert.AreEqual(s, m2.Formatter.Read(m2), "The string did not serialise/deserialise properly"); mock1.Verify(); mock2.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 PollInvokesPollOnAllContainedServers() { monitor1.Expect("Poll"); monitor2.Expect("Poll"); monitor3.Expect("Poll"); aggregator.Poll(); }
private void PrepareSelectDefinedTransferAndGoToTransferPage(int count) { browserMock.ExpectAndReturn("get_Document", documentMock.MockInstance); DynamicMock transfersGrid = AddElementMock(typeof(IHTMLElement)); documentMock.ExpectAndReturn("getElementById", transfersGrid.MockInstance, "BaseDefinedTransfersList"); PrepareGetIdListMocks(count, transfersGrid, "BaseDefinedTransfersList_grid_ctl_"); for (int i = 0; i < count + 1; i++) { DynamicMock transfer = AddElementMock(typeof(IHTMLElement)); documentMock.ExpectAndReturn("getElementById", transfer.MockInstance, "BaseDefinedTransfersList_grid_ctl_" + i + "__"); switch (i) { case 0: transfer.ExpectAndReturn("get_innerHTML", "123" + paymentInfo.DefinedTransferName); break; default: transfer.ExpectAndReturn("get_innerHTML", paymentInfo.DefinedTransferName); break; } } if (count > 0) { DynamicMock transfer = AddElementMock(typeof(IHTMLElement)); transfer.Expect("click"); documentMock.ExpectAndReturn("getElementById", transfer.MockInstance, "BaseDefinedTransfersList_grid_ctl_1_4_exec"); } }
public void ViewManagerCreateView() { #region Mock intialization DynamicMock useCase = new DynamicMock(typeof(IUseCase)); DynamicMock engine = new DynamicMock(typeof(IRegexEngine)); DynamicMock view = new DynamicMock(typeof(IRegexView)); IRegexView viewMockInstance = (IRegexView)view.MockInstance; IUseCase useCaseMockInstance = (IUseCase)useCase.MockInstance; IRegexEngine engineMockInstance = (IRegexEngine)engine.MockInstance; #endregion useCase.ExpectAndReturn("CreateNewView", viewMockInstance); useCase.ExpectAndReturn("CreateNewEngine", engineMockInstance); engine.Expect("AttachView", withSameObjectAs(viewMockInstance)); view.Expect("Init", withSameObjectAs(engineMockInstance)); ViewManager factory = new ViewManager(); IRegexView newView = factory.CreateView(useCaseMockInstance); useCase.Verify(); engine.Verify(); view.Verify(); Assert.AreSame(newView, viewMockInstance, "Returned view is not the same instance as expected"); }
public void LogoutRemovesSessionFromCache() { _sessionMock.ExpectAndReturn("RetrieveFromCache", _sessionToken, _sessionToken); _sessionMock.Expect("RemoveFromCache", _sessionToken); _manager.Logout(_sessionToken); VerifyAll(); }
public void SetupAndTeardownRemotingInfrastructure() { string configFile = CreateTemporaryConfigurationFile(); IMock mockCruiseManager = new RemotingMock(typeof(ICruiseManager)); IMock mockCruiseServer = new DynamicMock(typeof(ICruiseServer)); mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance); mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance); mockCruiseServer.Expect("Dispose"); using (new RemoteCruiseServer((ICruiseServer)mockCruiseServer.MockInstance, configFile)) { Assert.AreEqual(2, ChannelServices.RegisteredChannels.Length); Assert.IsNotNull(ChannelServices.GetChannel("ccnet"), "ccnet channel is missing"); Assert.IsNotNull(ChannelServices.GetChannel("ccnet2"), "ccnet2 channel is missing"); ICruiseManager remoteManager = (ICruiseManager)RemotingServices.Connect(typeof(ICruiseManager), "tcp://localhost:35354/" + RemoteCruiseServer.ManagerUri); Assert.IsNotNull(remoteManager, "cruiseserver should be registered on tcp channel"); remoteManager = (ICruiseManager)RemotingServices.Connect(typeof(ICruiseManager), "http://localhost:35355/" + RemoteCruiseServer.ManagerUri); Assert.IsNotNull(remoteManager, "cruiseserver should be registered on http channel"); } Assert.AreEqual(0, ChannelServices.RegisteredChannels.Length, "all registered channels should be closed."); mockCruiseServer.Verify(); mockCruiseManager.Verify(); }
public void PassesThroughLabelSourceControl() { //// SETUP IntegrationResult result = new IntegrationResult(); DynamicMock mockSC1 = new DynamicMock(typeof(ISourceControl)); mockSC1.Expect("LabelSourceControl", result); DynamicMock mockSC2 = new DynamicMock(typeof(ISourceControl)); mockSC2.Expect("LabelSourceControl", result); ISourceControl[] sourceControls = new ISourceControl[] { (ISourceControl)mockSC1.MockInstance, (ISourceControl)mockSC2.MockInstance }; MultiSourceControl multiSourceControl = new MultiSourceControl(); multiSourceControl.SourceControls = sourceControls; //// EXECUTE multiSourceControl.LabelSourceControl(result); //// VERIFY mockSC1.Verify(); mockSC2.Verify(); }
public void ShouldPassThroughIntegrationCompletedCallToAllSubTriggers() { subTrigger1Mock.Expect("IntegrationCompleted"); subTrigger2Mock.Expect("IntegrationCompleted"); trigger.IntegrationCompleted(); VerifyAll(); }
public void CreateMockForMBRClass() { DynamicMock classMock = new DynamicMock( typeof( MBRClass ) ); MBRClass classInstance = (MBRClass)classMock.MockInstance; classMock.Expect( "SomeMethod" ); classMock.ExpectAndReturn( "AnotherMethod", "Hello World", 5, "hello" ); classMock.ExpectAndReturn( "MethodWithParams", 42, new object[] { new string[] { "the", "answer" } } ); classInstance.SomeMethod(); Assert.AreEqual( "Hello World", classInstance.AnotherMethod( 5, "hello" ) ); Assert.AreEqual( 42, classInstance.MethodWithParams( "the", "answer" ) ); classMock.Verify(); }