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


C# Fixture.Customize方法代码示例

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


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

示例1: MessageShouldBeSameAfterSerializationAndDeserialization

        public void MessageShouldBeSameAfterSerializationAndDeserialization()
        {
            var writer = new BinaryWriter(new MemoryStream());
            IMessageFactory msgFactory = new MessageFactory(new Message[]
                {
                    new ISomeServiceComplexRequest()
                });

            var fixture = new Fixture();
            fixture.Customize<ISomeServiceComplexRequest>(ob =>
                ob.With(x => x.datas,
                    fixture.CreateMany<SubData>().ToList()));
            fixture.Customize<ComplexData>(ob => ob
                .With(x => x.SomeArrString, fixture.CreateMany<string>().ToList())
                .With(x => x.SomeArrRec, fixture.CreateMany<SubData>().ToList()));

            var msg = fixture.CreateAnonymous<ISomeServiceComplexRequest>();

            //serialize and deserialize msg1
            msg.Serialize(writer);
            writer.Seek(0, SeekOrigin.Begin);
            var reader = new BinaryReader(writer.BaseStream);
            Message retMsg = msgFactory.Deserialize(reader);

            retMsg.Should().BeOfType<ISomeServiceComplexRequest>();
            msg.ShouldBeEqualTo((ISomeServiceComplexRequest)retMsg);
        }
开发者ID:tlotter,项目名称:MassiveOnlineUniversalServerEngine,代码行数:27,代码来源:MessageSerializationTests.cs

示例2: ShouldProperlyInvokeRequestReplyMethod

        public void ShouldProperlyInvokeRequestReplyMethod()
        {
            #region Arrange
            var fixture = new Fixture();
            fixture.Customize<ISomeServiceComplexRequest>(ob =>
                ob.With(x => x.datas,
                    fixture.CreateMany<SubData>().ToList()));
            fixture.Customize<ComplexData>(ob => ob
                .With(x => x.SomeArrString, fixture.CreateMany<string>().ToList())
                .With(x => x.SomeArrRec, fixture.CreateMany<SubData>().ToList()));

            var inputMsg = fixture.CreateAnonymous<ISomeServiceComplexRequest>();
            var output = inputMsg.data;

            var tcs = new TaskCompletionSource<ComplexData>();
            tcs.SetResult(output);

            var service = Substitute.For<ISomeService>();
            service.Complex(inputMsg.requestId, inputMsg.data, inputMsg.name, inputMsg.datas)
                .Returns(x => tcs.Task);

            #endregion

            //Act
            Task<Message> ret = _protocolDesc.Dispatch(service, inputMsg);

            //Assert
            service.Received(1).Complex(inputMsg.requestId, inputMsg.data, inputMsg.name, inputMsg.datas);
            ret.Should().NotBeNull();
            ret.Status.Should().Be(TaskStatus.RanToCompletion);
            var replyMsg = ret.Result as ISomeServiceComplexReply;
            replyMsg.Should().NotBeNull();
            replyMsg.RetVal.Should().Be(output);
        }
开发者ID:tlotter,项目名称:MassiveOnlineUniversalServerEngine,代码行数:34,代码来源:DispatcherTests.cs

示例3: TestBase

 public TestBase()
 {
     Fixture = new Fixture();
     Fixture.Customize<Feature>(ctx => ctx.OmitAutoProperties());
     Fixture.Customize<Scenario>(ctx => ctx.OmitAutoProperties());
     Scenario = Fixture.Create<Scenario>();
 }
开发者ID:kolbasik,项目名称:NBDD,代码行数:7,代码来源:ScenarioTest.cs

示例4: Setup

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

            Expression<Func<ControllerSample, ModelSample, IEnumerable<ModelSample>>> lambda = (c, m)
               => c.ControllerQueryMethod(m.Id, m.Name, QueryParameter.Is<string>(), QueryParameter.Is<int>());

            Expression<Func<ControllerSample, ModelSample, ModelSample>> lambda2 = (c, m)
               => c.ControllerMethodPut(m.Id, m);

            var apiExplorerMoq = new Mock<IApiExplorer>();
            apiExplorerMoq.Setup(_ => _.ApiDescriptions).Returns(new Collection<ApiDescription>()
            {
                new ApiDescription()
                {
                }
            });

            var actionConfiguration = new Mock<IActionConfiguration>();
            actionConfiguration.Setup(_ => _.MappingRules).Returns(() => new List<MappingRule>
            {
                new MappingRule( (MethodCallExpression)lambda.Body, apiExplorerMoq.Object)
                {
                    ApiDescriptions = new List<ApiDescription>()
                    {
                        new ApiDescription()
                        {
                            RelativePath = "/api/{id}?query={query}",
                            HttpMethod = HttpMethod.Get
                        }
                    },
                    Type = MappingRule.RuleType.Default

                },
                new MappingRule( (MethodCallExpression)lambda2.Body, apiExplorerMoq.Object)
                {
                    ApiDescriptions = new List<ApiDescription>()
                    {
                        new ApiDescription()
                        {
                            RelativePath = "/api/prod/{id}",
                            HttpMethod = HttpMethod.Put
                        }
                    },
                    Type = MappingRule.RuleType.Default

                }
            });

            _actionConfiguration = actionConfiguration.Object;
        }
