示例#1
0
		public void When1Param_InvokeMethodWithCorrectParamValue()
		{
			var p = new ParameterBinder(typeof(MyClass), "A", new NameValueCollection { { "p1", "123" } });
			var instance = new MyClass();
			p.Invoke(instance);

			instance.P1.Should().Be.EqualTo(123);
		}
示例#2
0
		public void CanCallMethodWithDateTime()
		{
			var p = new ParameterBinder(typeof(OthersTypes), "MDateTime", new NameValueCollection { { "something", DateTime.Today.ToString() } });
			var instance = new OthersTypes();
			p.Invoke(instance);

			instance.MDateCalled.Should().Be.EqualTo(DateTime.Today);
		}
示例#3
0
		public void CanCallMethodWithString()
		{
			var p = new ParameterBinder(typeof(OthersTypes), "MString", new NameValueCollection { { "something", "aaa" } });
			var instance = new OthersTypes();
			p.Invoke(instance);

			instance.MStringCalled.Should().Be.EqualTo("aaa");
		}
示例#4
0
		public void When2LevelParam_ChooseMethodWith2Param()
		{
			var p = new ParameterBinder(typeof(Aclass), "MethodTwoLevel", new NameValueCollection { { "Simple1Level.P1", "123" }, { "Simple1Level.P2", "452" } });
			var instance = new Aclass();
			p.Invoke(instance);

			instance.TwoLevel.Simple1Level.P1.Should().Be.EqualTo(123);
			instance.TwoLevel.Simple1Level.P2.Should().Be.EqualTo(452);
		}
示例#5
0
		public void When1LevelParamWithCollection_CanConvertTheCollection()
		{
			var p = new ParameterBinder(typeof(Aclass), "MethodOneLevelColl", new NameValueCollection { { "P1", "123" }, { "P2", "452" }, { "Coll", "8" }, { "Coll", "9" } });
			var instance = new Aclass();
			p.Invoke(instance);

			instance.OneLevelColl.P1.Should().Be.EqualTo(123);
			instance.OneLevelColl.Coll.Should().Have.SameValuesAs(8, 9);
		}