public void OnRestartKillAllIntegratorsRefreshConfigAndStartupNewIntegrators()
        {
            integratorMock1.Expect("Start");
            integratorMock2.Expect("Start");

            server.Start();

            integratorMock1.Expect("Stop", true);
            integratorMock1.Expect("WaitForExit");
            integratorMock2.Expect("Stop", true);
            integratorMock2.Expect("WaitForExit");

            configuration = new Configuration();
            configuration.AddProject(project1);
            integratorList = new ProjectIntegratorList();
            integratorList.Add(integrator1);
            configServiceMock.ExpectAndReturn("Load", configuration);
            projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue);

            integratorMock1.Expect("Start");
            integratorMock2.ExpectNoCall("Start");

            server.Restart();

            VerifyAll();
        }
Beispiel #2
0
        public void DontLabelSourceControlIfApplyLabelFalse()
        {
            P4 p4 = CreateP4();

            p4.View       = "//depot/myproject/...";
            p4.ApplyLabel = false;

            processInfoCreatorMock.ExpectNoCall("CreateProcessInfo", typeof(P4), typeof(string));
            mockProcessExecutor.ExpectNoCall("Execute", typeof(ProcessInfo));
            p4.LabelSourceControl(IntegrationResultMother.CreateSuccessful("foo-123"));

            VerifyAll();
        }
Beispiel #3
0
        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 Split_SplitEventNotThrownWithoutCallingSplit()
        {
            DynamicMock viewMock = setup_createEmptyViewMock();

            viewMock.ExpectNoCall("OnSplit", typeof(IRegexView));
            setup_attachMockViewToController(viewMock, m_controller);
        }
Beispiel #5
0
        public void ShouldCallInitializerWithConfiguredWorkingDirectoryIfAlternativeIsConfigured()
        {
            // Setup
            P4 p4 = CreateP4();

            p4.View             = "//depot/myproject/...";
            p4.WorkingDirectory = "p4sOwnWorkingDirectory";
            p4InitializerMock.Expect("Initialize", p4, "myProject", "p4sOwnWorkingDirectory");
            projectMock.ExpectAndReturn("Name", "myProject");
            projectMock.ExpectNoCall("WorkingDirectory");

            // Execute
            p4.Initialize(project);

            // Verify
            VerifyAll();
        }
Beispiel #6
0
        public void WhenATransitionIsNullOrEmptyStringNoAudioIsPlayed()
        {
            AudioFiles files = new AudioFiles();

            files.StillSuccessfulBuildSound = string.Empty;
            files.StillFailingBuildSound    = null;

            new BuildTransitionSoundPlayer(
                stubProjectMonitor,
                (IAudioPlayer)mockAudioPlayer.MockInstance,
                files);

            mockAudioPlayer.ExpectNoCall("Play", typeof(string));
            stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.StillSuccessful));


            mockAudioPlayer.ExpectNoCall("Play", typeof(string));
            stubProjectMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(stubProjectMonitor, BuildTransition.StillFailing));
        }
Beispiel #7
0
        public void ShouldNotCopySourceIfAutoGetSourceNotBeenSetToTrue()
        {
            IIntegrationResult result = Integration("foo", "myWorkingDirectory", "myArtifactDirectory");

            fileSystemMock.ExpectNoCall("Copy", typeof(string), typeof(string));

            sc.GetSource(result);

            fileSystemMock.Verify();
        }
        public void ShouldNotGetSourceIfAutoGetSourceFalse()
        {
            DynamicMock executor = new DynamicMock(typeof(ProcessExecutor));
            AccuRev     accurev  = new AccuRev((ProcessExecutor)executor.MockInstance);

            accurev.AutoGetSource = false;

            executor.ExpectNoCall("Execute", typeof(ProcessInfo));
            accurev.GetSource(new IntegrationResult());
            executor.Verify();
        }
        public void ShouldNotGetSourceIfAutoGetSourceFalse()
        {
            DynamicMock           executor   = new DynamicMock(typeof(ProcessExecutor));
            ExternalSourceControl externalSC = new ExternalSourceControl((ProcessExecutor)executor.MockInstance);

            externalSC.AutoGetSource = false;

            executor.ExpectNoCall("Execute", typeof(ProcessInfo));
            externalSC.GetSource(new IntegrationResult());
            executor.Verify();
        }