开发者ID:RichieYang,项目名称:NHateoas,代码行数:53,代码来源:LinksGeneratorTest.cs

示例5: CanBeSerialized

        public void CanBeSerialized()
        {
            var fixture = new Fixture();
            fixture.Customize<TestSuite>(ob => ob.Without(tr => tr.SystemErrWrapped).Without(tc => tc.SystemOutWrapped));
            fixture.Customize<TestCase>(ob => ob.Without(tr => tr.SystemErrWrapped).Without(tc => tc.SystemOutWrapped));
            fixture.Customize<ErrorOrFailure>(ob => ob.Without(tr => tr.TextWrapped));
            TestRun obj = fixture.Create(new TestRun());
            var serializer = new XmlSerializer(typeof (TestRun));

            //using (var stream = File.Create("abc.xml"))
            using (var stream = new MemoryStream())
            {
                serializer.Serialize(stream, obj);
            }
        }
开发者ID:arpitgold,项目名称:vstest-junit-logger,代码行数:15,代码来源:JUnitTestLoggerTests.cs

示例6: GetPatientProcedures

        public IEnumerable<PatientProcedure> GetPatientProcedures(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientProcedures)
        {
            fixture.Customize<PatientProcedure>(pp => pp.With(x => x.PatientId, demographic.PatientId)
                                                        .Without(x => x.CptHcpcs));

            var procedures = fixture.CreateMany<PatientProcedure>(randomizer.Next(0, maxNumberOfPatientProcedures + 1)).ToList();
            foreach (var procedure in procedures)
            {
                procedure.ProcedureDate = procedure.ProcedureDate.Date;

                var hasFavoredProcedure = randomizer.NextPercent() <= ChanceOfHavingFavoredProcedure;
                procedure.CptHcpcs = hasFavoredProcedure ? randomizer.NextListElement(_favoredProcedureCodes) : GetRandomProcedure(randomizer);

                var isProcedureRecent = randomizer.NextPercent() <= ChanceOfHavingRecentProcedure;
                if(isProcedureRecent)
                {
                    var oldestRecentDateTime = DateTime.Today.AddMonths(-6);
                    if(procedure.ProcedureDate < oldestRecentDateTime)
                    {
                        var maximumNumberOfDaysForRecent = (int)(DateTime.Today - oldestRecentDateTime).TotalDays;
                        var daysAgo = randomizer.Next(1, maximumNumberOfDaysForRecent);
                        procedure.ProcedureDate = DateTime.Today.AddDays(-daysAgo);
                    }
                }
            }

            return procedures.OrderBy(x => x.ProcedureDate);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:28,代码来源:PatientProcedureBuilder.cs

示例7: SetUp

        public void SetUp()
        {
            "Given a fixture"
                .Given(() =>
                    {
                        Fixture = new Fixture();
                        Fixture.Customize(new AutoMoqCustomization());
                    });

            "And some mock comparers"
                .And(() =>
                    {
                        Inner = Fixture.Freeze<IEnumerable<IComparison>>()
                                       .Select(Mock.Get)
                                       .ToList();

                        Inner.ForEach(
                            m => m.Setup(c => c.CanCompare(It.IsAny<Type>(), It.IsAny<Type>()))
                                  .Returns(false));

                        Inner.ForEach(
                            m => m.Setup(c => c.Compare(It.IsAny<IComparisonContext>(), It.IsAny<object>(), It.IsAny<object>()))
                                  .Returns(ComparisonResult.Inconclusive));
                    });

            "And a CompositeComparer"
                .And(() => SUT = Fixture.Build<CompositeComparison>()
                                        .With(x => x.Comparisons)
                                        .Create());
        }
开发者ID:kzu,项目名称:DeepEqual,代码行数:30,代码来源:CompositComparisonTests.cs

示例8: UnitTestBase

        public UnitTestBase()
        {
            AutoMapperConfiguration.Configure();

            Fixture = new Fixture();
            Fixture.Customize(new AutoFakeItEasyCustomization());
        }
开发者ID:Maceage,项目名称:xUnitSpike,代码行数:7,代码来源:UnitTestBase.cs

示例9: Initialize

 public void Initialize()
 {
     fixture = new Fixture();
     fixture.Customize<usr_CUSTOMERS>(
         customer =>
         customer.With(x => x.password, Tests.SAMPLE_PASSWORD).With(x => x.email, Tests.SAMPLE_EMAIL_ADDRESS));
 }
开发者ID:mamluka,项目名称:JewelryONet,代码行数:7,代码来源:DataBaseCustomerAccountServiceTests.cs

示例10: Setup

        public void Setup()
        {
            var fixture = new Fixture();
            fixture.Customize(new WebModelCustomization());

            _controller = fixture.Create<AccountController>();
        }
开发者ID:screamish,项目名称:ChitChat,代码行数:7,代码来源:AccountControllerTests.cs

示例11: GetPatientTherapies

        public IEnumerable<PatientTherapy> GetPatientTherapies(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientTherapies)
        {
            fixture.Customize<PatientTherapy>(pt => pt.With(x => x.PatientId, demographic.PatientId)
                                                      .Without(x => x.DDID)
                                                      .Without(x => x.RXNorm)
                                                      .Without(x => x.StopDate));

            var therapies = fixture.CreateMany<PatientTherapy>(randomizer.Next(0, maxNumberOfPatientTherapies + 1));
            foreach (var therapy in therapies)
            {
                var daysOnTherapy = randomizer.Next(1, 365);
                therapy.StopDate = new DateTime(Math.Min(therapy.StartDate.AddDays(daysOnTherapy).Ticks, DateTime.Now.Ticks));

                var hasFavoredTherapy = randomizer.NextPercent() <= ChanceOfHavingFavoredCondition;
                if (hasFavoredTherapy)
                {
                    var pair = randomizer.NextDictionaryPair(_favoredTherapies);
                    therapy.NDC = pair.Key;
                    therapy.DrugName = pair.Value;
                }
                else
                {
                    therapy.NDC = NDCGenerator.GetRandomNDC(randomizer);
                }
            }

            return therapies.OrderBy(x => x.StartDate);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:28,代码来源:PatientTherapyBuilder.cs

示例12: FreshenMailBoxTestWithException

        public void FreshenMailBoxTestWithException()
        {
            _imapWorker.Setup(false);

            var r = new ImapCommandResponse();

            var fix = new Fixture();
            fix.Customize(new AutoMoqCustomization());

            var messages = fix.CreateMany<IMessageSummary>().ToList();

            //first fetch throws exception - after closing and opening folders now messages are returned
            //this mirrors how the client has been functioning in real world tests
            inbox.Setup(x => x.FetchAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<MessageSummaryItems>(),
                It.IsAny<CancellationToken>())).ThrowsAsync(new ImapCommandException(r ,"The IMAP server replied to the 'FETCH' command with a 'NO' response."))
                .Callback(() =>
                {
                    inbox.Setup(x => x.FetchAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<MessageSummaryItems>(),
                        It.IsAny<CancellationToken>())).ReturnsAsync(messages);
                });

            _imapWorker.FreshenMailBox();

            inbox.Verify(x => x.CloseAsync(It.Is<bool>(y => y == false), It.IsAny<CancellationToken>()), Times.Exactly(1));
            inbox.Verify(x => x.OpenAsync(It.IsAny<FolderAccess>(), It.IsAny<CancellationToken>()));
        }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:26,代码来源:ImapWorkerTests.cs

