Exemplo n.º 1
0
        public void ShouldEqualNameValueAndIsNumericInProcessMethod()
        {
            var objectDefinitions = this.ContainerFixture.Container.Resolve <IObjectDefinitions <Type> >();
            var attribute         = new MockBaseAttribute();
            var type = attribute.GetType();

            type.Should().NotBeNull();

            var typeInfo = type.GetTypeInfo();

            foreach (var property in typeInfo.DeclaredProperties)
            {
                var tuple     = new Tuple <PropertyInfo, object>(property, attribute);
                var processed = this.ContainerFixture.AttributeParameterProvider.Process(this.ContainerFixture.AttributeParameterProvider.GetFromSource(tuple), objectDefinitions, tuple);
                processed.Name.Should().Be(property.Name);
                var propaVal = property.GetValue(attribute);

                if (propaVal == null)
                {
                    processed.Value.Should().BeNull();
                }
                else
                {
                    processed.Value.Should().Be(propaVal.ToString());
                }

                processed.IsNumeric.Should().Be(this.IsNumeric(property));
            }
        }
        public void AttributeProvider_GetFromSource()
        {
            //Arrange
            var attribute = new MockBaseAttribute();

            //Act
            var result = this.ContainerFixture.AttributeProvider.GetFromSource(attribute);

            //Assert
            result.Should().NotBeNull();
            result.Name.Should().Be(nameof(MockBaseAttribute));
            result.Parameters.Should().NotBeNull();
            result.Parameters.Count.Should().Be(0);
        }
        public void AttributeProvider_Process()
        {
            //Arrange
            var attribute         = new MockBaseAttribute();
            var objectDefinitions = this.ContainerFixture.Container.Resolve <IObjectDefinitions <Type> >();

            //Act
            var result = this.ContainerFixture.AttributeProvider.Process(this.ContainerFixture.AttributeProvider.GetFromSource(attribute), objectDefinitions, attribute);

            //Assert
            result.Should().NotBeNull();
            result.Name.Should().Be(nameof(MockBaseAttribute));
            result.Parameters.Should().NotBeNull();
            result.Parameters.Count.Should().Be(6);

            //Parameters Assertion
            result.Parameters.Select(x => x.Name).Contains("PrivateAttr").Should().BeFalse();
            result.Parameters.Select(x => x.Name).Contains("ProtectedAttr").Should().BeFalse();
        }