Exemple #1
0
        public async Task AccessModifierReturnsPrivateWhenEmptyModifierDefinedWithClassParent()
        {
            var code = FieldDefinitionCode.BuildClassFieldWithModifiers(string.Empty);

            var declaringType = Substitute.For <IClassDefinition>();

            var node = await TestNode.FindNode <FieldDeclarationSyntax>(code).ConfigureAwait(false);

            var sut = new Wrapper(declaringType, node);

            sut.AccessModifiers.Should().Be(AccessModifiers.Private);
        }
Exemple #2
0
        public async Task ThrowsExceptionWhenDeclaringTypeIsNotSupported()
        {
            var code = FieldDefinitionCode.BuildClassFieldWithModifiers(string.Empty);

            var declaringType = Substitute.For <ITypeDefinition>();

            var node = await TestNode.FindNode <FieldDeclarationSyntax>(code).ConfigureAwait(false);

            // ReSharper disable once ObjectCreationAsStatement
            Action action = () => new Wrapper(declaringType, node);

            action.Should().Throw <NotSupportedException>();
        }
Exemple #3
0
        public async Task AccessModifierReturnsValueBasedOnAccessModifiers(
            string accessModifiers,
            AccessModifiers expected)
        {
            var code = FieldDefinitionCode.BuildClassFieldWithModifiers(accessModifiers);

            var declaringType = Substitute.For <IClassDefinition>();

            var node = await TestNode.FindNode <FieldDeclarationSyntax>(code).ConfigureAwait(false);

            var sut = new Wrapper(declaringType, node);

            sut.AccessModifiers.Should().Be(expected);
        }
Exemple #4
0
        public async Task IsVisibleReturnsWhetherParentAndAccessModifierAreVisible(bool parentIsVisible,
                                                                                   string accessModifiers, bool expected)
        {
            var code = FieldDefinitionCode.BuildClassFieldWithModifiers(accessModifiers);

            var declaringType = Substitute.For <IClassDefinition>();

            declaringType.IsVisible.Returns(parentIsVisible);

            var node = await TestNode.FindNode <FieldDeclarationSyntax>(code).ConfigureAwait(false);

            var sut = new Wrapper(declaringType, node);

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