Beispiel #10
0
        public void ForceBuildDoesNothingIfProjectIsNotConnected()
        {
            mockProjectMonitor.ExpectAndReturn("ProjectState", ProjectState.NotConnected);
            mockProjectMonitor.ExpectAndReturn("ListBuildParameters", null);
            controller.SelectedProject = projectMonitor;

            mockProjectMonitor.ExpectNoCall("ForceBuild", typeof(Dictionary <string, string>), typeof(string));
            controller.ForceBuild();

            mockProjectMonitor.Verify();
        }
Beispiel #11
0
        public void UpdateUser_Duplicate()
        {
            User user = new User {
                AccessToken = "x", AutoUpdate = true, FacebookUserId = 1234, SteamUserId = "user1"
            };

            _managerMock.ExpectAndReturn("IsDuplicate", true, user.SteamUserId, user.FacebookUserId);
            _managerMock.ExpectNoCall("UpdateUser");

            Assert.That(() => _service.UpdateUser(user), Throws.TypeOf(typeof(DuplicateSteamUserException)));

            _managerMock.Verify();
        }
        public void ShouldOnlyDisposeOnce()
        {
            integratorMock1.Expect("Abort");
            integratorMock2.Expect("Abort");
            ((IDisposable)server).Dispose();

            integratorMock1.ExpectNoCall("Abort");
            integratorMock2.ExpectNoCall("Abort");
            ((IDisposable)server).Dispose();

            integratorMock1.Verify();
            integratorMock2.Verify();
        }
        public void ShouldNotGetSourceIfAutoGetSourceFalse()
        {
            DynamicMock executor  = new DynamicMock(typeof(ProcessExecutor));
            ClearCase   clearCase = new ClearCase((ProcessExecutor)executor.MockInstance);

            clearCase.Executable    = EXECUTABLE;
            clearCase.ViewPath      = VIEWPATH;
            clearCase.AutoGetSource = false;

            executor.ExpectNoCall("Execute", typeof(ProcessInfo));
            clearCase.GetSource(new IntegrationResult());
            executor.Verify();
        }
        public void ShouldStopBuildIfTaskFails()
        {
            IntegrationResult result = IntegrationResultMother.CreateFailed();

            mockTask.Expect("Run", result);

            IMock secondTask = new DynamicMock(typeof(ITask));

            secondTask.ExpectNoCall("Run", typeof(IntegrationResult));

            project.Tasks = new ITask[] { (ITask)mockTask.MockInstance, (ITask)secondTask.MockInstance };
            project.Run(result);
            VerifyAll();
            secondTask.Verify();
        }
Beispiel #15
0
        public void ShouldProxyIfBuildPresent()
        {
            IResponse response = new HtmlFragmentResponse("foo");

            // Setup
            cruiseRequestMock.ExpectAndReturn("BuildName", "myBuild");
            errorViewBuilderMock.ExpectNoCall("BuildView", typeof(string));
            proxiedActionMock.ExpectAndReturn("Execute", response, cruiseRequest);

            // Execute
            IResponse returnedResponse = checkingAction.Execute(cruiseRequest);

            // Verify
            Assert.AreEqual(response, returnedResponse);
            VerifyAll();
        }
Beispiel #16
0
        public void ShouldNotProxyAndShowErrorMessageIfBuildMissing()
        {
            IResponse response = new HtmlFragmentResponse("foo");

            // Setup
            cruiseRequestMock.ExpectAndReturn("BuildName", "");
            errorViewBuilderMock.ExpectAndReturn("BuildView", response, new IsTypeOf(typeof(string)));
            proxiedActionMock.ExpectNoCall("Execute", typeof(ICruiseRequest));

            // Execute
            IResponse returnedResponse = checkingAction.Execute(cruiseRequest);

            // Verify
            Assert.AreEqual(response, returnedResponse);
            VerifyAll();
        }
