Ejemplo n.º 1
0
        private static bool DetermineIsVisible(IPropertyDefinition propertyDefinition,
                                               PropertyAccessorAccessModifiers accessModifiers)
        {
            if (propertyDefinition.IsVisible == false)
            {
                // The parent property is not visible so neither is the accessor
                return(false);
            }

            if (accessModifiers == PropertyAccessorAccessModifiers.None)
            {
                // There is no access modifiers defined to further restrict visibility so we inherit from the declaring property
                return(true);
            }

            if (accessModifiers == PropertyAccessorAccessModifiers.Protected)
            {
                return(true);
            }

            if (accessModifiers == PropertyAccessorAccessModifiers.ProtectedInternal)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public void CalculateChangeHandlesAllPossibleValues(PropertyAccessorAccessModifiers oldValue, PropertyAccessorAccessModifiers newValue)
        {
            var sut = new PropertyAccessorAccessModifiersChangeTable();

            Action action = () => sut.CalculateChange(oldValue, newValue);

            action.Should().NotThrow();
        }
Ejemplo n.º 3
0
        // @formatter:on — enable formatter after this line
        public void CalculateChangeReturnsExpectedValue(
            PropertyAccessorAccessModifiers oldModifiers,
            PropertyAccessorAccessModifiers newModifiers,
            SemVerChangeType expected)
        {
            var sut = new PropertyAccessorAccessModifiersChangeTable();

            var actual = sut.CalculateChange(oldModifiers, newModifiers);

            actual.Should().Be(expected);
        }
Ejemplo n.º 4
0
        public async Task AccessModifierReturnsExpectedValue(string modifiers, PropertyAccessorAccessModifiers expected)
        {
            var parentName = Guid.NewGuid().ToString();

            var declaringProperty = Substitute.For <IPropertyDefinition>();

            declaringProperty.Name.Returns(parentName);

            var node = await TestNode
                       .FindNode <AccessorDeclarationSyntax>(
                PropertyDefinitionCode.ReadOnlyProperty.Replace("get;", modifiers + " get;"))
                       .ConfigureAwait(false);

            var sut = new PropertyAccessorDefinition(declaringProperty, node);

            sut.AccessModifiers.Should().Be(expected);
        }