Esempio n. 1
0
        public void RightToLeftPrecedence(
            SampleClass one,
            SampleClass two,
            dynamic target)
        {
            "Given an instance of a class with two properties set to variations of one"
            .x(() => one = new SampleClass
            {
                IntProperty    = 1,
                StringProperty = "one"
            });

            "And another instance with two properties set to variations of two"
            .x(() =>
            {
                two = new SampleClass
                {
                    IntProperty    = 2,
                    StringProperty = "two"
                };
            });

            "When I apply assign them giving one precedence"
            .x(() => { target = Objectify.Assign(new { }, two, one); });

            "Then the output should contain the properties of the right most parameter"
            .x(() =>
            {
                Assert.Equal(target.IntProperty, one.IntProperty);
                Assert.Equal(target.StringProperty, one.StringProperty);
            });
        }
Esempio n. 2
0
        public void AdditionalProperty(
            SampleClass src,
            dynamic target)
        {
            "Given an instance of a class with two properties"
            .x(() =>
            {
                src = new SampleClass
                {
                    IntProperty    = 6,
                    StringProperty = "something"
                };
            });

            "When I assign it to a new object with an extra property"
            .x(() => { target = Objectify.Assign(new { AnotherProperty = "something else" }, src); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(target.IntProperty, src.IntProperty);
                Assert.Equal(target.StringProperty, src.StringProperty);
                Assert.Equal(target.AnotherProperty, "something else");
            });
        }
Esempio n. 3
0
        public void OverwriteProperty(
            SampleClass src,
            SampleClass target)
        {
            "Given an instance of a class with two properties"
            .x(() => src = new SampleClass
            {
                IntProperty    = 6,
                StringProperty = "something"
            });

            "When I assign it to a new object with an extra property"
            .x(() => { target = Objectify.Assign <SampleClass>(src, new { StringProperty = "something else" }); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(src.IntProperty, target.IntProperty);
                Assert.Equal("something else", target.StringProperty);
            });
        }
Esempio n. 4
0
        public void ActLikeAMapperWithAdditionalOverwritingProperties(
            SampleClass src,
            SampleClassTwo similarTarget)
        {
            "Given an instance of a class with two properties"
            .x(() => src = new SampleClass
            {
                IntProperty    = 6,
                StringProperty = "something"
            });

            "When I assign it to a new object with an extra property"
            .x(() => { similarTarget = Objectify.Assign <SampleClassTwo>(src, new { intproperty = 7 }, new { stringproperty = "seven" }); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(7, similarTarget.IntProperty);
                Assert.Equal("seven", similarTarget.StringProperty);
            });
        }
Esempio n. 5
0
        public void LikeForLike(
            SampleClass src,
            dynamic target)
        {
            "Given an instance of a class with two properties"
            .x(() => src = new SampleClass
            {
                IntProperty    = 6,
                StringProperty = "something"
            });

            "When I assign it to a new object"
            .x(() => { target = Objectify.Assign(new { }, src); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(target.IntProperty, src.IntProperty);
                Assert.Equal(target.StringProperty, src.StringProperty);
            });
        }
Esempio n. 6
0
        public void LikeForLike(
            SampleClass src,
            SampleClass target)
        {
            "Given an instance of a class with two properties"
            .x(() => src = new SampleClass
            {
                IntProperty    = 6,
                StringProperty = "something"
            });

            "When I assign it to a new object"
            .x(() => { target = Objectify.Assign <SampleClass>(src, src); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(src.IntProperty, target.IntProperty);
                Assert.Equal(src.StringProperty, target.StringProperty);
                Assert.False(object.ReferenceEquals(src, target));
            });
        }
Esempio n. 7
0
        public void ActLikeAMapper(
            SampleClass src,
            SampleClassTwo similarTarget)
        {
            "Given an instance of a class with two properties"
            .x(() => src = new SampleClass
            {
                IntProperty    = 6,
                StringProperty = "something"
            });

            "When I assign it to a new object with an extra property"
            .x(() => { similarTarget = Objectify.Assign <SampleClassTwo>(src); });

            "Then that object should have those properties"
            .x(() =>
            {
                Assert.Equal(similarTarget.IntProperty, src.IntProperty);
                Assert.Equal(similarTarget.StringProperty, src.StringProperty);
            });

            "And they shouldn't be the same reference"
            .x(() => Assert.False(ReferenceEquals(src, similarTarget)));
        }