當前位置: 首頁>>代碼示例>>C#>>正文


C# MockRepository.InOrder方法代碼示例

本文整理匯總了C#中Moq.MockRepository.InOrder方法的典型用法代碼示例。如果您正苦於以下問題:C# MockRepository.InOrder方法的具體用法?C# MockRepository.InOrder怎麽用?C# MockRepository.InOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Moq.MockRepository的用法示例。


在下文中一共展示了MockRepository.InOrder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Install_should_raise_the_events_for_the_installation_steps_if_skipped

        public void Install_should_raise_the_events_for_the_installation_steps_if_skipped()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwInstl = new MachineWideInstallation("2.0.0");
            fixture.FreezeInstalledEnvironment();
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwInstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(MachineWideProcessResults.Skipped))).Object;


            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Install(mwInstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:22,代碼來源:MachineWideInstallerTest.cs

示例2: Install_should_call_installation_steps_by_a_fixed_sequence

        public void Install_should_call_installation_steps_by_a_fixed_sequence()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var proj = fixture.Freeze<Project>();
            var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj);
            var callback = default(Action);
            var metadataArr = fixture.CreateMany<IVsPackageMetadata>(3).ToArray();
            {
                var m = fixture.Freeze<Mock<IVsPackageInstallerEvents>>();
                callback = () =>
                {
                    m.Raise(_ => _.PackageInstalling += null, metadataArr[0]);
                    m.Raise(_ => _.PackageInstalled += null, metadataArr[1]);
                    m.Raise(_ => _.PackageReferenceAdded += null, metadataArr[2]);
                };
            }
            {
                var m = fixture.Freeze<Mock<IVsPackageInstaller>>();
                m.Setup(_ => _.InstallPackage(It.IsAny<string>(), It.IsAny<Project>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>())).Callback(callback);
            }
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            pwPkg.PackageInstalling += mocks.InOrder<VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[0]))).Object;
            pwPkg.PackageInstalled += mocks.InOrder<VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[1]))).Object;
            pwPkg.PackageReferenceAdded += mocks.InOrder<VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[2]))).Object;

            var pwInstllr = fixture.NewProjectWideInstaller();


            // Act
            pwInstllr.Install(pwPkg);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:38,代碼來源:ProjectWideInstallerTest.cs

