当前位置: 首页>>代码示例>>C#>>正文


C# Fixture.Freeze方法代码示例

本文整理汇总了C#中Fixture.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.Freeze方法的具体用法?C# Fixture.Freeze怎么用?C# Fixture.Freeze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fixture的用法示例。


在下文中一共展示了Fixture.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Install_should_install_if_a_package_has_not_been_installed_yet

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

            var proj = fixture.Freeze<Project>();
            var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj);
            var mocks = new MockRepository(MockBehavior.Strict);
            {
                var m = mocks.Create<IVsPackageInstallerServices>();
                m.Setup(_ => _.IsPackageInstalledEx(proj, "Prig", "2.0.0")).Returns(false);
                m.Setup(_ => _.IsPackageInstalled(proj, "Prig")).Returns(false);
                fixture.Inject(m);
            }
            {
                var m = mocks.Create<IVsPackageUninstaller>();
                fixture.Inject(m);
            }
            {
                var m = mocks.Create<IVsPackageInstaller>();
                m.Setup(_ => _.InstallPackage(default(string), proj, "Prig", "2.0.0", false));
                fixture.Inject(m);
            }

            var pwInstllr = fixture.NewProjectWideInstaller();


            // Act
            pwInstllr.Install(pwPkg);


            // Assert
            mocks.VerifyAll();
        }
开发者ID:umaranis,项目名称:Prig,代码行数:34,代码来源:ProjectWideInstallerTest.cs

示例2: NewDisableTestAdapterCommand_should_bind_Text_property_to_CurrentProject_status

        public void NewDisableTestAdapterCommand_should_bind_Text_property_to_CurrentProject_status()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var projName = fixture.Create<string>();
            {
                var m = fixture.Freeze<Mock<Project>>();
                m.Setup(_ => _.Name).Returns(projName);
            }

            var vm = new PrigViewModel();
            var menuCommand = PrigPackage.NewDisableTestAdapterCommand(vm);
            menuCommand.Text = null;

            // Act
            vm.CurrentProject.Value = null;
            var defaultText = menuCommand.Text;
            vm.CurrentProject.Value = fixture.Freeze<Project>();
            var projectSelectedText = menuCommand.Text;

            // Assert
            Assert.IsNotNull(defaultText);
            Assert.AreNotEqual(defaultText, projectSelectedText);
            Assert.That(projectSelectedText, Is.StringMatching(projName));
        }
开发者ID:urasandesu,项目名称:Prig,代码行数:25,代码来源:PrigPackageTest.cs

示例3: Initialize

        public void Initialize()
        {
            _fixture = new Fixture();
            _fixture.Customize(new AutoMoqCustomization());

            _dbSet = _fixture.Freeze<StubDbSet<StubModel>>();
            _context = _fixture.Freeze<Mock<IApplicationContext>>();
            _context.Setup(a => a.Set<StubModel>()).Returns(_dbSet);

            _repository = _fixture.CreateAnonymous<ReadOnlyRepository<StubModel, int>>();
        }
开发者ID:brschwalm,项目名称:Autumn,代码行数:11,代码来源:ReadOnlyRepositoryTests.cs

示例4: Should_return_queue_when_created

        public void Should_return_queue_when_created()
        {
            var queueName = "test";
            var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization());
            var store = fixture.Freeze<IMessageStore>();
            var sut = fixture.Freeze<MessageQueueFactory>();

            A.CallTo(() => store.CreateQueue(queueName)).Returns(true);

            var queue = sut.Create(queueName);
            Assert.AreEqual<string>(queueName, queue.Id);
        }
开发者ID:kellabyte,项目名称:HaywireMQ,代码行数:12,代码来源:MessageQueueFactoryTests.cs

示例5: CreateAddsItemToDb

    public void CreateAddsItemToDb()
    {
      var fixture = new Fixture();
      var db = fixture.Freeze<Db>();
      fixture.Inject(db.Database);
      var item = fixture.Freeze<Item>(x => x.OmitAutoProperties());
      var sut = new AddContentItemCommand();

      sut.Execute(item, new SpecimenContext(fixture));

      db.GetItem(item.ID).Should().NotBeNull();
    }
