Example #1
0
        public void ChildHasHiddenProperties_Include_PropertiesNotGenerated()
        {
            WithSourceFiles(Files.ChildClass, Files.Mixin);

            var child = CreateClass(nameof(ChildClassWithEventsFromMixin));
            var mixin = CreateMixinReference(child, "_mixin");

            var includeMixin = new IncludeMixinCommand(mixin);
            var generatedClass = includeMixin.Execute(child.SourceCode, Semantic);

            Assert.IsNotEmpty(generatedClass.Members.OfType<EventDeclarationSyntax>());
        }
        private void ValidateCommentForMember(string mixinReferenceName)
        {
            // arrange
            var sourceCode = new SourceCode(Files.Comments);
            var childClass = sourceCode.Class(nameof(Child));
            var mixinClass = new MixinReferenceFactory(sourceCode.Semantic)
                .Create(childClass.FindMixinReference(mixinReferenceName));
            var settings = new Settings(includeDocumentation: true);
            var mixinCommand = new IncludeMixinCommand(mixinClass);

            // act
            var newClassDeclaration = mixinCommand.Execute(
                childClass,
                sourceCode.Semantic,
                settings);

            Assert.IsTrue(
                ValidationHelpers.HasSameDocumentation(
                    newClassDeclaration, 
                    mixinCommand.Mixin));
        }
        public void AddDocumentationAndCreateRegion_Created()
        {
            // arrange
            var sourceCode = new SourceCode(Files.Comments);
            var childClass = sourceCode.Class(nameof(Child));
            var mixinClass = 
                new MixinReferenceFactory(sourceCode.Semantic)
                .Create(childClass.FindMixinReference("_mixinWithProperty"));
            var settings = new Settings(includeDocumentation: true,createRegions: true);
            var mixinCommand = new IncludeMixinCommand(mixinClass);

            // act
            var newClassDeclaration = mixinCommand.Execute(childClass, sourceCode.Semantic,settings);

            // assert: there should be a region and a documentation
            var isPropertyBetweenRegion = IsPropertyBetweenRegion(
                newClassDeclaration, 
                "mixin _mixinWithProperty",
                "Property");
            var hasSameDocumentation = HasSameDocumentation(newClassDeclaration, mixinCommand.Mixin);
            Assert.IsTrue(isPropertyBetweenRegion);
            Assert.IsTrue(hasSameDocumentation);
        }