本文整理汇总了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
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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()));
}
}
示例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);
}
示例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);
}
示例9: ReturnsTrueForDerivingClass
public void ReturnsTrueForDerivingClass()
{
var genericType = typeof (List<>);
var toCheck = new List<string>();
Assert.IsTrue(TypeHelper.IsSubclassOfRawGeneric(genericType, toCheck.GetType()));
}
示例10: ReturnsFalseForNonDerivingClass
public void ReturnsFalseForNonDerivingClass()
{
var genericType = typeof (SavableModelBase<>);
var toCheck = new List<string>();
Assert.IsFalse(TypeHelper.IsSubclassOfRawGeneric(genericType, toCheck.GetType()));
}
示例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);
}
示例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));
}
}
示例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()));
}
示例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()));
}
示例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()));
}