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


C# Fixture.Get方法代码示例

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


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

示例1: SingleParameterGetReturnsCorrectResult

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

示例2: CreateAccountControllerWillReturnCorrectController

 public void CreateAccountControllerWillReturnCorrectController()
 {
     // Fixture setup
     var fixture = new Fixture().Customize(new CommerceWebCustomization());
     var sut = fixture.CreateAnonymous<CommerceControllerFactory>();
     // Exercise system
     var result = fixture.Get((RequestContext ctx) => sut.CreateController(ctx, "Account"));
     // Verify outcome
     Assert.IsAssignableFrom<AccountController>(result);
     // Teardown
 }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:11,代码来源:CommerceControllerFactoryTest.cs

示例3: GetById

        public void GetById()
        {
            // Arrange
            var controller =
                new Fixture().Customize(new ApiControllerConventions()).Create<ValuesController>();

            // Act
            var result = controller.Get(5);

            // Assert
            Assert.AreEqual("value", result);
        }
开发者ID:jupaol,项目名称:Nutrition,代码行数:12,代码来源:ValuesControllerTest.cs

示例4: 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

示例5: QuadrupleParameterGetReturnsCorrectResult

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

示例6: GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectFirstParameter

        public void GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectFirstParameter()
        {
            // Fixture setup
            sbyte? expectedByte = -56;

            var sut = new Fixture();
            sut.Register<sbyte?>(() => expectedByte);

            var mock = new QueryMock<sbyte?, bool, string, float>();
            mock.OnQuery = (x1, x2, x3) => { Assert.Equal<sbyte?>(expectedByte, x1); return 3646.77f; };
            // Exercise system
            sut.Get((sbyte? x1, bool x2, string x3) => mock.Query(x1, x2, x3));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs

示例7: GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectSecondParameter

        public void GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectSecondParameter()
        {
            // Fixture setup
            float expectedNumber = -927.2f;

            var sut = new Fixture();
            sut.Register<float>(() => expectedNumber);

            var mock = new QueryMock<bool, float, TimeSpan, object>();
            mock.OnQuery = (x1, x2, x3) => { Assert.Equal<float>(expectedNumber, x2); return new object(); };
            // Exercise system
            sut.Get((bool x1, float x2, TimeSpan x3) => mock.Query(x1, x2, x3));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs

示例8: TripleParameterGetReturnsCorrectResult

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

示例9: GetOnQueryWithThreeParametersWillInvokeMethod

        public void GetOnQueryWithThreeParametersWillInvokeMethod()
        {
            // Fixture setup
            bool methodInvoked = false;
            var sut = new Fixture();

            var mock = new QueryMock<object, object, object, object>();
            mock.OnQuery = (x1, x2, x3) => { methodInvoked = true; return new object(); };
            // Exercise system
            sut.Get((object x1, object x2, object x3) => mock.Query(x1, x2, x3));
            // Verify outcome
            Assert.True(methodInvoked, "Query method invoked");
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:14,代码来源:FixtureTest.cs

示例10: GetOnQueryWithTwoParametersWillInvokeMethodWithCorrectSecondParameter

        public void GetOnQueryWithTwoParametersWillInvokeMethodWithCorrectSecondParameter()
        {
            // Fixture setup
            sbyte expectedByte = -29;

            var sut = new Fixture();
            sut.Register<sbyte>(() => expectedByte);

            var mock = new QueryMock<DateTime, sbyte, bool>();
            mock.OnQuery = (x1, x2) => { Assert.Equal<sbyte>(expectedByte, x2); return false; };
            // Exercise system
            sut.Get((DateTime x1, sbyte x2) => mock.Query(x1, x2));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs

示例11: GetCurrencyWillReturnCachingCurrency

        public void GetCurrencyWillReturnCachingCurrency()
        {
            // Fixture setup
            var fixture = new Fixture();

            var currencyProviderStub = new Mock<CurrencyProvider>();
            currencyProviderStub.Setup(cp => cp.GetCurrency(It.IsAny<string>())).Returns(new Mock<Currency>().Object);
            fixture.Register(() => currencyProviderStub.Object);

            var sut = fixture.CreateAnonymous<CachingCurrencyProvider>();
            // Exercise system
            var result = fixture.Get((string currencyCode) => sut.GetCurrency(currencyCode));
            // Verify outcome
            Assert.IsAssignableFrom<CachingCurrency>(result);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:16,代码来源:CachingCurrencyProviderTest.cs

示例12: GetOnQueryWithFourParametersWillInvokeMethodWithCorrectThirdParameter

        public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectThirdParameter()
        {
            // Fixture setup
            var expectedDayOfWeek = DayOfWeek.Friday;

            var sut = new Fixture();
            sut.Register<DayOfWeek>(() => expectedDayOfWeek);

            var mock = new QueryMock<int, float, DayOfWeek, string, LoaderOptimization>();
            mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal<DayOfWeek>(expectedDayOfWeek, x3); return LoaderOptimization.MultiDomain; };
            // Exercise system
            sut.Get((int x1, float x2, DayOfWeek x3, string x4) => mock.Query(x1, x2, x3, x4));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs

示例13: GetOnQueryWithTwoParametersWillInvokeMethod

        public void GetOnQueryWithTwoParametersWillInvokeMethod()
        {
            // Fixture setup
            bool methodInvoked = false;
            var sut = new Fixture();

            var mock = new QueryMock<string, int, long>();
            mock.OnQuery = (x1, x2) => { methodInvoked = true; return 148; };
            // Exercise system
            sut.Get((string x1, int x2) => mock.Query(x1, x2));
            // Verify outcome
            Assert.True(methodInvoked, "Query method invoked");
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:14,代码来源:FixtureTest.cs

示例14: GetOnQueryWithFourParametersWillInvokeMethodWithCorrectFourthParameter

        public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectFourthParameter()
        {
            // Fixture setup
            var expectedNumber = 42;

            var sut = new Fixture();
            sut.Register<int>(() => expectedNumber);

            var mock = new QueryMock<Version, ushort, string, int, PlatformID>();
            mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal<int>(expectedNumber, x4); return PlatformID.WinCE; };
            // Exercise system
            sut.Get((Version x1, ushort x2, string x3, int x4) => mock.Query(x1, x2, x3, x4));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs

示例15: GetOnQueryWithFourParametersWillInvokeMethodWithCorrectSecondParameter

        public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectSecondParameter()
        {
            // Fixture setup
            var expectedDateTimeKind = DateTimeKind.Utc;

            var sut = new Fixture();
            sut.Register<DateTimeKind>(() => expectedDateTimeKind);

            var mock = new QueryMock<Random, DateTimeKind, DateTime, string, float>();
            mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal<DateTimeKind>(expectedDateTimeKind, x2); return 77f; };
            // Exercise system
            sut.Get((Random x1, DateTimeKind x2, DateTime x3, string x4) => mock.Query(x1, x2, x3, x4));
            // Verify outcome (done by mock)
            // Teardown
        }
开发者ID:dhilgarth,项目名称:AutoFixture,代码行数:15,代码来源:FixtureTest.cs


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