本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting.GetType方法的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting.GetType怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting
的用法示例。
在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnonymousTypesTest
public void AnonymousTypesTest()
{
var v = new { Amount = 108, Message = "Hello" };
// read only!
// v.Amount = 110;
Assert.AreEqual("<>f__AnonymousType0`2", v.GetType().Name, "2는 패러매터 숫자를 가리킨다");
Assert.AreEqual("System.Object", v.GetType().BaseType.FullName, "object 상속");
}
示例2: ImplicitArrayAssignmentWithSameTypes
public void ImplicitArrayAssignmentWithSameTypes()
{
//Even though we don't specify types explicitly, the compiler
//will pick one for us
var names = new[] { "John", "Smith" };
Assert.AreEqual(typeof(FILL_ME_IN), names.GetType(), "Determine the type of the array elements to improve your Karma.");
//but only if it can. So this doesn't work
// (Try uncommenting the line below to see how the compiler reacts)
//var array = new[] { "John", 1 };
}
示例3: GetMemberNames_AnonymousType_ReturnsMemberNamesInOrderDefined
public void GetMemberNames_AnonymousType_ReturnsMemberNamesInOrderDefined()
{
var anonymous = new { prop1 = "value1", prop2 = "value2" };
var memberNames = FormatterUtils.GetMemberNames(anonymous.GetType());
Assert.IsNotNull(memberNames);
Assert.AreEqual(2, memberNames.Count);
Assert.AreEqual("prop1", memberNames[0]);
Assert.AreEqual("prop2", memberNames[1]);
}
示例4: IsSimpleType_ComplexTypes_ReturnsFalse
public void IsSimpleType_ComplexTypes_ReturnsFalse()
{
var anonymous = new { prop = "val" };
Assert.IsFalse(FormatterUtils.IsSimpleType(anonymous.GetType()));
Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(Array)));
Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(IEnumerable<>)));
Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(object)));
Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(SimpleTestItem)));
}
示例5: GetEnumerableItemType_ListOfAnonymousObject_ReturnsTestItemType
public void GetEnumerableItemType_ListOfAnonymousObject_ReturnsTestItemType()
{
var anonymous = new { prop1 = "value1", prop2 = "value2" };
var anonymousList = new[] { anonymous }.ToList();
var itemType = FormatterUtils.GetEnumerableItemType(anonymousList.GetType());
Assert.IsNotNull(itemType);
Assert.AreEqual(anonymous.GetType(), itemType);
}
示例6: GetMemberInfo_AnonymousType_ReturnsMemberInfoList
public void GetMemberInfo_AnonymousType_ReturnsMemberInfoList()
{
var anonymous = new { prop1 = "value1", prop2 = "value2" };
var memberInfo = FormatterUtils.GetMemberInfo(anonymous.GetType());
Assert.IsNotNull(memberInfo);
Assert.AreEqual(2, memberInfo.Count);
}
示例7: SortAndPaginateKeepsOriginalQueryableType
public void SortAndPaginateKeepsOriginalQueryableType()
{
var readCommand = new ReadCommandInfo
{
OrderByProperties = new[] { new OrderByProperty { Property = "Name", Descending = true } },
Skip = 1,
Top = 2,
};
IQueryable<object> query = new[] { "a", "b", "c", "d" }.AsQueryable().Select(name => new C { Name = name });
Console.WriteLine(query.GetType());
Assert.IsTrue(query is IQueryable<C>);
var result = GenericFilterHelper.SortAndPaginate<object>(query, readCommand);
Assert.AreEqual("c, b", TestUtility.Dump(result, item => ((C)item).Name));
Console.WriteLine(result.GetType());
Assert.IsTrue(result is IQueryable<C>);
}