开发者ID:sergeyshushlyapin,项目名称:Sitecore.FakeDb,代码行数:12,代码来源:AddContentItemCommandTest.cs

示例6: ProductSqlRepositoryFixure

        public ProductSqlRepositoryFixure()
        {
            // Fixture setup
            var fixture = new Fixture()
                .Customize(new AutoMoqCustomization());

            mockProduct = fixture.Freeze<Product>();
            mockProducts = fixture.Freeze<IEnumerable<Product>>();
            IFactory<IProduct> productFactory = new ProductFactory();
            ISqlCommandFactory commandFactory = new SqlCommandFactory();
            ISqlDbInstance db = new MockSqlDbInstance(mockProduct, mockProducts);

            productRepo = new ProductSqlRepository(productFactory, db, commandFactory);
        }
开发者ID:pomonav,项目名称:Heinz95729,代码行数:14,代码来源:ProductSqlRepositoryFixture.cs

示例7: OwnerIsCorrect

        public void OwnerIsCorrect()
        {
            // Fixture setup
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var name = fixture.CreateAnonymous("Owner");
            fixture.Freeze<Mock<IPrincipal>>().SetupGet(p => p.Identity.Name).Returns(name);

            var basket = fixture.Freeze<Basket>();

            var sut = fixture.CreateAnonymous<BasketView>();
            // Exercise system
            string result = sut.Owner;
            // Verify outcome
            Assert.Equal(basket.Owner.Identity.Name, result);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:16,代码来源:BasketViewTest.cs

示例8: Should_return_queue_when_created

        public void Should_return_queue_when_created()
        {
            //var resetEvent = new ManualResetEvent(false);
            var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization());
            var msg = fixture.CreateAnonymous<Message>();
            var sut = fixture.Freeze<InMemoryMessageChannel>();

            object msg2 = null;

            int count = 1;
            var watch = new Stopwatch();
            watch.Start();

            for (int i = 0; i < count; i++)
            {
                sut.BeginReceive(TimeSpan.FromSeconds(1), ar =>
                                                               {
                                                                   msg2 = sut.EndReceive(ar);
                                                                   //resetEvent.Set();
                                                               },
                                 null);

                sut.Send(sut.QueueId, msg);
                //resetEvent.WaitOne(TimeSpan.FromSeconds(5));
            }

            watch.Stop();
            //int rate = count / (int)watch.Elapsed.TotalSeconds;

            Assert.AreSame(msg, msg2);
        }
开发者ID:kellabyte,项目名称:HaywireMQ,代码行数:31,代码来源:InMemoryMessageChannelTests.cs

示例9: ProductNoSqlRepositoryRegressionFixture

        public ProductNoSqlRepositoryRegressionFixture()
        {
            // Fixture setup
            var fixture = new Fixture()
                .Customize(new AutoMoqCustomization());

            mockProduct = fixture.Freeze<Product>();
            mockProducts = fixture.Freeze<IEnumerable<Product>>();
            IFactory<IProduct> productFactory = new ProductFactory();
            ICouchbaseClient db = new CouchbaseClient();
            ILocale locale = fixture.Freeze<DefaultLocale>();
            IRestClient restClient = new RestClient();

            productRepo = new ProductNoSqlRepository(productFactory, db, locale, restClient,
                "http://localhost:9200/unittests/_search");
        }
开发者ID:pomonav,项目名称:Heinz95729,代码行数:16,代码来源:ProductNoSqlRepositoryRegressionFixture.cs

