• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IFixture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IFixture的典型用法代码示例。如果您正苦于以下问题:C# IFixture类的具体用法?C# IFixture怎么用?C# IFixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IFixture类属于命名空间,在下文中一共展示了IFixture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: For_ReturnsCombinationOfDepthAndMemberTypesStrings

        public void For_ReturnsCombinationOfDepthAndMemberTypesStrings(
            [Frozen] IGetDepthString getDepthString,
            [Frozen] IGetMemberTypesString getMemberTypesString,
            DefaultGetNodeString sut,
            string depthString,
            string memberTypesString,
            int depth,
            IFixture fixture)
        {
            // Arrange
            fixture.MakeNonRecursive();

            var graphNode = fixture.Create<GraphNode>();

            getDepthString.For(depth).Returns(depthString);
            getMemberTypesString.For(graphNode).Returns(memberTypesString);

            var expectedResult = depthString + memberTypesString;

            // Act
            var result = sut.For(graphNode, depth);

            // Assert
            Assert.Equal(expectedResult, result);
        }
开发者ID:TeaDrivenDev,项目名称:Graphology,代码行数:25,代码来源:DefaultGetNodeStringTests.cs


示例2: Customize

        public void Customize(IFixture fixture)
        {
            var contextFixture = new StructureMapFixture();

            fixture.Register(() => contextFixture);
            fixture.Customizations.Add(new ContainerBuilder(contextFixture.Container));
        }
开发者ID:jvandertil,项目名称:MembershipReboot.Postgres,代码行数:7,代码来源:StructureMapCustomization.cs


示例3: CreateTests

 public override IEnumerable<ITestCase> CreateTests(
     IFixture fixture,
     MethodInfo method
     )
 {
     yield return new MethodTestCase(fixture.Name, method);
 }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:7,代码来源:TestAttribute.cs


示例4: ViewContext

 private static void ViewContext(IFixture fixture)
 {
     fixture.Register<ControllerBase, ViewContext>(
         controllerBase =>
         new ViewContext
             {TempData = new TempDataDictionary(), ViewData = new ViewDataDictionary(), Controller = controllerBase});
 }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:7,代码来源:MvcCustomizations.cs


示例5: Customize

 public void Customize(IFixture fixture)
 {
     fixture.Customize<Mock<MethodInfo>>(c => c
         .Do(stub => stub
             .SetupGet(m => m.ReflectedType.Name)
             .Returns(fixture.CreateAnonymous<string>())));
 }
开发者ID:olcayseker,项目名称:Hyprlinkr,代码行数:7,代码来源:HyprlinkrCustomization.cs