示例3: Install_should_call_installation_steps_by_a_fixed_sequence

        public void Install_should_call_installation_steps_by_a_fixed_sequence()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwInstl = new MachineWideInstallation("2.0.0");
            fixture.FreezeUninstalledEnvironment();
            var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()) };
            {
                var m = fixture.Freeze<Mock<IEnvironmentRepository>>();
                m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs);
                m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView)).Returns(RegistryKeyMixin.DummyX86ClassesRootKey);
                m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(RegistryKeyMixin.DummyX86InProcServer32Key);
                m.Setup(_ => _.GetRegistryValue(RegistryKeyMixin.DummyX86InProcServer32Key, null)).Returns(fixture.Create<string>());
            }
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwInstl.Preparing += mocks.InOrder<Action>(order, m => m.Setup(_ => _())).Object;
            mwInstl.ProfilerStatusChecking += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object;
            mwInstl.NuGetPackageCreating += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwInstl.NuGetPackageCreated += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwInstl.NuGetSourceRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object;
            mwInstl.NuGetSourceRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwInstl.EnvironmentVariableRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object;
            mwInstl.EnvironmentVariableRegistered += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object;
            mwInstl.ProfilerRegistering += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object;
            mwInstl.ProfilerRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwInstl.DefaultSourceInstalling += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object;
            mwInstl.DefaultSourceInstalled += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwInstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(It.IsAny<MachineWideProcessResults>()))).Object;

            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Install(mwInstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:41,代碼來源:MachineWideInstallerTest.cs

示例4: Install_should_raise_the_event_to_register_environment_variables_before_and_after

        public void Install_should_raise_the_event_to_register_environment_variables_before_and_after()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwInstl = new MachineWideInstallation("2.0.0");
            fixture.FreezeUninstalledEnvironment();
            var pkgDir = @"C:\ProgramData\chocolatey\lib\Prig";
            var variableName = "URASANDESU_PRIG_PACKAGE_FOLDER";
            var variableValue = pkgDir;
            {
                var m = fixture.Freeze<Mock<IEnvironmentRepository>>();
                m.Setup(_ => _.GetPackageFolder()).Returns(pkgDir);
                m.Setup(_ => _.GetPackageFolderKey()).Returns(variableName);
                m.Setup(_ => _.StorePackageFolder(variableValue));
            }
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwInstl.EnvironmentVariableRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(variableName, variableValue))).Object;
            mwInstl.EnvironmentVariableRegistered += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(variableName, variableValue))).Object;

            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Install(mwInstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:31,代碼來源:MachineWideInstallerTest.cs

示例5: Install_should_raise_the_event_to_register_NuGet_source_before_and_after

        public void Install_should_raise_the_event_to_register_NuGet_source_before_and_after()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwInstl = new MachineWideInstallation("2.0.0");
            var toolsPath = @"C:\ProgramData\chocolatey\lib\Prig\tools";
            fixture.FreezeUninstalledEnvironment(toolsPath);
            var stdout = fixture.Create<string>();
            {
                var m = fixture.Freeze<Mock<INuGetExecutor>>();
                m.Setup(_ => _.StartSourcing(It.IsAny<string>(), It.IsAny<string>())).Returns(stdout);
            }
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwInstl.NuGetSourceRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _("Prig Source", toolsPath))).Object;
            mwInstl.NuGetSourceRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(stdout))).Object;

            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Install(mwInstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:28,代碼來源:MachineWideInstallerTest.cs

示例6: Install_should_raise_the_event_to_create_Nupkg_before_and_after

        public void Install_should_raise_the_event_to_create_Nupkg_before_and_after()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwInstl = new MachineWideInstallation("2.0.0");
            fixture.FreezeUninstalledEnvironment();
            var stdout = fixture.Create<string>();
            {
                var m = fixture.Freeze<Mock<INuGetExecutor>>();
                m.Setup(_ => _.StartPacking(It.IsAny<string>(), It.IsAny<string>())).Returns(stdout);
            }
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwInstl.NuGetPackageCreating += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _("Prig"))).Object;
            mwInstl.NuGetPackageCreated += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(stdout))).Object;

            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Install(mwInstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:27,代碼來源:MachineWideInstallerTest.cs

示例7: Uninstall_should_call_uninstallation_steps_by_a_fixed_sequence

        public void Uninstall_should_call_uninstallation_steps_by_a_fixed_sequence()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mwUninstl = new MachineWideUninstallation("2.0.0");
            fixture.FreezeInstalledEnvironment();
            var mocks = new MockRepository(MockBehavior.Strict);
            var order = new MockOrder();
            mwUninstl.Preparing += mocks.InOrder<Action>(order, m => m.Setup(_ => _())).Object;
            mwUninstl.ProfilerStatusChecking += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object;
            mwUninstl.DefaultSourceUninstalling += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.DefaultSourceUninstalled += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.ProfilerUnregistering += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object;
            mwUninstl.ProfilerUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.EnvironmentVariableUnregistering += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.EnvironmentVariableUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.NuGetSourceUnregistering += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.NuGetSourceUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object;
            mwUninstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(It.IsAny<MachineWideProcessResults>()))).Object;

            var mwInstllr = fixture.NewMachineWideInstaller();


            // Act
            mwInstllr.Uninstall(mwUninstl);


            // Assert
            mocks.VerifyAll();
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:31,代碼來源:MachineWideInstallerTest.cs


注:本文中的Moq.MockRepository.InOrder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。