Beispiel #1
0
        public void When_PrincipalParameter_Expect_DirectAccess()
        {
            var p     = new ParameterExample();
            var param = p.GetParameter();

            Assert.AreEqual(param, p.Principal);
        }
        public void When_Get_Expect_Parameter()
        {
            var p     = new ParameterExample();
            var param = p.GetProperty <GivenParameter <double> >("parameter1");

            Assert.AreEqual(p.Parameter1, param);
        }
Beispiel #3
0
        public void When_GetParameter_Expect_Parameter()
        {
            var p     = new ParameterExample();
            var param = p.GetParameter("parameter1");

            Assert.AreEqual(p.Parameter1, param);
        }
Beispiel #4
0
        public void When_SetterForParameterProperty_Expect_DirectAccess()
        {
            var p      = new ParameterExample();
            var setter = p.GetSetter("parameter1");

            Assert.AreEqual(false, p.Parameter1.Given);
            setter(1.0);
            Assert.AreEqual(1.0, p.Parameter1.Value, 1e-12);
            Assert.AreEqual(true, p.Parameter1.Given);
        }
Beispiel #5
0
        public void When_SetterForMethod_Expect_DirectAccess()
        {
            var p      = new ParameterExample();
            var setter = p.GetSetter("method1");

            setter(1.0);
            Assert.AreEqual(1.0, p.Property1, 1e-12);
            setter(10.0);
            Assert.AreEqual(10.0, p.Property1, 1e-12);
        }
Beispiel #6
0
        public void When_SetterForField_Expect_DirectAccess()
        {
            var p      = new ParameterExample();
            var setter = p.GetSetter("field1");

            setter(1.0);
            Assert.AreEqual(1.0, p.Field1, 1e-12);
            setter(10.0);
            Assert.AreEqual(10.0, p.Field1, 1e-12);
        }
Beispiel #7
0
        public void When_PrincipalSetter_Expect_DirectAccess()
        {
            var p      = new ParameterExample();
            var setter = p.GetSetter();

            setter(1.0);
            Assert.AreEqual(1.0, p.Principal.Value, 1e-12);
            setter(10.0);
            Assert.AreEqual(10.0, p.Principal.Value, 1e-12);
        }
        public void When_SetterForProperty_Expect_DirectAccess()
        {
            var p      = new ParameterExample();
            var setter = p.CreateParameterSetter <int>("property2");

            setter(1);
            Assert.AreEqual(1, p.Property2);
            setter(10);
            Assert.AreEqual(10, p.Property2);
        }
        public void When_CopyPropertiesAndFields_CopiesPropertyWithPrivateSetter()
        {
            var source = new ParameterExample();

            source.SetMethod1(1);
            var destination = new ParameterExample();

            ReflectionHelper.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1, destination.Property1);

            destination.SetMethod1(2);

            Assert.AreEqual(1, source.Property1);

            source.SetMethod1(3);

            Assert.AreEqual(3, source.Property1);
            Assert.AreEqual(2, destination.Property1);
        }
        public void When_CopyPropertiesAndFields_CopiesWritableParameter()
        {
            var source = new ParameterExample();

            source.Parameter2.Value = 1;
            var destination = new ParameterExample();

            Utility.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1, destination.Parameter2.Value);

            destination.Parameter2.Value = 2;

            Assert.AreEqual(1, source.Parameter2.Value);
            Assert.AreEqual(2, destination.Parameter2.Value);

            source.Parameter2.Value = 3;
            Assert.AreEqual(3, source.Parameter2.Value);
            Assert.AreEqual(2, destination.Parameter2.Value);
        }
        public void When_CopyPropertiesAndFields_CopiesProperty()
        {
            var source = new ParameterExample();

            source.Property2 = 1;
            var destination = new ParameterExample();

            Utility.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1, destination.Property2);

            destination.Property2 = 2;

            Assert.AreEqual(1, source.Property2);
            Assert.AreEqual(2, destination.Property2);

            source.Property2 = 3;
            Assert.AreEqual(3, source.Property2);
            Assert.AreEqual(2, destination.Property2);
        }
Beispiel #12
0
        public void When_CopyPropertiesAndFields_CopiesReadonlyParameter()
        {
            var source = new ParameterExample();

            source.Parameter1.Value = 1;
            var destination = new ParameterExample();

            Reflection.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1, destination.Parameter1.Value);

            destination.Parameter1.Value = 2;

            Assert.AreEqual(1, source.Parameter1.Value);
            Assert.AreEqual(2, destination.Parameter1.Value);

            source.Parameter1.Value = 3;
            Assert.AreEqual(3, source.Parameter1.Value);
            Assert.AreEqual(2, destination.Parameter1.Value);
        }
        public void When_CopyPropertiesAndFields_CopiesWritableParameter()
        {
            var source = new ParameterExample
            {
                Parameter2 = 1
            };
            var destination = new ParameterExample();

            ReflectionHelper.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1, destination.Parameter2.Value);

            destination.Parameter2 = 2;

            Assert.AreEqual(1, source.Parameter2.Value);
            Assert.AreEqual(2, destination.Parameter2.Value);

            source.Parameter2 = 3;
            Assert.AreEqual(3, source.Parameter2.Value);
            Assert.AreEqual(2, destination.Parameter2.Value);
        }
        public void When_CopyPropertiesAndFields_CopiesField()
        {
            var source = new ParameterExample();

            source.Field1 = 1.0;
            source.Field2 = 2;
            var destination = new ParameterExample();

            Utility.CopyPropertiesAndFields(source, destination);
            Assert.AreEqual(1.0, destination.Field1, 1e-12);
            Assert.AreEqual(2, destination.Field2);

            destination.Field1 = 2;

            Assert.AreEqual(1, source.Field1);
            Assert.AreEqual(2, destination.Field1);

            source.Field1 = 3;
            Assert.AreEqual(3, source.Field1);
            Assert.AreEqual(2, destination.Field1);
        }
Beispiel #15
0
        public void When_SetterForGetOnlyProperty_Expect_Null()
        {
            var p = new ParameterExample();

            Assert.AreEqual(null, p.GetSetter("property1"));
        }