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


C# List.GetType方法代码示例

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


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

示例1: ImplicitlyTypedLocalVariablesAndArraysTest

        public void ImplicitlyTypedLocalVariablesAndArraysTest()
        {
            var i = 5;
            Assert.AreEqual("System.Int32", i.GetType().FullName, "int로 컴파일");

            var s = "ohyecloudy";
            Assert.AreEqual("System.String", s.GetType().FullName, "string으로 컴파일");

            var ia = new[] { 0, 1, 2 };
            Assert.AreEqual("System.Int32[]", ia.GetType().FullName, "int array로 컴파일");

            var istr = new[] { "ohyecloudy", "hello" };
            Assert.AreEqual("System.String[]", istr.GetType().FullName, "string array로 컴파일");

            var expr =
                from c in (new List<Customer>())
                where c.City == "London"
                select c;
            Assert.AreEqual("WhereListIterator`1", expr.GetType().Name);

            var list = new List<int>();
            Assert.AreEqual("List`1", list.GetType().Name);
            Assert.IsTrue(list.GetType().IsGenericType);

            // null 초기화 X
            // var mem = null;

            // 초기화 표현에 사용 X
            // var i = (i = 20); X
            // int i = (i = 20); O

            // multiple declarator 사용 X
            // var i, j, k; X
        }
开发者ID:ohyecloudy,项目名称:csharp-features,代码行数:34,代码来源:ImplicitlyTypedLocalVariablesAndArraysTests.cs

