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


C# List.OfType方法代码示例

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


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

示例1: IntervalTimePerTimeValuesAttribute

        static IntervalTimePerTimeValuesAttribute()
        {
            var values = new List<IQuantity>();

            var times = new[]
            {
                //TODO: ... however, us, ms, s, min, hr, are not unreasonable to expect ...
                T.Microsecond,
                T.Millisecond,
                T.Second,
                T.Minute,
                T.Hour,
                ////TODO: we do not care about Days or Weeks for purposes of these tests...
                //T.Day,
                //T.Week,
            };

            // TODO: TBD: Avoid scaling too absurdly: may want to be more selective than this...
            var length = times.Length - 2;

            // TODO: TBD: Could also vary the value itself, but this will do for starters...
            const double value = 1e2;

            var first = times.Take(length).ToArray();
            var second = times.Reverse().Take(length).ToArray();

            values.AddRange(from x in first from y in second select new Quantity(value, x, y.Invert()));
            values.AddRange(from y in first from x in second select new Quantity(value, x, y.Invert()));

            Values = values.OfType<object>().ToArray();
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:31,代码来源:IntervalTimePerTimeValuesAttribute.cs

示例2: ShouldBehavior

 public void ShouldBehavior()
 {
     var items = new List<object>();
     items.Add("Hello");
     items.Add(5);
     string item = items.OfType<string>().First();
     Assert.That(item, Is.EqualTo("Hello"));
 }
开发者ID:cessor,项目名称:patterns,代码行数:8,代码来源:SingletonTests.cs

示例3: OfType_LinqExt

		public void OfType_LinqExt ()
		{
			// Filter out those which are note od typw double
			var sampleIntNumbers = new List<object> (){ 1,2,3,4,5,6m,7,8m,9,10};
			var sampleDecimalNumbers = sampleIntNumbers.OfType<decimal> ().ToList ();

			Assert.AreEqual (2, sampleDecimalNumbers.Count ());
	
			Assert.IsInstanceOfType (typeof(List<decimal>), sampleDecimalNumbers);
			Assert.IsInstanceOfType (typeof(decimal), sampleDecimalNumbers.First ());
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:11,代码来源:Conversions.cs

示例4: SetUp

        public void SetUp()
        {
            var configurationSettings = new List<IConfigurationSetting>();

            ConfigurationConfigurator.RegisterConfigurationSettings()
                                     .FromAssemblies(Assembly.GetExecutingAssembly())
                                     .RegisterWithContainer(configurationSettings.Add)
                                     .AllowConfigurationEntriesThatDoNotHaveSettingsClasses(false)
                                     .WithCustomValueParsers(new PersonNameValueParser())
                                     .ExcludeSettingKeys("IgnoredSetting")
                                     .DoYourThing();

            _somePersonSetting = configurationSettings.OfType<SomePersonSetting>().Single();
        }
开发者ID:niing,项目名称:ConfigInjector,代码行数:14,代码来源:WhenConstructingSomePerson.cs

示例5: IndexShouldRenderViewIndex

        public void IndexShouldRenderViewIndex()
        {
            var contents = new List<Content>
                {
                    new TextContent { UrlName = HomeController.Shopfront }
                }.AsQueryable();

            contentRepository.Expect(cr => cr.GetAll()).Return(contents);

            homeController.Index()
                .ReturnsViewResult()
                .ForView("Index")
                .WithModel<CmsViewData>()
                .AssertAreSame(
                    contents.OfType<ITextContent>().First(), 
                    vd => vd.TextContent);

        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:18,代码来源:HomeControllerTests.cs

示例6: Index_ShouldRenderTopContentWithTopPageView

        public void Index_ShouldRenderTopContentWithTopPageView()
        {
            const string urlName = "home_page";

            var contents = new List<Content>
            {
                new TopContent { UrlName = "home_page" }
            }.AsQueryable();

            contentRepository.Expect(cr => cr.GetAll()).Return(contents);

            cmsController.Index(urlName)
                .ReturnsViewResult()
                .ForView("TopPage")
                .WithModel<CmsViewData>()
                .AssertAreSame(
                    contents.OfType<ITextContent>().First(), vd => vd.TextContent);

        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:19,代码来源:CmsControllerTests.cs

示例7: TimePerStepValuesAttribute

        static TimePerStepValuesAttribute()
        {
            var values = new List<IQuantity>();

            var times = new[]
            {
                T.Microsecond,
                T.Millisecond,
                T.Second,
                T.Minute,
                T.Hour,
                //// Day and week are way too extreme for purposes of these tests.
                //T.Day,
                //T.Week,
            };

            const double value = 1e1;

            values.AddRange(from t in times select new Quantity(value, t));

            Values = values.OfType<object>().ToArray();
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:22,代码来源:TimePerStepValuesAttribute.cs

示例8: OfTypeQueryReuse

        public void OfTypeQueryReuse()
        {
            List<int> data = new List<int> { 1, 2 };
            IEnumerable<object> enumerable = data.OfType<object>();

            enumerable.AssertEqual(1, 2);

            data.Add(3);
            enumerable.AssertEqual(1, 2, 3);
        }
开发者ID:barisertekin,项目名称:LINQlone,代码行数:10,代码来源:OfTypeTests.cs

示例9: GetTimeDependentFeatureCoverage

        private static FeatureCoverage GetTimeDependentFeatureCoverage()
        {
            IList<SimpleFeature> features = new List<SimpleFeature>
                                                {
                                                    new SimpleFeature(0, new Point(0, 0)),
                                                    new SimpleFeature(1, new Point(1, 1)),
                                                    new SimpleFeature(2, new Point(2, 2))
                                                };

            var coverage = FeatureCoverage.GetTimeDependentFeatureCoverage<SimpleFeature>();
            
            // set values of feature a variable
            coverage.Features.AddRange(features.OfType<IFeature>());
            coverage.FeatureVariable.SetValues(features);
            return coverage;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:16,代码来源:FeatureCoverageTest.cs

示例10: UnityCanResolveEnumerableOfTypesRegisteredInUnityTest

        public void UnityCanResolveEnumerableOfTypesRegisteredInUnityTest()
        {
            // Setup
            var unityContainer = new UnityContainer();

            // Add composition support for unity
            unityContainer.AddNewExtension<LazySupportExtension>();

            Component1.InstanceCount = 0;
            Component2.InstanceCount = 0;

            unityContainer.RegisterType<IComponent, Component1>("component1");
            unityContainer.RegisterType<IComponent, Component2>("component2");
            unityContainer.RegisterType<IComponent, Component3>();

            var collectionOfLazyUnityComponents = unityContainer.Resolve<IEnumerable<IComponent>>();
            Assert.That(collectionOfLazyUnityComponents, Is.Not.Null);

            Assert.That(Component1.InstanceCount, Is.EqualTo(1));
            Assert.That(Component2.InstanceCount, Is.EqualTo(1));

            var list = new List<IComponent>(collectionOfLazyUnityComponents);
            Assert.That(list.Count, Is.EqualTo(3));

            Assert.That(list.OfType<Component1>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<Component2>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<Component3>().Count(), Is.EqualTo(1));
        }
开发者ID:pwlodek,项目名称:CodeGallery,代码行数:28,代码来源:LazySupportExtensionTests.cs

示例11: ContainersAreNestedAndSorted

        public void ContainersAreNestedAndSorted()
        {
            Type itemType = typeof(Definitions.ItemWithNestedContainers);
            IList<IEditable> editables = new List<IEditable>();
            IList<IEditableContainer> containers = explorer.Find<IEditableContainer>(itemType);
            HierarchyNode<IContainable> rootContainer = hierarchyBuilder.Build(containers.OfType<IContainable>(), editables.OfType<IContainable>());

            var first = rootContainer.Children[0];//.GetContained(null)[0] as IEditableContainer;
            Assert.IsNotNull(first.Current);
            Assert.AreSame(first.Current, containers[1]);
            Assert.AreEqual(3, first.Children.Count);//.GetContained(null).Count);

            var inside3 = first.Children[0];//.GetContained(null)[0] as IEditableContainer;
            Assert.IsNotNull(inside3.Current);
            Assert.AreSame(inside3.Current, containers[0]);
            Assert.AreEqual(0, inside3.Children.Count);//.GetContained(null).Count);

            var inside1 = first.Children[1];//.GetContained(null)[1] as IEditableContainer;
            Assert.IsNotNull(inside1.Current);
            Assert.AreSame(inside1.Current, containers[2]);
            Assert.AreEqual(1, inside1.Children.Count);//.GetContained(null).Count);

            var inside2 = first.Children[2];//.GetContained(null)[2] as IEditableContainer;
            Assert.IsNotNull(inside2.Current);
            Assert.AreSame(inside2.Current, containers[3]);
            Assert.AreEqual(0, inside2.Children.Count);//.GetContained(null).Count);
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:27,代码来源:EditableExplorerTests.cs

示例12: UnityCanResolveEnumerableOfTypesRegisteredInUnityAndMefTest

        public void UnityCanResolveEnumerableOfTypesRegisteredInUnityAndMefTest()
        {
            // Setup
            var unityContainer = new UnityContainer();
            var assemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

            MixedComponent1.InstanceCount = 0;
            MixedComponent2.InstanceCount = 0;
            MixedComponent5.InstanceCount = 0;

            // Add composition support for unity
            unityContainer.AddExtension(new CompositionIntegration(true));
            unityContainer.Configure<CompositionIntegration>().Catalogs.Add(assemblyCatalog);

            unityContainer.RegisterType<IMixedComponent, MixedComponent1>("component1");
            unityContainer.RegisterType<IMixedComponent, MixedComponent2>("component2");
            unityContainer.RegisterType<IMixedComponent, MixedComponent3>();

            var collectionOfLazyUnityComponents = unityContainer.Resolve<IEnumerable<IMixedComponent>>();
            Assert.That(collectionOfLazyUnityComponents, Is.Not.Null);

            Assert.That(MixedComponent1.InstanceCount, Is.EqualTo(1));
            Assert.That(MixedComponent2.InstanceCount, Is.EqualTo(1));
            Assert.That(MixedComponent5.InstanceCount, Is.EqualTo(1));

            var list = new List<IMixedComponent>(collectionOfLazyUnityComponents);
            Assert.That(list.Count, Is.EqualTo(5));
            Assert.That(list.OfType<MixedComponent1>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<MixedComponent2>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<MixedComponent3>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<MixedComponent4>().Count(), Is.EqualTo(1));
            Assert.That(list.OfType<MixedComponent5>().Count(), Is.EqualTo(1));
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:33,代码来源:LazyResolutionTests.cs

示例13: OriginalSourceReturnedForSequenceOfCorrectNonNullableValueType

 public void OriginalSourceReturnedForSequenceOfCorrectNonNullableValueType()
 {
     IEnumerable ints = new List<int>();
     Assert.AreSame(ints, ints.OfType<int>());
 }
开发者ID:mafm,项目名称:edulinq,代码行数:5,代码来源:OfTypeTest.cs

示例14: InvalidContainerReference_IsIgnored

        public void InvalidContainerReference_IsIgnored()
        {
            Type itemType = typeof(N2.Tests.Definitions.Definitions.ItemWithNestedContainers);
            IList<IEditable> editables = new List<IEditable>();
            IList<IEditableContainer> containers = explorer.Find<IEditableContainer>(itemType);
            containers.RemoveAt(2); // inside1

            Assert.DoesNotThrow(() => hierarchyBuilder.Build(containers.OfType<IContainable>(), editables.OfType<IContainable>()));
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:9,代码来源:EditableExplorerTests.cs

示例15: OriginalSourceNotReturnedForNullableValueTypes

 public void OriginalSourceNotReturnedForNullableValueTypes()
 {
     IEnumerable nullableInts = new List<int?>();
     Assert.AreNotSame(nullableInts, nullableInts.OfType<int?>());
 }
开发者ID:mafm,项目名称:edulinq,代码行数:5,代码来源:OfTypeTest.cs


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