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


C# Fixture.Inject方法代码示例

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


在下文中一共展示了Fixture.Inject方法的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: Create

 private SchedulerTaskFactory Create(ATaskScheduler scheduler)
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     fixture.Inject(scheduler);
     var factory = fixture.Create<ITaskSchedulerFactory>();
     factory.Create().Returns(scheduler);
     fixture.Inject(factory);
     return fixture.Create<SchedulerTaskFactory>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:9,代码来源:SchedulerTaskFactoryTests.cs

示例3: Get_CorrelationId

 public void Get_CorrelationId()
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var messageId = fixture.Create<IMessageId>();
     var id = fixture.Create<ICorrelationId>();
     fixture.Inject(messageId);
     fixture.Inject(id);
     var test = fixture.Create<SentMessage>();
     Assert.Equal(test.CorrelationId, id);
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:10,代码来源:SentMessageTests.cs

示例4: Create_Default

        public void Create_Default()
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());

            var headers = fixture.Create<IStandardHeaders>();
            var customHeaders = fixture.Create<ICustomHeaders>();
            fixture.Inject(headers);
            fixture.Inject(customHeaders);
            var test = fixture.Create<Headers>();

            Assert.Equal(headers, test.StandardHeaders);
            Assert.Equal(customHeaders, test.CustomHeaders);
        }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:13,代码来源:HeadersTests.cs

示例5: DoubleParameterGetReturnsCorrectResult

 public void DoubleParameterGetReturnsCorrectResult(
     int number,
     string text)
 {
     // Fixture setup
     var fixture = new Fixture();
     fixture.Inject(number);
     fixture.Inject(text);
     // Exercise system
     var actual = fixture.Get((int x, string y) => x + y);
     // Verify outcome
     Assert.Equal(number + text, actual);
     // Teardown
 }
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:14,代码来源:SpecimenQueryTests.cs

示例6: Create

        public void Create()
        {
            var redisId = new GetRedisIncrId();
            var uuId = new GetUuidMessageId();

            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var container = Substitute.For<IContainer>();
            container.GetInstance<GetRedisIncrId>().Returns(redisId);
            container.GetInstance<GetUuidMessageId>().Returns(uuId);
            fixture.Inject(container);

            var factory = fixture.Create<IContainerFactory>();
            factory.Create().ReturnsForAnyArgs(container);

            var options = Helpers.CreateOptions();
            options.MessageIdLocation = MessageIdLocations.RedisIncr;
            var test = new GetMessageIdFactory(factory, options);
            var result = test.Create();
            Assert.IsAssignableFrom(typeof(GetRedisIncrId), result);

            options.MessageIdLocation = MessageIdLocations.Uuid;
            result = test.Create();
            Assert.IsAssignableFrom(typeof(GetUuidMessageId), result);

            options.MessageIdLocation = MessageIdLocations.Custom;
            test.Create();

            options.MessageIdLocation = (MessageIdLocations)99;
            Assert.Throws<DotNetWorkQueueException>(
           delegate
           {
               test.Create();
           });
        }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:34,代码来源:GetMessageIdFactorytests.cs

示例7: Create

            MessageProcessingRpcSend<FakeMessage> Create()
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());

            var sentMessage = fixture.Create<ISentMessage>();
            fixture.Inject(sentMessage);

            var output = fixture.Create<QueueOutputMessage>();
            var sendMessages = fixture.Create<ISendMessages>();
            sendMessages.Send(fixture.Create<IMessage>(),
                  fixture.Create<IAdditionalMessageData>()).ReturnsForAnyArgs(output);
            fixture.Inject(sendMessages);

            fixture.Inject(fixture.Create<ProducerQueue<FakeMessage>>());
            return fixture.Create<MessageProcessingRpcSend<FakeMessage>>();
        }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:16,代码来源:MessageProcessingRpcSendTests.cs