示例10: NonManagedAssembliesAreExcluded

            public void NonManagedAssembliesAreExcluded(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IAssemblyUtility> assemblyUtility,
                [Frozen] Mock<IScriptExecutor> executor,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                const string NonManaged = "non-managed.dll";

                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = "test.csx" };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);
                fileSystem.Setup(x => x.EnumerateFiles(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories))
                          .Returns(new[] { "managed.dll", NonManaged });

                assemblyUtility.Setup(x => x.IsManagedAssembly(It.Is<string>(y => y == NonManaged))).Returns(false);
                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                servicesBuilder.Setup(b => b.Build()).Returns(services);

                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                executor.Verify(i => i.Initialize(It.Is<IEnumerable<string>>(x => !x.Contains(NonManaged)), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<string[]>()), Times.Once());
                executor.Verify(i => i.Terminate(), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:33,代码来源:ExecuteScriptCommandTests.cs

示例11: InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed

            public void InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed(
                [Frozen] Mock<IPackageInstaller> packageInstaller,
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IPackageAssemblyResolver> resolver,
                [Frozen] Mock<IInitializationServices> initServices)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = null };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();
                
                fileSystem.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(CurrentDirectory);
                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);

                initServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                initServices.Setup(i => i.GetPackageInstaller()).Returns(packageInstaller.Object);
                initServices.Setup(i => i.GetPackageAssemblyResolver()).Returns(resolver.Object);
                
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initServices.Object);
      
                resolver.Setup(i => i.GetPackages(It.IsAny<string>())).Returns(new List<IPackageReference>
                    {
                        new PackageReference("a", new FrameworkName(".NETFramework,Version=v4.0"), new Version()),
                        new PackageReference("b", new FrameworkName(".NETFramework,Version=v4.0"), new Version())
                    });
                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                packageInstaller.Verify(i => i.InstallPackages(It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 2), It.IsAny<bool>()), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:33,代码来源:InstallCommandTests.cs

示例12: ScriptExecCommandShouldInvokeWithScriptPassedFromArgs

            public void ScriptExecCommandShouldInvokeWithScriptPassedFromArgs(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IScriptExecutor> executor,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = "test.csx" };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);

                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                servicesBuilder.Setup(b => b.Build()).Returns(services);

                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                executor.Verify(i => i.Initialize(It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<string[]>()), Times.Once());
                executor.Verify(i => i.Terminate(), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:27,代码来源:ExecuteScriptCommandTests.cs

示例13: InstallCommandShouldInstallSinglePackageIfNamePassed

            public void InstallCommandShouldInstallSinglePackageIfNamePassed(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IPackageInstaller> packageInstaller,
                [Frozen] Mock<IPackageAssemblyResolver> resolver,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var args = new Config { AllowPreRelease = false, PackageName = "mypackage", };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                initializationServices.Setup(i => i.GetPackageInstaller()).Returns(packageInstaller.Object);
                initializationServices.Setup(i => i.GetPackageAssemblyResolver()).Returns(resolver.Object);

                servicesBuilder.Setup(b => b.Build()).Returns(services);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                packageInstaller.Verify(
                    i => i.InstallPackages(
                        It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 1 && x.First().PackageId == "mypackage"),
                        It.IsAny<bool>()),
                    Times.Once());
            }
开发者ID:JamesLinus,项目名称:scriptcs,代码行数:30,代码来源:InstallCommandTests.cs

示例14: UpdateWillUpdateRepository

        public void UpdateWillUpdateRepository()
        {
            // Fixture setup
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var presenter = fixture.CreateAnonymous<CampaignItemPresenter>();
            var item = fixture.CreateAnonymous<CampaignItem>();

            fixture.Freeze<Mock<IPresentationMapper>>().Setup(m => m.Map(presenter)).Returns(item);
            var repositoryMock = fixture.Freeze<Mock<CampaignRepository>>();

            var sut = fixture.CreateAnonymous<CampaignPresenter>();
            // Exercise system
            sut.Update(presenter);
            // Verify outcome
            repositoryMock.Verify(r => r.Update(item));
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:17,代码来源:CampaignPresenterTest.cs

示例15: SelectAllWillReturnCorrectResult

        public void SelectAllWillReturnCorrectResult()
        {
            // Fixture setup
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var items = fixture.CreateMany<CampaignItem>().ToList();
            var expectedPresenters = fixture.CreateMany<CampaignItemPresenter>().ToList();

            fixture.Freeze<Mock<CampaignRepository>>().Setup(r => r.SelectAll()).Returns(items);
            fixture.Freeze<Mock<IPresentationMapper>>().Setup(m => m.Map(items)).Returns(expectedPresenters);

            var sut = fixture.CreateAnonymous<CampaignPresenter>();
            // Exercise system
            IEnumerable<CampaignItemPresenter> result = sut.SelectAll();
            // Verify outcome
            Assert.Equal(expectedPresenters, result);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:17,代码来源:CampaignPresenterTest.cs


注:本文中的Fixture.Freeze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。