public void ShouldReturnBuildPluginLinksRelevantToThisProject() { DynamicMock buildPluginMock1 = new DynamicMock(typeof (IBuildPlugin)); DynamicMock buildPluginMock2 = new DynamicMock(typeof (IBuildPlugin)); DynamicMock buildPluginMock3 = new DynamicMock(typeof (IBuildPlugin)); buildPluginMock1.SetupResult("LinkDescription", "Description 1"); buildPluginMock1.SetupResult("NamedActions", new INamedAction[] {action1}); buildPluginMock1.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier)); buildPluginMock2.SetupResult("LinkDescription", "Description 2"); buildPluginMock2.SetupResult("NamedActions", new INamedAction[] {action2}); buildPluginMock2.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier)); buildPluginMock3.SetupResult("IsDisplayedForProject", false, typeof(IProjectSpecifier)); configurationMock.ExpectAndReturn("BuildPlugins", new IBuildPlugin[] { (IBuildPlugin) buildPluginMock1.MockInstance, (IBuildPlugin) buildPluginMock2.MockInstance, (IBuildPlugin) buildPluginMock3.MockInstance }); linkFactoryMock.ExpectAndReturn("CreateBuildLink", link1, buildSpecifier, "Description 1", "Action Name 1"); linkFactoryMock.ExpectAndReturn("CreateBuildLink", link2, buildSpecifier, "Description 2", "Action Name 2"); IAbsoluteLink[] buildLinks = Plugins.GetBuildPluginLinks(buildSpecifier); Assert.AreSame(link1, buildLinks[0]); Assert.AreSame(link2, buildLinks[1]); Assert.AreEqual(2, buildLinks.Length); VerifyAll(); }
public void ShouldOnlyAllowOneThreadToResolveEachType() { TypeToTypeMap sharedMap = new HashtableTypeMap(Hashtable.Synchronized(new Hashtable())); DynamicMock expectedToBeUsed = new DynamicMock(typeof(ImplementationResolver)); expectedToBeUsed.ExpectAndReturn("ResolveImplementation", typeof(TestClass), typeof(TestInterface)); DynamicMock notExpectedToBeUsed = new DynamicMock(typeof(ImplementationResolver)); notExpectedToBeUsed.ExpectNoCall("ResolveImplementation", typeof(Type)); StallingImplementationResolver stallingResolver = new StallingImplementationResolver((ImplementationResolver) expectedToBeUsed.MockInstance); ImplementationResolver resolvingResolver = new CachingImplementationResolver( stallingResolver, sharedMap); ImplementationResolver moochingResolver = new CachingImplementationResolver((ImplementationResolver) notExpectedToBeUsed.MockInstance, sharedMap); ImplementationResolverRunner resolvingRunner = new ImplementationResolverRunner(resolvingResolver, typeof(TestInterface)); Thread resolvingThread = new Thread( new ThreadStart(resolvingRunner.runResolution)); ImplementationResolverRunner moochingRunner = new ImplementationResolverRunner(moochingResolver, typeof(TestInterface)); Thread moochingThread = new Thread( new ThreadStart(moochingRunner.runResolution)); resolvingThread.Start(); moochingThread.Start(); Thread.Sleep(500); // allow moochingThread to catch up to resolvingThread stallingResolver.Resume(); Assert.IsTrue(resolvingThread.Join(200), "Resolving thread did not complete before timeout."); Assert.IsTrue(moochingThread.Join(200), "Mooching thread did not complete before timeout."); expectedToBeUsed.Verify(); notExpectedToBeUsed.Verify(); Assert.AreEqual(typeof(TestClass), resolvingRunner.implementationType); Assert.AreEqual(typeof(TestClass), moochingRunner.implementationType); }
public void SetUp() { stubProjectMonitor = new StubProjectMonitor("project"); mockAudioPlayer = new DynamicMock(typeof(IAudioPlayer)); mockAudioPlayer.Strict = true; }
public void TestSimpleSmtpNegotiation() { SmtpServer smtpserver=new SmtpServer("localhost"); EmailMessage emailMessage=GetTestHtmlAndTextMessage(); IMock mockSmtpProxy = new DynamicMock(typeof(ISmtpProxy)); mockSmtpProxy.ExpectAndReturn("Open", new SmtpResponse(220, "welcome to the mock object server"), null); mockSmtpProxy.ExpectAndReturn("Helo", new SmtpResponse(250, "helo"), Dns.GetHostName()); mockSmtpProxy.ExpectAndReturn("MailFrom", new SmtpResponse(250, "mail from"), emailMessage.FromAddress); foreach (EmailAddress rcpttoaddr in emailMessage.ToAddresses) { mockSmtpProxy.ExpectAndReturn("RcptTo", new SmtpResponse(250, "receipt to"), rcpttoaddr); } mockSmtpProxy.ExpectAndReturn("Data", new SmtpResponse(354, "data open"), null); mockSmtpProxy.ExpectAndReturn("WriteData", new SmtpResponse(250, "data"), emailMessage.ToDataString()); mockSmtpProxy.ExpectAndReturn("Quit", new SmtpResponse(221, "quit"), null); mockSmtpProxy.Expect("Close", null); ISmtpProxy smtpProxy= (ISmtpProxy) mockSmtpProxy.MockInstance; smtpserver.OverrideSmtpProxy(smtpProxy); emailMessage.Send(smtpserver); }
public void Setup() { cruiseRequestWrapperMock = new DynamicMock(typeof(ICruiseRequest)); buildNameRetrieverMock = new DynamicMock(typeof(IBuildNameRetriever)); recentBuildsViewBuilderMock = new DynamicMock(typeof(IRecentBuildsViewBuilder)); pluginLinkCalculatorMock = new DynamicMock(typeof(IPluginLinkCalculator)); velocityViewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator)); linkFactoryMock = new DynamicMock(typeof(ILinkFactory)); linkListFactoryMock = new DynamicMock(typeof(ILinkListFactory)); farmServiceMock = new DynamicMock(typeof(IFarmService)); sideBarViewBuilder = new SideBarViewBuilder( (ICruiseRequest) cruiseRequestWrapperMock.MockInstance, (IBuildNameRetriever) buildNameRetrieverMock.MockInstance, (IRecentBuildsViewBuilder) recentBuildsViewBuilderMock.MockInstance, (IPluginLinkCalculator) pluginLinkCalculatorMock.MockInstance, (IVelocityViewGenerator) velocityViewGeneratorMock.MockInstance, (ILinkFactory) linkFactoryMock.MockInstance, (ILinkListFactory)linkListFactoryMock.MockInstance, (IFarmService) farmServiceMock.MockInstance, null); velocityResponse = new HtmlFragmentResponse("velocity view"); velocityContext = new Hashtable(); links = new IAbsoluteLink[] { new GeneralAbsoluteLink("link")}; serverLinks = new IAbsoluteLink[] { new GeneralAbsoluteLink("link")}; serverSpecifiers = new IServerSpecifier[] {new DefaultServerSpecifier("test")}; }
public void Setup() { cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest)); requestMock = new DynamicMock(typeof(IRequest)); linkFactoryMock = new DynamicMock(typeof(ILinkFactory)); velocityViewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator)); farmServiceMock = new DynamicMock(typeof(IFarmService)); viewBuilder = new TopControlsViewBuilder( (ICruiseRequest) cruiseRequestMock.MockInstance, (ILinkFactory) linkFactoryMock.MockInstance, (IVelocityViewGenerator) velocityViewGeneratorMock.MockInstance, (IFarmService) farmServiceMock.MockInstance, null, null); serverSpecifier = new DefaultServerSpecifier("myServer"); projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "myProject"); buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "myBuild"); expectedVelocityContext = new Hashtable(); response = new HtmlFragmentResponse("foo"); link1 = new GeneralAbsoluteLink("1"); link2 = new GeneralAbsoluteLink("2"); link3 = new GeneralAbsoluteLink("3"); link4 = new GeneralAbsoluteLink("4"); }
public void ShouldBeAbleToSaveProjectsThatALoaderCanLoad() { ExecutableTask builder = new ExecutableTask(); builder.Executable = "foo"; FileSourceControl sourceControl = new FileSourceControl(); sourceControl.RepositoryRoot = "bar"; // Setup Project project1 = new Project(); project1.Name = "Project One"; project1.SourceControl = sourceControl; Project project2 = new Project(); project2.Name = "Project Two"; project2.SourceControl = sourceControl; ProjectList projectList = new ProjectList(); projectList.Add(project1); projectList.Add(project2); DynamicMock mockConfiguration = new DynamicMock(typeof(IConfiguration)); mockConfiguration.ExpectAndReturn("Projects", projectList); FileInfo configFile = new FileInfo(TempFileUtil.CreateTempFile(TempFileUtil.CreateTempDir(this), "loadernet.config")); // Execute DefaultConfigurationFileSaver saver = new DefaultConfigurationFileSaver(new NetReflectorProjectSerializer()); saver.Save((IConfiguration) mockConfiguration.MockInstance, configFile); DefaultConfigurationFileLoader loader = new DefaultConfigurationFileLoader(); IConfiguration configuration2 = loader.Load(configFile); // Verify Assert.IsNotNull (configuration2.Projects["Project One"]); Assert.IsNotNull (configuration2.Projects["Project Two"]); mockConfiguration.Verify(); }
public void Setup() { ProjectStatusOnServer server = new ProjectStatusOnServer(new ProjectStatus("myProject", IntegrationStatus.Success, DateTime.Now), new DefaultServerSpecifier("myServer")); ProjectStatusListAndExceptions statusList = new ProjectStatusListAndExceptions( new ProjectStatusOnServer[] { server }, new CruiseServerException[] { }); farmServiceMock = new DynamicMock(typeof(IFarmService)); farmServiceMock.SetupResult("GetProjectStatusListAndCaptureExceptions", statusList, typeof(IServerSpecifier), typeof(string)); viewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator)); linkFactoryMock = new DynamicMock(typeof(ILinkFactory)); ServerLocation serverConfig = new ServerLocation(); serverConfig.ServerName = "myServer"; configuration.Servers = new ServerLocation[] { serverConfig }; var urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder)); urlBuilderMock.SetupResult("BuildProjectUrl", string.Empty, typeof(string), typeof(IProjectSpecifier)); plugin = new ProjectReportProjectPlugin((IFarmService) farmServiceMock.MockInstance, (IVelocityViewGenerator) viewGeneratorMock.MockInstance, (ILinkFactory) linkFactoryMock.MockInstance, configuration, (ICruiseUrlBuilder)urlBuilderMock.MockInstance); cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest)); cruiseRequest = (ICruiseRequest ) cruiseRequestMock.MockInstance; }
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 SetUp() { mockFarmService = new DynamicMock(typeof (IFarmService)); reportAction = new ForceBuildXmlAction((IFarmService) mockFarmService.MockInstance); cruiseRequestMock = new DynamicMock(typeof (ICruiseRequest)); cruiseRequest = (ICruiseRequest) cruiseRequestMock.MockInstance; }
public void SetUp() { stubProjectMonitor = new StubProjectMonitor("project"); mockLampController = new DynamicMock(typeof(ILampController)); mockLampController.Strict = true; ILampController lampController = mockLampController.MockInstance as ILampController; configuration = new X10Configuration(); configuration.Enabled = true; configuration.StartTime = DateTime.Parse("08:00"); configuration.EndTime = DateTime.Parse("18:00"); configuration.ActiveDays[(int)DayOfWeek.Sunday] = false; configuration.ActiveDays[(int)DayOfWeek.Monday] = true; configuration.ActiveDays[(int)DayOfWeek.Tuesday] = true; configuration.ActiveDays[(int)DayOfWeek.Wednesday] = true; configuration.ActiveDays[(int)DayOfWeek.Thursday] = true; configuration.ActiveDays[(int)DayOfWeek.Friday] = true; configuration.ActiveDays[(int)DayOfWeek.Saturday] = false; stubCurrentTimeProvider = new StubCurrentTimeProvider(); stubCurrentTimeProvider.SetNow(new DateTime(2005, 11, 03, 12, 00, 00)); Assert.AreEqual(DayOfWeek.Thursday, stubCurrentTimeProvider.Now.DayOfWeek); new X10Controller( stubProjectMonitor, stubCurrentTimeProvider, configuration, lampController); }
public void AdjustScrollRange() { DynamicMock rootBox = new DynamicMock(typeof(IVwRootBox)); // This was taken out because it doesn't seem like the views code does this // anymore. It just calls AdjustScrollRange for the original view that changed. // Done as a part of TE-3576 //// result for style pane //rootBox.ExpectAndReturn("Height", 900); //rootBox.ExpectAndReturn("Width", 100); //rootBox.ExpectAndReturn("Height", 1000); //rootBox.ExpectAndReturn("Width", 100); //rootBox.ExpectAndReturn("Height", 1000); //rootBox.ExpectAndReturn("Width", 100); //// result for draft pane //rootBox.ExpectAndReturn("Height", 950); //rootBox.ExpectAndReturn("Width", 100); //rootBox.ExpectAndReturn("Height", 900); //rootBox.ExpectAndReturn("Width", 100); //rootBox.ExpectAndReturn("Height", 1000); //rootBox.ExpectAndReturn("Width", 100); // result for bt pane rootBox.ExpectAndReturn("Height", 1100); rootBox.ExpectAndReturn("Width", 100); rootBox.ExpectAndReturn("Height", 900); rootBox.ExpectAndReturn("Width", 100); rootBox.ExpectAndReturn("Height", 950); rootBox.ExpectAndReturn("Width", 100); using (RootSiteGroup group = new RootSiteGroup()) { DummyBasicView stylePane = new DummyBasicView(); DummyBasicView draftPane = new DummyBasicView(); DummyBasicView btPane = new DummyBasicView(); PrepareView(stylePane, 50, 300, (IVwRootBox)rootBox.MockInstance); PrepareView(draftPane, 150, 300, (IVwRootBox)rootBox.MockInstance); PrepareView(btPane, 150, 300, (IVwRootBox)rootBox.MockInstance); group.AddToSyncGroup(stylePane); group.AddToSyncGroup(draftPane); group.AddToSyncGroup(btPane); group.ScrollingController = btPane; group.Controls.AddRange(new Control[] { stylePane, draftPane, btPane } ); btPane.ScrollMinSize = new Size(100, 1000); btPane.ScrollPosition = new Point(0, 700); // now call AdjustScrollRange on each of the panes. // This simulates what the views code does. // This was taken out because it doesn't seem like the views code does this // anymore. It just calls AdjustScrollRange for the original view that changed. // Done as a part of TE-3576 //stylePane.AdjustScrollRange(null, 0, 0, -100, 500); //draftPane.AdjustScrollRange(null, 0, 0, -50, 500); btPane.AdjustScrollRange(null, 0, 0, 100, 500); Assert.AreEqual(1108, btPane.ScrollMinSize.Height, "Wrong ScrollMinSize"); Assert.AreEqual(800, -btPane.ScrollPosition.Y, "Wrong scroll position"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a simulated range selection /// </summary> /// <param name="hvoPara1"></param> /// <param name="hvoPara2"></param> /// <param name="ichAnchor"></param> /// <param name="ichEnd"></param> /// ------------------------------------------------------------------------------------ public void SetupSelectionForParas(int hvoPara1, int hvoPara2, int ichAnchor, int ichEnd) { CheckDisposed(); DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper)); fakeSelHelper.SetupResult("NumberOfLevels", 1); SelLevInfo[] topInfo = new SelLevInfo[1]; topInfo[0].tag = StTextTags.kflidParagraphs; topInfo[0].hvo = hvoPara1; SelLevInfo[] bottomInfo = new SelLevInfo[1]; bottomInfo[0].tag = StTextTags.kflidParagraphs; bottomInfo[0].hvo = hvoPara2; fakeSelHelper.SetupResult("LevelInfo", topInfo); fakeSelHelper.SetupResult("IchAnchor", ichAnchor); fakeSelHelper.SetupResult("IchEnd", ichEnd); fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo, SelectionHelper.SelLimitType.Top); fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo, SelectionHelper.SelLimitType.Anchor); fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo, SelectionHelper.SelLimitType.Bottom); fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo, SelectionHelper.SelLimitType.End); fakeSelHelper.SetupResultForParams("GetIch", ichAnchor, SelectionHelper.SelLimitType.Top); fakeSelHelper.SetupResultForParams("GetIch", ichEnd, SelectionHelper.SelLimitType.Bottom); m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance; }
public void ShouldUseBuildLogTransformerToGenerateView() { DynamicMock buildLogTransformerMock = new DynamicMock(typeof(IBuildLogTransformer)); DynamicMock cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest)); DynamicMock buildSpecifierMock = new DynamicMock(typeof(IBuildSpecifier)); DynamicMock requestStub = new DynamicMock(typeof(IRequest)); ICruiseRequest cruiseRequest = (ICruiseRequest) cruiseRequestMock.MockInstance; IBuildSpecifier buildSpecifier = (IBuildSpecifier) buildSpecifierMock.MockInstance; IRequest request = (IRequest) requestStub.MockInstance; cruiseRequestMock.ExpectAndReturn("BuildSpecifier", buildSpecifier); cruiseRequestMock.SetupResult("Request", request); requestStub.SetupResult("ApplicationPath", "myAppPath"); Hashtable expectedXsltArgs = new Hashtable(); expectedXsltArgs["applicationPath"] = "myAppPath"; buildLogTransformerMock.ExpectAndReturn("Transform", "transformed", buildSpecifier, new string[] { @"xsl\myxsl.xsl" }, new HashtableConstraint(expectedXsltArgs), null); XslReportBuildAction action = new XslReportBuildAction((IBuildLogTransformer) buildLogTransformerMock.MockInstance, null); action.XslFileName = @"xsl\myxsl.xsl"; Assert.AreEqual("transformed", ((HtmlFragmentResponse)action.Execute(cruiseRequest)).ResponseFragment); buildLogTransformerMock.Verify(); cruiseRequestMock.Verify(); buildSpecifierMock.Verify(); }
public void Init() { m_mock = new DynamicMock(typeof(IIgnoreOrderTest)); m_mock.Expect("Method", new object[] { new IgnoreOrderConstraint(0, 1, 2 )}, new string[] { typeof(int[]).FullName }); }
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 IMock NewDynamicMock(Type type) { DynamicMock mock = new DynamicMock(type); mock.Strict = false; mocks.Add(mock); return mock; }
public void Setup() { slaveServiceMock = new DynamicMock(typeof(IConfigurationService)); cachingConfigurationService = new CachingConfigurationService((IConfigurationService) slaveServiceMock.MockInstance); configurationMock = new DynamicMock(typeof(IConfiguration)); configuration = (IConfiguration) configurationMock.MockInstance; }
public void Init() { m_mock = new DynamicMock(typeof(IIgnoreOrderTest)); m_mock.Expect("Method", new object[] { new IgnoreOrderConstraint(0, 1, 2 )}, new string[] { typeof(int[]).FullName }); m_mock.AdditionalReferences = new string[] { "COMInterfacesTests.dll" }; }
public void Setup() { viewBuilderMock = new DynamicMock(typeof(IDeleteProjectViewBuilder)); showDeleteProjectAction = new ShowDeleteProjectAction((IDeleteProjectViewBuilder) viewBuilderMock.MockInstance); cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest)); cruiseRequest = (ICruiseRequest) cruiseRequestMock.MockInstance; }
public void Setup() { processExecutorMock = new DynamicMock(typeof(ProcessExecutor)); processInfoCreatorMock = new DynamicMock(typeof(IP4ProcessInfoCreator)); p4Purger = new ProcessP4Purger((ProcessExecutor) processExecutorMock.MockInstance, (IP4ProcessInfoCreator) processInfoCreatorMock.MockInstance); tempDirPath = TempFileUtil.CreateTempDir("tempDir"); }
public void NullPortThrowsException() { Mock source = new DynamicMock(typeof(IUnmanagedSource)); source.ExpectNoCall("CreateFile", null, null, null, null, null, null, null); UnmanagedProvider.Source = (IUnmanagedSource) source.MockInstance; new PortStream(null); source.Verify(); }
public void Setup() { urlBuilderMock = new DynamicMock(typeof (IUrlBuilder)); serverSpecifier = new DefaultServerSpecifier("myserver"); projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "myproject"); buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "mybuild"); cruiseUrlBuilder = new DefaultCruiseUrlBuilder((IUrlBuilder) urlBuilderMock.MockInstance); }
public void IfThereIsAnExceptionBuildMessageShouldPublishExceptionMessage() { DynamicMock mock = new DynamicMock(typeof(IMessageBuilder)); mock.ExpectAndThrow("BuildMessage", new Exception("oops"), new IsAnything()); publisher = new EmailPublisher((IMessageBuilder) mock.MockInstance); string message = publisher.CreateMessage(new IntegrationResult()); AssertContains("oops", message); }
public void SetUp() { mockCache = new DynamicMock(typeof (IResponseCache)); mockCache.Strict = true; mockAction = new DynamicMock(typeof (IAction)); mockAction.Strict = true; proxy = new CachingActionProxy((IAction) mockAction.MockInstance, (IResponseCache) mockCache.MockInstance); }
public void SetUp() { queueChangedCount = pollCount = 0; mockServerManager = new DynamicMock(typeof (ICruiseServerManager)); mockServerManager.Strict = true; monitor = new ServerMonitor((ICruiseServerManager) mockServerManager.MockInstance); monitor.Polled += new MonitorServerPolledEventHandler(Monitor_Polled); monitor.QueueChanged += new MonitorServerQueueChangedEventHandler(Monitor_QueueChanged); }
public void Setup() { m_resolver = new DynamicMock(typeof(IOverlappingFileResolver)); m_resolver.Strict = true; m_expectedRemovedFiles = new ArrayList(); m_callCountForVerifyFileRemoved = 0; m_fileList = new ScrSfFileList((IOverlappingFileResolver)m_resolver.MockInstance); m_fileList.FileRemoved += new ScrImportFileEventHandler(VerifyFileRemoved); }
public void Setup() { cruiseManagerWrapperMock = new DynamicMock(typeof(ICruiseManagerWrapper)); serverQueryingBuildRetriever = new ServerQueryingBuildRetriever(((ICruiseManagerWrapper) cruiseManagerWrapperMock.MockInstance)); buildSpecifier = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("s"), "p"), "myBuild"); logContent = "log Content"; }
public void InvalidPortName() { Mock source = new DynamicMock(typeof(IUnmanagedSource)); source.ExpectAndReturn("CreateFile", new IntPtr(2), null, null, null, null, null, null, null, null); source.ExpectAndReturn("GetFileType", FileType.Disk, new IntPtr(2)); UnmanagedProvider.Source = (IUnmanagedSource) source.MockInstance; new PortStream("xpto"); source.Verify(); }
public virtual void SetUp() { CreateProcessExecutorMock(VaultVersionChecker.DefaultExecutable); mockHistoryParser = new DynamicMock(typeof (IHistoryParser)); vault = new VaultVersionChecker((IHistoryParser) mockHistoryParser.MockInstance, (ProcessExecutor) mockProcessExecutor.MockInstance, VaultVersionChecker.EForcedVaultVersion.Vault3); result = IntegrationResultMother.CreateSuccessful("foo"); result.WorkingDirectory = this.DefaultWorkingDirectory; }
public void MethodWithOutParamsVariableCall() { DynamicMock mock = new DynamicMock(typeof(IWithOutParam)); mock.ExpectAndReturn("MethodWithOutParam", null, null, new string[] { "System.String", "System.Int32&" }, new object[] { null, 4711 }); mock.ExpectAndReturn("MethodWithOutParam", null, null, new string[] { "System.String", "System.Int32&" }, new object[] { null, 4712 }); int ret = 0; IWithOutParam obj = (IWithOutParam)mock.MockInstance; obj.MethodWithOutParam("a", out ret); Assertion.AssertEquals(4711, ret); obj.MethodWithOutParam("b", out ret); Assertion.AssertEquals(4712, ret); }
[Test] public void IncorrectParameterConstraintMessage() { try { IMock Constraint = new DynamicMock(typeof(IConstraint)); Constraint.SetupResult("Message", "wee woo"); Constraint.SetupResult("Eval", false, typeof(object)); mock.Expect("x", new IsAnything(), (IConstraint)Constraint.MockInstance); mock.Invoke("x", "hello", "world"); Assertion.Fail("Expected VerifyException"); } catch (VerifyException e) { Assertion.AssertEquals("x() called with incorrect parameter (2)", e.Reason); Assertion.AssertEquals("wee woo", e.Expected); Assertion.AssertEquals("world", e.Actual); } }
public void ReuseGeneratedAssembly() { DynamicMock mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); mock.Ignore("c"); SameClass sc = (SameClass)mock.MockInstance; mock.SetupResult("b", "hello"); Assertion.AssertEquals("hello", sc.A()); mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); sc = (SameClass)mock.MockInstance; mock.ExpectAndReturn("c", true); mock.SetupResult("b", "hello"); AssertEquals("Should have overriden B()", "hello", sc.A()); mock.Verify(); }
[Test] public void HasADefaultNameBasedOnMockedType() { IMock mock = new DynamicMock(typeof(IBlah)); Assertion.AssertEquals("MockIBlah", mock.Name); }
public void CannotCreateMockInstanceWithNonEmptyConstructor() { IMock mock = new DynamicMock(typeof(WithNonEmptyConstructor)); WithNonEmptyConstructor nonEmpty = (WithNonEmptyConstructor)mock.MockInstance; }
[Test] public void CanBeExplicitlyNamed() { IMock mock = new DynamicMock(typeof(IBlah), "XBlah"); Assertion.AssertEquals("XBlah", mock.Name); }