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


C# NUnit.Framework.GetType方法代码示例

本文整理汇总了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 };
        }
开发者ID:jsberon,项目名称:CsharpNunitKoans,代码行数:11,代码来源:K020_AboutVariables.cs

示例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!"));
 }
开发者ID:namics,项目名称:TerrificNet,代码行数:11,代码来源:BlockTests.cs

示例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"]);
            }
        }
开发者ID:danbarua,项目名称:ServiceStack.Text,代码行数:17,代码来源:JsonObjectTests.cs

示例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);
		}
开发者ID:konkked,项目名称:Underscore.cs,代码行数:21,代码来源:DynamicTest.cs

示例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));
 }
开发者ID:JonasSamuelsson,项目名称:TinyORM,代码行数:6,代码来源:PropertyGetter_accessing_a_nested_property.cs

示例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 );

		}
开发者ID:konkked,项目名称:Underscore.cs,代码行数:91,代码来源:TransposeTest.cs


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