Beispiel #17
0
        public void ShouldOnlyDisposeOnce()
        {
            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");

            RemoteCruiseServer server = new RemoteCruiseServer((ICruiseServer)mockCruiseServer.MockInstance, configFile);

            ((IDisposable)server).Dispose();

            mockCruiseServer.ExpectNoCall("Dispose");
            ((IDisposable)server).Dispose();
            mockCruiseServer.Verify();
        }
        public void ShouldNotTryAndDeleteClientSpecIfClientSpecNotSet()
        {
            // Setup
            DynamicMock p4Mock = new DynamicMock(typeof(P4));
            P4          p4     = (P4)p4Mock.MockInstance;

            p4.Client = null;

            processInfoCreatorMock.ExpectNoCall("CreateProcessInfo", typeof(P4), typeof(string));
            processExecutorMock.ExpectNoCall("Execute", typeof(ProcessInfo));

            Assert.IsTrue(Directory.Exists(tempDirPath));

            // Execute
            p4Purger.Purge(p4, tempDirPath);

            // Verify
            Assert.IsFalse(Directory.Exists(tempDirPath));
            VerifyAll();
        }
Beispiel #19
0
        public void IfRequireChangesFromAllTrueAndFirstSourceControlHasEmptyChangesThenReturnEmpty()
        {
            //// SETUP
            IntegrationResult from = IntegrationResultMother.CreateSuccessful(DateTime.Now);
            IntegrationResult to   = IntegrationResultMother.CreateSuccessful(DateTime.Now.AddDays(10));

            Modification mod1 = new Modification();

            mod1.Comment = "Testing Multi";

            ArrayList mocks = new ArrayList();

            mocks.Add(CreateModificationsSourceControlMock(new Modification[0], from, to));
            DynamicMock nonCalledMock = new DynamicMock(typeof(ISourceControl));

            nonCalledMock.ExpectNoCall("GetModifications", typeof(IIntegrationResult), typeof(IIntegrationResult));
            mocks.Add(nonCalledMock);

            ArrayList scList = new ArrayList();

            foreach (DynamicMock mock in mocks)
            {
                scList.Add(mock.MockInstance);
            }

            MultiSourceControl multiSourceControl = new MultiSourceControl();

            multiSourceControl.SourceControls        = (ISourceControl[])scList.ToArray(typeof(ISourceControl));
            multiSourceControl.RequireChangesFromAll = true;

            //// EXECUTE
            ArrayList returnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));

            //// VERIFY
            foreach (DynamicMock mock in mocks)
            {
                mock.Verify();
            }

            Assert.AreEqual(0, returnedMods.Count);
        }
        public void ShouldNotApplyBackgroundToRunningStreams()
        {
            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", true);
            daq.ExpectNoCall("ApplyStreamBackground");

            mc.FireParametersChanged(DateTimeOffset.Now, dataVClamp);

            daq.Verify();
        }
        public void ShowHelp()
        {
            ConsoleRunnerArguments consoleArgs = new ConsoleRunnerArguments();

            consoleArgs.UseRemoting = true;
            consoleArgs.ShowHelp    = true;

            Mock mockCruiseServerFactory = new DynamicMock(typeof(ICruiseServerFactory));

            mockCruiseServerFactory.ExpectNoCall("Create", typeof(bool), typeof(string));

            ConsoleRunner runner = new ConsoleRunner(consoleArgs, (ICruiseServerFactory)mockCruiseServerFactory.MockInstance);

            runner.Run();

            // FIXME: should we care for the usage text and the logging implementation?
            // If yes read it from the embedded resource
            //Assert.AreEqual(1, listener.Traces.Count);
            //Assert.IsTrue(listener.Traces[0].ToString().IndexOf(ConsoleRunnerArguments.Usage) > 0, "Wrong message was logged.");

            mockCruiseServerFactory.Verify();
        }
        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);
        }
Beispiel #23
0
        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));
        }
Beispiel #24
0
        public void NoUserPromptForContentPara()
        {
            CheckDisposed();

            // Set up empty content paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                ScrStyleNames.NormalParagraph);

            section.AdjustReferences();

            m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
                                                                      typeof(int[]).FullName, typeInt });
            m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
                                                               typeof(IVwViewConstructor).FullName, typeInt });

            DummyTeStVc stVc       = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);
            bool        fTextAdded = stVc.CallInsertUserPrompt((IVwEnv)m_vwenvMock.MockInstance,
                                                               para.Hvo);

            Assert.IsFalse(fTextAdded, "User prompt was added to empty content para");
            m_vwenvMock.Verify();
        }