示例8: StartInstalling_should_do_nothing_if_it_will_be_executed_after_the_2nd_time

        public void StartInstalling_should_do_nothing_if_it_will_be_executed_after_the_2nd_time()
        {
            using (var prigConfig = new FileInfo(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\Prig.config")).BeginModifying())
            {
                try
                {
                    // Arrange
                    prigConfig.Info.Delete();
                    Environment.SetEnvironmentVariable("URASANDESU_PRIG_PACKAGE_FOLDER", AppDomain.CurrentDomain.BaseDirectory);

                    var fixture = new Fixture().Customize(new AutoMoqCustomization());
                    {
                        var m = new Mock<IEnvironmentRepository>(MockBehavior.Strict);
                        m.Setup(_ => _.GetPrigPath()).Returns(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\prig.exe"));
                        fixture.Inject(m);
                    }

                    var source = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString("N"));
                    Directory.CreateDirectory(source);

                    var prigExecutor = fixture.NewPrigExecutor();

                    // Act
                    prigExecutor.StartInstalling("TestWindow", source);
                    var result = prigExecutor.StartInstalling("TestWindow", source);

                    // Assert
                    Assert.That(result, Is.StringMatching(@"The specified source:.* has already installed\."));
                }
                finally
                {
                    Environment.SetEnvironmentVariable("URASANDESU_PRIG_PACKAGE_FOLDER", null);
                }
            }
        }
开发者ID:urasandesu,项目名称:Prig,代码行数:35,代码来源:PrigExecutorTest.cs

示例9: StartPacking_should_create_nupkg

        public void StartPacking_should_create_nupkg()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            {
                var m = new Mock<IEnvironmentRepository>(MockBehavior.Strict);
                m.Setup(_ => _.GetNuGetPath()).Returns(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\NuGet.exe"));
                fixture.Inject(m);
            }

            var nugetExecutor = fixture.NewNuGetExecutor();


            // Act
            var result = nugetExecutor.StartPacking(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\NuGet\Prig.nuspec"), AppDomain.CurrentDomain.BaseDirectory);


            // Assert
            var lines = result.Split(new[] { "\r\n" }, StringSplitOptions.None);
            Assert.LessOrEqual(2, lines.Length);
            var match = Regex.Match(lines[1], "'([^']+)'");
            Assert.IsTrue(match.Success);
            var nupkgPath = match.Groups[1].Value;
            Assert.IsTrue(File.Exists(nupkgPath));
            Assert.GreaterOrEqual(TimeSpan.FromSeconds(1), DateTime.Now - File.GetLastWriteTime(nupkgPath));
        }
开发者ID:umaranis,项目名称:Prig,代码行数:26,代码来源:NuGetExecutorTest.cs

示例10: Create

 private SqLiteCommandStringCache Create()
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var connection = fixture.Create<IConnectionInformation>();
     connection.QueueName.Returns("TestQueue");
     fixture.Inject(connection);
     return fixture.Create<SqLiteCommandStringCache>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:SQLiteCommandStringCacheTests.cs

示例11: Create

 private IWorkerHeartBeatNotificationFactory Create(bool enabled)
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var configuration = fixture.Create<IHeartBeatConfiguration>();
     configuration.Enabled.Returns(enabled);
     fixture.Inject(configuration);
     return fixture.Create<WorkerHeartBeatNotificationFactory>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:WorkerHeartBeatNotificationFactoryTests.cs

示例12: Create

 public void Create()
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var providers = new List<IQueueStatusProvider> {fixture.Create<QueueStatusProviderNoOp>()};
     fixture.Inject(providers);
     var test = fixture.Create<DotNetWorkQueue.QueueStatus.QueueStatus>();
     Assert.NotEqual(0, test.Queues.Count());
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:QueueStatusTests.cs

示例13: Create

 public IHeartBeatThreadPoolFactory Create()
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var container = fixture.Create<IContainer>();
     fixture.Inject(container);
     container.GetInstance<IHeartBeatThreadPool>().Returns(fixture.Create<HeartBeatThreadPool>());
     return fixture.Create<HeartBeatThreadPoolFactory>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:HeartBeatThreadPoolFactoryTests.cs

示例14: Create

 private WorkerNotification Create(bool enableRollback = false)
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var configuration = fixture.Create<TransportConfigurationReceive>();
     configuration.MessageRollbackSupported = enableRollback;
     fixture.Inject(configuration);
     return fixture.Create<WorkerNotification>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:WorkerNotificationTests.cs

示例15: Create

 private IAbortWorkerThread Create(bool enableAbort)
 {
     var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     var configuration = fixture.Create<IWorkerConfiguration>();
     configuration.AbortWorkerThreadsWhenStopping.Returns(enableAbort);
     fixture.Inject(configuration);
     return fixture.Create<AbortWorkerThread>();
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:8,代码来源:AbortWorkerThreadTests.cs


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