コード例 #1
0
        public void SetWithArg_stringToMemberOfType_expected <T>(string toSet, T expected)
        {
            FieldSample <T> sample = new FieldSample <T>();

            MemberAttribute fieldAttr = new MemberAttribute(new NArgAttribute(), GetSingleMemberInfo(sample, "_field"));

            MemberSetter.SetArg(sample, fieldAttr, toSet);

            MemberAttribute propAttr = new MemberAttribute(new NArgAttribute(), GetSingleMemberInfo(sample, "TestProp"));

            MemberSetter.SetArg(sample, propAttr, toSet);

            MemberAttribute methodAttr = new MemberAttribute(new NArgAttribute(), GetSingleMemberInfo(sample, "TestMethod"));

            MemberSetter.SetArg(sample, methodAttr, toSet);

            MemberAttribute methodWithNoArgsAttr = new MemberAttribute(new NArgAttribute(), GetSingleMemberInfo(sample, "TestMethodWithNoArgs"));

            MemberSetter.SetArg(sample, methodWithNoArgsAttr, toSet);

            Assert.That(sample.FieldProp, Is.EqualTo(expected));
            Assert.That(sample.TestProp, Is.EqualTo(expected));
            Assert.That(sample.TestMethodProp, Is.EqualTo(expected));
            Assert.That(sample.HasTestMethodWithNoArgsExecuted, Is.True);
        }
コード例 #2
0
        public void SetRemainingArg_EmptyStringArrayToIEnumerableOfSring_DoesNotThrow()
        {
            var sample = new FieldSample <int>();

            string[] empty = new string[] { };

            MemberAttribute propAttr = new MemberAttribute(new NArgAttribute(), GetSingleMemberInfo(sample, "FooProp"));

            MemberSetter.SetRemainingArg(sample, propAttr, empty);
        }