本文整理汇总了C#中NUnit.Framework.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# NUnit.Framework.GetType方法的具体用法?C# NUnit.Framework.GetType怎么用?C# NUnit.Framework.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework
的用法示例。
在下文中一共展示了NUnit.Framework.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(string[]), 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 };
}
示例2: Should_emit_all_nodes_in_block
public void Should_emit_all_nodes_in_block()
{
var model = new { Name = "World" };
var template = SyntaxTree.Block(
SyntaxTree.WriteString("Hello "),
SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.GetType(), "Name")),
SyntaxTree.WriteString("!")
);
var result = ExecuteTemplate(template, model);
Assert.That(result, Is.EqualTo("Hello World!"));
}
示例3: Does_encode_unicode
public void Does_encode_unicode()
{
string test = "<\"I get this : ";
var obj = new { test };
using (var mem = new System.IO.MemoryStream())
{
ServiceStack.Text.JsonSerializer.SerializeToStream(obj, obj.GetType(), mem);
var encoded = System.Text.Encoding.UTF8.GetString(mem.ToArray());
var copy1 = JsonObject.Parse(encoded);
Assert.That(test, Is.EqualTo(copy1["test"]));
System.Diagnostics.Debug.WriteLine(copy1["test"]);
}
}
示例4: Object_Transformation_Dynamic
public void Object_Transformation_Dynamic()
{
var a = "a";
var b = 1;
var c = 12.0;
var testTarget = new { a, b, c };
var prop = new Mock<IPropertyComponent>();
prop.Setup(s=>s.All(It.Is<object>(r=> r == testTarget)))
.Returns(testTarget.GetType().GetProperties(BindingFlags.Public|BindingFlags.Instance));
var result = _.Object.ToDynamic(testTarget);
Assert.AreEqual(a , result.a);
Assert.AreEqual(b , result.b);
Assert.AreEqual(c , result.c);
}
示例5: should_return_the_nested_property_value
public void should_return_the_nested_property_value()
{
var foo = new { Text = "Hello world" };
var getter = PropertyGetter.Create(foo.GetType(), "Text.Length");
Assert.That(getter.Get(foo), Is.EqualTo(foo.Text.Length));
}
示例6: Coalesce
public void Coalesce( )
{
string middleName = "Henry";
var coalscing = new { MiddleName = middleName, FirstName = "ShouldNotBeHere", LastName = "ShouldBeHere" };
var coalscingType = coalscing.GetType( );
var mkprop = new Mock<IPropertyComponent>( );
mkprop.Setup( a => a.All( typeof( Person ) ) )
.Returns( typeof( Person ).GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
mkprop.Setup( a => a.All( typeof( Employee ) ) )
.Returns( typeof( Employee ).GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
mkprop.Setup( a => a.All( coalscingType ) )
.Returns( coalscingType.GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
mkprop.Setup( a => a.All( It.IsAny<Person>( ) ) )
.Returns( typeof( Person ).GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
mkprop.Setup( a => a.All( It.IsAny<Employee>( ) ) )
.Returns( typeof( Employee ).GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
mkprop.Setup( a => a.All( coalscing ) )
.Returns( coalscingType.GetProperties( BindingFlags.Instance | BindingFlags.Public ) );
var target = new TransposeComponent( mkprop.Object );
string title = "Mr.",
firstName = "Charles",
suffix = "IV",
nickName = "Chip";
int age = 24;
var person = new Person
{
Title = title,
FirstName = firstName,
Suffix = suffix,
NickName = nickName,
Age = age,
};
string shouldbehere = "ShouldBeHere";
decimal defaultedSalary = 60000m;
var employeeWithExistingInfo = new Employee
{
FirstName = shouldbehere,
LastName = shouldbehere,
Salary = defaultedSalary
};
var employeeWithNoInfo = new Employee { };
var employeeWithOnlySalary = new Employee
{
Salary = 60000m
};
var result = target.Coalesce( employeeWithExistingInfo, person );
Assert.AreEqual( employeeWithExistingInfo, result );
Assert.AreEqual( defaultedSalary, result.Salary );
Assert.AreEqual( shouldbehere, result.FirstName );
Assert.AreEqual( shouldbehere, result.LastName );
var dm = default( decimal );
var ml = new Employee{};
var result3 = target.Coalesce( ml, new { Salary = 1000m } );
// the salary should not be replaced because
Assert.AreEqual( result3, ml );
Assert.AreEqual( dm, ml.Salary );
var result2 = target.Coalesce( person, coalscing );
Assert.AreEqual ( person, result2 );
Assert.AreNotEqual ( "ShouldNotBeHere", result2.FirstName );
Assert.AreEqual( "ShouldBeHere", result2.LastName );
Assert.AreEqual( "Henry", result2.MiddleName );
Assert.AreEqual( "IV", result2.Suffix );
var result4 = target.Coalesce( person, coalscing, true );
Assert.AreNotEqual( person, result4 );
Assert.AreNotEqual( "ShouldNotBeHere", result2.FirstName );
Assert.AreEqual( "ShouldBeHere", result2.LastName );
Assert.AreEqual( "Henry", result2.MiddleName );
Assert.AreEqual( "IV", result2.Suffix );
}