示例13: GetPatientUtilizations

        public IEnumerable<PatientUtilization> GetPatientUtilizations(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientUtilizations)
        {
            fixture.Customize<PatientUtilization>(pu => pu.With(x => x.PatientId, demographic.PatientId));

            var utilizations = fixture.CreateMany<PatientUtilization>(randomizer.Next(0, maxNumberOfPatientUtilizations + 1));

            return utilizations.OrderBy(x => x.ActivityDate);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:8,代码来源:PatientUtilizationBuilder.cs

示例14: GetFixture

 public static IFixture GetFixture()
 {
     var fixture = new Fixture();
     fixture.Customizations.Add(new PropertyOmitter());
     return fixture.Customize(
         new CompositeCustomization(
             new AutoNSubstituteCustomization()));
 }
开发者ID:abladon,项目名称:canvas,代码行数:8,代码来源:InlineAutoNSubstituteDataAttribute.cs

示例15: CreatesTemplateItem

    public void CreatesTemplateItem()
    {
      var fixture = new Fixture();
      fixture.Customize(new AutoContentCustomization());

      var template = fixture.Create<TemplateItem>();

      template.Database.GetTemplate(template.ID).Should().NotBeNull();
    }
开发者ID:sergeyshushlyapin,项目名称:Sitecore.FakeDb,代码行数:9,代码来源:AutoContentCustomizationTest.cs


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