Ejemplo n.º 1
0
        public void ExcludeRemovedProperties()
        {
            var sourceObject = new ExampleClass
            {
                IntegerProperty = 123,
                StringProperty  = "Some Text",
                BoolProperty    = true
            };

            var parameters = sourceObject.Parameterize()
                             .Remove(x => x.IntegerProperty)
                             .Create();

            var expected = new DynamicParameters();

            expected.Add(nameof(sourceObject.StringProperty).ToLowerInvariant(), sourceObject.StringProperty);
            expected.Add(nameof(sourceObject.BoolProperty).ToLowerInvariant(), sourceObject.BoolProperty);

            parameters.Should().BeOfType <DynamicParameters>();
            parameters.Should().BeEquivalentTo(expected);
        }
        public void IncludeAddedProperties()
        {
            var sourceObject = new ExampleClass
            {
                IntegerProperty = 123,
                StringProperty  = "Some Text",
                BoolProperty    = true
            };

            var parameters = _parameterFactory.Parameterize(sourceObject)
                             .Add("NewParameter", "New Value")
                             .Create();

            var expected = new DynamicParameters();

            expected.Add(nameof(sourceObject.IntegerProperty).ToLowerInvariant(), sourceObject.IntegerProperty);
            expected.Add(nameof(sourceObject.StringProperty).ToLowerInvariant(), sourceObject.StringProperty);
            expected.Add(nameof(sourceObject.BoolProperty).ToLowerInvariant(), sourceObject.BoolProperty);
            expected.Add("newparameter", "New Value");

            parameters.Should().BeOfType <DynamicParameters>();
            parameters.Should().BeEquivalentTo(expected);
        }