Example #1
0
        public void Execute_MissingItem_NoViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 });
            var parent = BuildDataTable(new[] { "Key0", "Key2", "Key2", "Key0", "Key2" }, new object[] { 1, 1, 1, 1, 1 });

            var referencer = new ReferenceAnalyzer(BuildColumnMapping(1));
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }
Example #2
0
        public void Execute_MultipleKeysParentLargerThanChildDuplicateKeys_NoViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });
            var parent = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 });

            var referencer = new ReferenceAnalyzer(BuildColumnMapping(2));
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
Example #3
0
        public void Execute_MultipleKeysPermuteValueColumnOneMissingParent_OneViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 2 });
            var parent = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });

            parent.Columns[2].SetOrdinal(0);

            var referencer = new ReferenceAnalyzer(BuildColumnMapping(2, 1));
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }
Example #4
0
        public void Execute_DuplicatedKeyColumnsOnBothSide_NoViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 2 });
            var parent = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 });

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping("#0", "#0", ColumnType.Text),
                new ColumnMapping("#1", "#1", ColumnType.Text)
            };
            var referencer = new ReferenceAnalyzer(mapping);
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
Example #5
0
        public void Execute_NamedColumns_NoViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });
            var parent = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new[] { "0.000", "1.0", "2" });

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping("zero", "zero", ColumnType.Text),
                new ColumnMapping("one", "one", ColumnType.Text),
                new ColumnMapping("two", "two", ColumnType.Numeric)
            };
            var referencer = new ReferenceAnalyzer(mapping);
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
Example #6
0
        public ReferenceAnalysisSteps()
        {
            var sinkMock = new Mock <IMessageSink>();

            sinkMock.Setup(m => m.Write(It.IsAny <string>()))
            .Callback <string>(m => _sinkOutput = _sinkOutput + m + "\n");

            var editor = new Mock <IReferencesEditor>();

            editor.Setup(m => m.GetReferencedProjects(It.IsAny <string>()))
            .Returns(new [] { "Project2", "Project3" });

            var xamlReaderMock = new Mock <IXamlReferencesReader>();

            _sut = new ReferenceAnalyzer(sinkMock.Object, editor.Object, xamlReaderMock.Object);
        }
Example #7
0
        public void Execute_MultipleKeysPermuteKeyColumnsOneMissingParent_OneViolation()
        {
            var child  = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Fie" }, new object[] { 1, 2, 3 });
            var parent = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });

            parent.Columns[1].SetOrdinal(0);

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping("#0", "#1", ColumnType.Text),
                new ColumnMapping("#1", "#0", ColumnType.Text)
            };
            var referencer = new ReferenceAnalyzer(mapping);
            var violations = referencer.Execute(child, parent);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }
        public IEnumerable <IDeployableAddOn> GenerateAddOnsFromSolution(Solution solution)
        {
            var projects = solution.Projects.Select(ProjectAnalyser.AnalyzeProject)
                           .Where(project => !project.ProjectType.Equals(ProjectType.Ignored))
                           .ToList();

            var analyzedProjects =
                projects.Select(
                    project =>
                    new AnalyzedProjectInfo()
            {
                Info       = project,
                Namespaces = this.GetNamespaces(project)
            }).ToList();

            ReferenceAnalyzer.PopulateAndAnalyseReferences(analyzedProjects);

            var structurer = new AddOnConstructor();

            return(structurer.StructureAddOns(analyzedProjects));
        }