示例2: TypeConverter_CanConvertCommentList_IsTrue

 public void TypeConverter_CanConvertCommentList_IsTrue()
 {
     var converter = new TypeConverter<IEnumerable<Comment>>();
     var list = new List<Comment> {new Comment(), new Comment()};
     var canConvert = converter.CanConvert(list.GetType());
     Assert.IsTrue(canConvert);
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:TypeConverterTests.cs

示例3: TypeConverter_CanConvertImageList_IsTrue

 public void TypeConverter_CanConvertImageList_IsTrue()
 {
     var converter = new TypeConverter<IEnumerable<Image>>();
     var list = new List<Image> {new Image(), new Image()};
     var canConvert = converter.CanConvert(list.GetType());
     Assert.IsTrue(canConvert);
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:TypeConverterTests.cs

示例4: Ad

 public void Ad()
 {
     var s = new string[] { "a", "b" };
     var s1 = new List<string>()
                  {
                      "a",
                      "b"
                  };
     var a = s.GetType();
     var b = s1.GetType();
 }
开发者ID:luqizheng,项目名称:Qi4Net,代码行数:11,代码来源:QCacheTest.cs

示例5: GetGenericArgumentCount_WhenGivenTypeWithOneGenericArgument_ReturnsOne

        public void GetGenericArgumentCount_WhenGivenTypeWithOneGenericArgument_ReturnsOne()
        {
            // ARRANGE
            var item = new List<string>();
            var type = item.GetType();

            // ACT
            var actual = type.GetGeneGetGenricArgumentCount();

            // ASSERT
            Assert.AreEqual(1, actual);
        }
开发者ID:dibley1973,项目名称:StoredProcedureFramework,代码行数:12,代码来源:TypeExtensionTests.cs

示例6: EmptyCollectionTest

        public void EmptyCollectionTest()
        {
            List<int> list = new List<int>();

            try
            {
                list.Sum();
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(e.Message, string.Format("{0} is empty", list.GetType()));
            }
        }
开发者ID:Velmond,项目名称:TelerikAcademy-CSharp,代码行数:13,代码来源:IEnumerableTExtensionsTests.cs

示例7: GetTypeFromTypeName

        public void GetTypeFromTypeName()
        {
            var ps = new List<Persion>();
            var t = ps.GetType();
            Console.WriteLine(t);

            Console.WriteLine(t.FullName);

            var t2 = Type.GetType(t.FullName);
            Assert.AreEqual(t, t2);

            Console.WriteLine(typeof(Dictionary<string, Persion>).FullName);
            var pa1 = new Persion[0];
            var pa2 = new Persion[10];


            var t3 = Type.GetType(pa1.GetType().FullName);
            Console.WriteLine(t3.FullName);
            var t4 = Type.GetType(pa2.GetType().FullName);
            Console.WriteLine(t4.FullName);
        }
开发者ID:fr4nky80,项目名称:LearnCSharp,代码行数:21,代码来源:GenericTypeTest.cs

示例8: RegisterSingleByInstanceNonGeneric_InstanceOfSameTypeAsService_Succeeds

        public void RegisterSingleByInstanceNonGeneric_InstanceOfSameTypeAsService_Succeeds()
        {
            // Arrange
            var container = ContainerFactory.New();

            object impl = new List<int>();

            // Act
            container.RegisterSingleton(impl.GetType(), impl);
        }
开发者ID:khellang,项目名称:SimpleInjector,代码行数:10,代码来源:RegisterSingleByInstanceTests.cs

示例9: ReturnsTrueForDerivingClass

            public void ReturnsTrueForDerivingClass()
            {
                var genericType = typeof (List<>);
                var toCheck = new List<string>();

                Assert.IsTrue(TypeHelper.IsSubclassOfRawGeneric(genericType, toCheck.GetType()));
            }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:TypeHelperFacts.cs

示例10: ReturnsFalseForNonDerivingClass

            public void ReturnsFalseForNonDerivingClass()
            {
                var genericType = typeof (SavableModelBase<>);
                var toCheck = new List<string>();

                Assert.IsFalse(TypeHelper.IsSubclassOfRawGeneric(genericType, toCheck.GetType()));
            }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:TypeHelperFacts.cs

示例11: GetAllSubCommoditiesTest

        public void GetAllSubCommoditiesTest()
        {
            //Commodity target = new Commodity(); // TODO: Initialize to an appropriate value
            List<Commodity> expected = new List<Commodity>
                {
                    new Commodity { CommodityID = 5, Name = "Yellow Wheat",LongName = "",CommodityTypeID = 1, ParentID = 1 },
                    new Commodity { CommodityID = 6, Name = "Green Wheat",LongName = "",CommodityTypeID = 1, ParentID = 1 },
                    new Commodity { CommodityID = 8, Name = "Beans",LongName = "",CommodityTypeID = 1, ParentID = 3 },
               };

            List<Commodity> actual = this.MockCommodityRepository.GetAllSubCommodities();

            Assert.IsInstanceOfType(actual, expected.GetType()); // Test type
            Assert.AreEqual(actual.Count, expected.Count);
            //are all elemetnts found
            foreach (var commodityExp in expected)
            {
                Assert.IsTrue(actual.Contains(actual.Find(c => c.CommodityID == commodityExp.CommodityID)));
            }

            //Assert.AreEqual(expected, actual);
        }
开发者ID:edgecomputing,项目名称:cats-hub-module,代码行数:22,代码来源:CommodityTest.cs

示例12: TestWriteListInt32

        public void TestWriteListInt32()
        {
            List<int> value = new List<int>() { 3155, 3155 };
            var name = "test";
            var attribute = XFireAttributeFactory.Instance.GetAttribute(value.GetType());

            using (var ms = new MemoryStream())
            {
                using (var writer = new BinaryWriter(ms))
                {
                    attribute.WriteAll(writer, name, value);
                }

                var expected = new byte[] { 0x04, 0x74, 0x65, 0x73, 0x74, 0x04, 0x02, 0x02, 0x00,
                                            0x53, 0x0c, 0x00, 0x00, 0x53, 0x0c, 0x00, 0x00 };
                Assert.IsTrue(ms.ToArray().SequenceEqual(expected));
            }
        }
开发者ID:darcymiranda,项目名称:PFire,代码行数:18,代码来源:AttributeWriters.cs

示例13: GetListType

        public void GetListType()
        {
            var li = new List<int>();
            Assert.AreEqual(typeof(int),ReflectionHelper.GetListType(li.GetType()));

            var ls = new List<string>();
            Assert.AreEqual(typeof(string),ReflectionHelper.GetListType(ls.GetType()));

            var aString = "";
            Assert.AreNotEqual(typeof(string),ReflectionHelper.GetListType(aString.GetType()));
        }
开发者ID:rdeago,项目名称:DynamicSugarNet,代码行数:11,代码来源:ReflectionHelper_UnitTests.cs

示例14: IsTypeListOfT

        public void IsTypeListOfT()
        {
            var o = 1;
            Assert.IsFalse(ReflectionHelper.IsTypeListOfT(o.GetType()));

            var li = new List<int>();
            Assert.IsTrue(ReflectionHelper.IsTypeListOfT(li.GetType()));

            var ld = new List<double>();
            Assert.IsTrue(ReflectionHelper.IsTypeListOfT(ld.GetType()));
        }
开发者ID:rdeago,项目名称:DynamicSugarNet,代码行数:11,代码来源:ReflectionHelper_UnitTests.cs

示例15: IsDictionaryOfKV

        public void IsDictionaryOfKV()
        {
            var o = 1;
            Assert.IsFalse(ReflectionHelper.IsDictionaryOfKV(o.GetType()));

            var li = new List<int>();
            Assert.IsFalse(ReflectionHelper.IsDictionaryOfKV(li.GetType()));

            var dsi = new Dictionary<string, int>();
            Assert.IsTrue(ReflectionHelper.IsDictionaryOfKV(dsi.GetType()));
        }
开发者ID:rdeago,项目名称:DynamicSugarNet,代码行数:11,代码来源:ReflectionHelper_UnitTests.cs


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