Exemplo n.º 1
0
        private void HandleLinkedFilesAndShowMessageBox(List <ProjectItem> linkedItems)
        {
            LinkedFileFilter linkedFileFilter = new LinkedFileFilter(_dte.Solution);

            linkedFileFilter.Filter(linkedItems);

            LinkedFileHandler linkedFileHandler = new LinkedFileHandler();

            linkedFileHandler.Handle(_licenseReplacer, linkedFileFilter);

            if (linkedFileHandler.Message != string.Empty)
            {
                MessageBox.Show(
                    linkedFileHandler.Message,
                    Resources.NameOfThisExtension,
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
            }
        }
Exemplo n.º 2
0
        public void TestProjectItemWithoutLicenseHeaderFile()
        {
            Solution    solution   = MockRepository.GenerateMock <Solution> ();
            ProjectItem linkedFile = MockRepository.GenerateMock <ProjectItem> ();

            solution.Expect(x => x.FindProjectItem("linkedFile.cs")).Return(linkedFile);
            linkedFile.Expect(x => x.Name).Return("linkedFile.cs");
            linkedFile.Expect(x => x.Collection.Parent).Return(new object());

            LinkedFileFilter linkedFileFilter = new LinkedFileFilter(solution);

            linkedFileFilter.Filter(new List <ProjectItem> {
                linkedFile
            });

            Assert.IsEmpty(linkedFileFilter.ToBeProgressed);
            Assert.IsNotEmpty(linkedFileFilter.NoLicenseHeaderFile);
            Assert.IsEmpty(linkedFileFilter.NotInSolution);
        }
        public async Task Filter_GivenNonSolutionItem_PopulatesNotInSolutionProperty()
        {
            await VisualStudioTestContext.SwitchToMainThread();

            var solution   = MockRepository.GenerateMock <Solution>();
            var linkedFile = MockRepository.GenerateMock <ProjectItem>();

            solution.Expect(x => x.FindProjectItem("linkedFile.cs")).Return(null);
            linkedFile.Expect(x => x.Name).Return("linkedFile.cs");

            var linkedFileFilter = new LinkedFileFilter(solution);

            linkedFileFilter.Filter(new List <ProjectItem> {
                linkedFile
            });

            Assert.That(linkedFileFilter.ToBeProgressed, Is.Empty);
            Assert.That(linkedFileFilter.NoLicenseHeaderFile, Is.Empty);
            Assert.That(linkedFileFilter.NotInSolution, Is.Not.Empty);
        }
        public async Task Filter_GivenNonLicenseHeaderFile_PopulatesNoLicenseHeaderFileProperty()
        {
            await VisualStudioTestContext.SwitchToMainThread();

            var solution = MockRepository.GenerateMock <Solution>();

            solution.Expect(x => x.FullName).Return(@"d:\projects\Stuff.sln");

            var dte = MockRepository.GenerateMock <DTE>();

            dte.Expect(x => x.Solution).Return(solution);

            var projectItems = MockRepository.GenerateMock <ProjectItems>();

            var linkedFile = MockRepository.GenerateMock <ProjectItem>();

            linkedFile.Expect(x => x.DTE).Return(dte);
            projectItems.Expect(x => x.Parent).Return(new object());
            linkedFile.Expect(x => x.Collection).Return(projectItems);

            solution.Expect(x => x.FindProjectItem("linkedFile.cs")).Return(linkedFile);


            linkedFile.Expect(x => x.Name).Return("linkedFile.cs");
            linkedFile.Expect(x => x.Properties).Return(null);


            var linkedFileFilter = new LinkedFileFilter(solution);

            linkedFileFilter.Filter(new List <ProjectItem> {
                linkedFile
            });

            Assert.That(linkedFileFilter.ToBeProgressed, Is.Empty);
            Assert.That(linkedFileFilter.NoLicenseHeaderFile, Is.Not.Empty);
            Assert.That(linkedFileFilter.NotInSolution, Is.Empty);
        }