示例6: Customize

        public void Customize(IFixture fixture)
        {
            ControllerDescriptor(fixture);
            ActionDescriptor(fixture);
            ActionExecutedContext(fixture);
            ActionExecutingContext(fixture);
            ViewEngineResult(fixture);
            ViewContext(fixture);
            ControllerBase(fixture);
            IValueProvider(fixture);
            ModelBindingContext(fixture);
            ValueProviderResult(fixture);

            fixture.Customize<ControllerContext>(cc => cc.Without(c => c.DisplayMode));
            fixture.Customize<ExceptionContext>(ec => ec.Without(c => c.DisplayMode));
            fixture.Customize<ResultExecutedContext>(rec => rec.Without(c => c.DisplayMode));
            fixture.Customize<AuthorizationContext>(ac => ac.Without(c => c.DisplayMode));
            fixture.Customize<ResultExecutingContext>(rec => rec.Without(c => c.DisplayMode));

            fixture.Register<HttpContextBase>(
                () => 
                {
                    var mock = new Mock<HttpContextBase>();
                    mock.Setup(m => m.Items).Returns(new Dictionary<string, object>());
                    return mock.Object;
                });
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:27,代码来源:MvcCustomizations.cs


示例7: Customize

 public void Customize(IFixture fixture)
 {
     fixture.Customize<JournaledEvent>(composer => composer
         .FromFactory(() => JournaledEvent.Create(
             new object(),
             (_, type, writer) => writer.WriteLine(fixture.Create("EventPayload")))));
 }
开发者ID:savamura,项目名称:Journalist,代码行数:7,代码来源:JournaledEventCustomization.cs


示例8:

        void ICustomization.Customize(IFixture fixture)
        {
            this.Customize(fixture);

            fixture.Register(() =>
                {
                    var fileSystem = new Mock<IFileSystem>();
                    fileSystem.SetupGet(f => f.PackagesFile).Returns("scriptcs_packages.config");
                    fileSystem.SetupGet(f => f.PackagesFolder).Returns("scriptcs_packages");
                    fileSystem.SetupGet(f => f.BinFolder).Returns("scriptcs_bin");
                    fileSystem.SetupGet(f => f.DllCacheFolder).Returns(".scriptcs_cache");
                    fileSystem.SetupGet(f => f.NugetFile).Returns("scriptcs_nuget.config");
                    fileSystem.SetupGet(f => f.CurrentDirectory).Returns("workingdirectory");
                    fileSystem.Setup(f => f.FileExists(@"workingdirectory\scriptcs_packages\PackageScripts.csx")).Returns(false);
                    fileSystem.Setup(f => f.DirectoryExists(@"workingdirectory\scriptcs_packages")).Returns(true);
                    fileSystem.Setup(f => f.GetWorkingDirectory(It.IsAny<string>())).Returns("workingdirectory");
                    return fileSystem;
                });

            fixture.Register(() =>
                {
                    var composer = new Mock<IScriptLibraryComposer>();
                    composer.SetupGet(c => c.ScriptLibrariesFile).Returns("ScriptLibraries.csx");
                    return composer;
                });
        }
开发者ID:MegaYanuardi,项目名称:scriptcs,代码行数:26,代码来源:ScriptCsMoqCustomization.cs


示例9: Customize

        public void Customize(IFixture fixture)
        {
            fixture.Register<IContactFactory>(
                () =>
                    {
                        var factory = new Mock<IContactFactory>();
                        factory.Setup(f => f.Create(It.IsAny<ID>()))
                            .Returns(
                                (ID id) =>
                                    {
                                        // get facet map
                                        var contactFacetMap = new Dictionary<string, Type>()
                                                {
                                                    {"Personal", typeof(IContactPersonalInfo)},
                                                    {"Addresses", typeof(IContactAddresses)},
                                                    {"Emails", typeof(IContactEmailAddresses)},
                                                    {"Phone Numbers", typeof(IContactPhoneNumbers)},
                                                    {"Picture", typeof(IContactPicture)}
                                                };
                                                    //{"Communication Profile", typeof(IContactCoummunicationProfile)},
                                                    //{"Preferences", typeof(IContactPreferences)},
                                                    //{"SocialProfile", typeof(Sitecore.Social.Connector.Facets.Contact.SocialProfile.ISocialProfileFacet)}

                                        var result = ModelFactory.CreateContact(id, contactFacetMap);
                                        return result;
                                    });

                        return factory.Object;
                    });
        }
开发者ID:freemsly,项目名称:Sitecore-ElasticAnalytics,代码行数:30,代码来源:ContactFactoryCustomization.cs


示例10: ViewModel_ShouldReturnCorrectValue

		public async Task ViewModel_ShouldReturnCorrectValue(
		  IFixture fixture,
			TestSchedulers scheduler)
		{
			//arrange
			const int insertionIndex = 5;
			var initialList = fixture.CreateMany<int>(10).ToArray();
			var addedList = fixture.CreateMany<int>(10).ToArray();
			var expected = initialList.Take(insertionIndex)
									  .Concat(addedList.Reverse())
									  .Concat(initialList.Skip(insertionIndex))
									  .ToArray();
			var notifications = scheduler.CreateColdObservable(addedList.Select((i, ii) => OnNext(Subscribed + 1 + ii, i)).ToArray());
			var sut = new UpdatableObservableViewModelBuilderOptions<int, int[], int>(
				_ => { },
				ct => Task.FromResult(initialList),
				() => notifications,
				scheduler,
				scheduler,
				scheduler)
				.UpdateAction((i, o) => () => o.Insert(insertionIndex, i))
				.ToViewModel();

			//act

			scheduler.Start();
			await sut.RefreshAsync();
			scheduler.AdvanceBy(Disposed);
			var actual = ((IObservableViewModel<ObservableCollection<int>>)sut).CurrentValue;
			//assert

			actual.ShouldAllBeEquivalentTo(expected);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:33,代码来源:UpdatableViewModelTests.cs


示例11: Customize

        /// <summary>Customizes an <see cref="IFixture"/> to enable auto-mocking with NSubstitute.</summary>
        /// <param name="fixture">The fixture upon which to enable auto-mocking.</param>
        public void Customize(IFixture fixture)
        {
            if (fixture == null)
                throw new ArgumentNullException("fixture");

            fixture.ResidueCollectors.Add(Builder);
        }
开发者ID:jpierson,项目名称:AutoFixture,代码行数:9,代码来源:AutoNSubstituteCustomization.cs


示例12: ViewModel_WhenRefreshed_ShouldDisposePreviousNotificationsSubscriptions

		public async Task ViewModel_WhenRefreshed_ShouldDisposePreviousNotificationsSubscriptions(
		  IFixture fixture,
			TestSchedulers scheduler,
			int[] values)
		{
			//arrange
			var notifications = scheduler.CreateColdObservable<int>();
			var sut = new UpdatableObservableViewModelBuilderOptions<int, int[], int>(
				_ => { },
				ct => Task.FromResult(values),
				() => notifications,
				scheduler,
				scheduler,
				scheduler)
				.UpdateAction((i, o) => () => { })
				.ToViewModel();
			const long disposeTime = 805;

			//act

			scheduler.Start();
			await sut.RefreshAsync();
			//we advance to an arbitrary time
			scheduler.AdvanceBy(disposeTime);
			//the subscription to the new observable should happen here
			//the first subscription should be dispose at the current scheduler time
			await sut.RefreshAsync();

			//assert
			notifications.Subscriptions[0].Unsubscribe.Should().Be(disposeTime);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:31,代码来源:UpdatableViewModelTests.cs


示例13: AddFixture

        private void AddFixture(TestAssembly testAssembly, IFixture fixture)
        {
            List<ITestCase> tests = new List<ITestCase>();

            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                foreach (ITestCase test in fixture.CreateTestCases())
                {
                    if (test == null)
                        continue;
                    if (!testCaseFilter.Filter(fixture,test))
                        continue;
                    ITestCase decoratedTest = DecorateTest(fixture, test);
                    tests.Add(decoratedTest);
                }
                testAssembly.AddFixture(fixture, tests);
            }
            catch (Exception ex)
            {
                BadFixture badFixture = new BadFixture(fixture.Name, ex);
                tests.Clear();
                testAssembly.AddFixture(badFixture, tests);
            }
        }
开发者ID:buptkang,项目名称:QuickGraph,代码行数:25,代码来源:TestBatchFactory.cs


示例14: Filter

 public bool Filter(IFixture fixture, ITestCase test)
 {
     foreach (string scope in scopes)
         if (test.Name.ToLower().StartsWith(scope.ToLower()))
             return true;
     return false;
 }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:7,代码来源:ScopeTestCaseFilter.cs


示例15: ConstructWithNullLoggerThrows

 public void ConstructWithNullLoggerThrows(
     IFixture fixture)
 {
     fixture.Inject<ILogger>(null);
     var e = Assert.Throws<TargetInvocationException>(() => fixture.Create<NotifyErrorAttribute>());
     Assert.IsType<ArgumentNullException>(e.InnerException);
 }
开发者ID:jwChung,项目名称:TfsBuilder,代码行数:7,代码来源:NotifyErrorAttributeTest.cs


示例16: CreateTests

 public override IEnumerable<ITestCase> CreateTests(IFixture fixture, MethodInfo method)
 {
     for (int i = 0; i < this.ThreadCount; ++i)
     {
         yield return new MethodTestCase(fixture.Name, method);
     }
 }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:7,代码来源:MultiThreadedTestAttribute.cs


示例17: CreateDomains

 public override void CreateDomains(
     IList<IDomain> domains, 
     ParameterInfo parameter, 
     IFixture fixture)
 {
     domains.Add(Domains.Boolean);
 }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:7,代码来源:UsingBooleanAttribute.cs


示例18: InitialiseBuilder

 internal void InitialiseBuilder(
     IFixture fixture,
     SpecimenProvider sut)
 {
     // Act
     Assert.Same(fixture, sut.Builder);
 }
开发者ID:AutoTestNET,项目名称:AutoTest.ArgumentNullException,代码行数:7,代码来源:SpecimenProviderShould.cs


示例19: SpApiConfiguration

			void ICustomization.Customize( IFixture fixture )
			{
				fixture.Register( () => new SpApiConfiguration(
					ConfigurationManager.AppSettings[ "PortalUsername" ],
					ConfigurationManager.AppSettings[ "PortalPassword" ],
					ConfigurationManager.AppSettings[ "PortalBaseUrl" ] ) );
			}
开发者ID:InishTech,项目名称:Sp.Api,代码行数:7,代码来源:AutoPortalDataAttribute.cs


示例20: Customize

 /// <summary>
 /// Customizes the specified fixture.
 /// </summary>
 /// <param name="fixture">The fixture to customize.</param>
 public void Customize(IFixture fixture)
 {
     foreach (var c in this.Customizations)
     {
         c.Customize(fixture);
     }
 }
开发者ID:ErikSchierboom,项目名称:AutoFixture,代码行数:11,代码来源:CompositeCustomization.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IFlagCollection类代码示例发布时间:2022-05-24
下一篇:
C# IFilterParameterCollection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap