Exemple #1
0
        public void NetFrameworkProject_NoManifest_Load()
        {
            var path = TestUtils.GetSampleProject(@"RepoCat.TestApps.NetFramework.NoManifest.csproj");

            var repo = new RepositoryInfo()
            {
                RepositoryName   = "Test",
                OrganizationName = "TestOrg"
            };
            var provider = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalDotNetProjects,
                RepositoryName   = repo.RepositoryName,
                OrganizationName = repo.OrganizationName,
            }, new Mock <ILogger>().Object);



            var info = (provider as ProjectInfoBuilderBase).GetInfo(path.FullName);

            info.Should().NotBeNull();
            info.RepositoryInfo.Should().BeEquivalentTo(repo);
            info.Autogenerated.Should().BeTrue();
            info.RepositoryStamp.Should().NotBeNullOrEmpty();
            info.ProjectName.Should().BeEquivalentTo("RepoCat.TestApps.NetFramework.NoManifest");
            info.AssemblyName.Should().Be("RepoCat.TestApps.NetFramework.NoManifest");
            info.Components.Count.Should().Be(0);
            info.Properties.Should()
            .ContainEquivalentOf(new Property("CodeFiles", new List <string>()
            {
                "Class1.cs", "AssemblyInfo.cs"
            }));
        }
Exemple #2
0
        public void NetFrameworkProject_Load()
        {
            var path = TestUtils.GetSampleProject(@"RepoCat.TestApps.NetFramework.csproj");

            var repo = new RepositoryInfo()
            {
                RepositoryName   = "Test",
                OrganizationName = "TestOrg"
            };
            var provider = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalDotNetProjects,
                RepositoryName   = repo.RepositoryName,
                OrganizationName = repo.OrganizationName
            }, new Mock <ILogger>().Object);



            var info = (provider as ProjectInfoBuilderBase).GetInfo(path.FullName);

            info.Should().NotBeNull();
            info.RepositoryInfo.Should().BeEquivalentTo(repo);
            info.DocumentationUri.Should().BeEquivalentTo("http://google.com/Somewhere");
            info.RepositoryStamp.Should().NotBeNullOrEmpty();
            info.ProjectName.Should().BeEquivalentTo("OverridenProjectName");
            info.AssemblyName.Should().Be("RepoCat.TestApps.NetFramework");
            info.Components.Single().Name.Should().Be("SampleNetFrameworkConsoleApp");
            info.Components.Single().Tags.Count.Should().Be(3);
        }
Exemple #3
0
        public void NetFrameworkProject_NoManifest_DoNotLoad()
        {
            var path = TestUtils.GetSampleProject(@"RepoCat.TestApps.NetFramework.NoManifest.csproj");

            var provider = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode            = TransmissionMode.LocalDotNetProjects,
                SkipProjectsWithoutManifest = true
            }, new Mock <ILogger>().Object);

            var info = (provider as ProjectInfoBuilderBase).GetInfo(path.FullName);

            info.Should().BeNull();
        }
Exemple #4
0
        public void NetCoreProject_Load()
        {
            var path = TestUtils.GetSampleProject(@"RepoCat.TestApps.NetCore.csproj");

            var repo = new RepositoryInfo()
            {
                RepositoryName   = "Test",
                OrganizationName = "TestOrg"
            };
            var provider = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalDotNetProjects, RepositoryName = repo.RepositoryName, OrganizationName = repo.OrganizationName
            }, new Mock <ILogger>().Object);

            var info = (provider as ProjectInfoBuilderBase).GetInfo(path.FullName);

            info.Should().NotBeNull();
            info.RepositoryInfo.Should().BeEquivalentTo(repo);
            info.Owner.Should().BeEquivalentTo("Jim The Beam");
            info.ProjectDescription.Should().BeEquivalentTo("Description is optional");
            info.ProjectName.Should().BeEquivalentTo("RepoCat.TestApps.NetCore");
            info.RepositoryStamp.Should().NotBeNullOrEmpty();
            info.AssemblyName.Should().Be("RepoCat.TestApps.NetCore");
            info.Tags.Should().BeEquivalentTo(new[] { "These", "Tags", "Are", "Optional" });
            info.Properties.Should().ContainEquivalentOf(new Property("EntireProjectProperties", "AreAlsoOptional"));
            info.Properties.Should()
            .ContainEquivalentOf(new Property("CodeFiles", new List <string>()
            {
                "Program.cs"
            }));
            info.Properties.Should()
            .ContainEquivalentOf(new Property("ManualCollection", new List <string>()
            {
                "Value 1", "Val2", "V3"
            }));

            info.Components.Single().Name.Should().Be("SampleNetCoreConsoleApp");
            info.Components.Single().Tags.Count.Should().Be(3);


            info.Components.First().Properties.Should()
            .ContainEquivalentOf(new Property("ComponentManualCollection", new List <string>()
            {
                "Value 1", "Val2", "V3"
            }));
        }
        public void RelativePathPropertyKey_ResolvedOk()
        {
            //arrange
            ManifestBasedUriProvider uriProvider = new ManifestBasedUriProvider(new TraceLogger(LogLevel.Debug));
            List <string>            uris        = uriProvider.GetUris(RepoRoot.FullName).ToList();
            IProjectInfoBuilder      builder     = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalManifestBased
            }, new TraceLogger(LogLevel.Debug));

            //act
            List <ProjectInfo> infos = builder.GetInfos(uris).ToList();

            //assert
            var scriptTwo  = infos.Single(x => x.ProjectName == "ScriptTwo");
            var samplePath = scriptTwo.Components.Single().Properties["SamplePath"];

            FileAssert.Exists(samplePath.ToString());
        }
        public void ProjectInfo_RepoStampsShouldBeEqual()
        {
            //arrange
            ManifestBasedUriProvider uriProvider = new ManifestBasedUriProvider(new TraceLogger(LogLevel.Debug));
            List <string>            uris        = uriProvider.GetUris(RepoRoot.FullName).ToList();
            IProjectInfoBuilder      builder     = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalManifestBased
            }, new TraceLogger(LogLevel.Debug));

            //act
            List <ProjectInfo> infos = builder.GetInfos(uris).ToList();

            //assert

            //the stamp of both scripts should be the same (as they are loaded at the same time)
            //otherwise, they would be visible in different snapshots of the repo
            Assert.AreEqual(infos[0].RepositoryStamp, infos[1].RepositoryStamp);
        }
Exemple #7
0
        private ProjectInfo LoadFromManifestWithRepoIncluded(bool allowOverride, RepositoryInfo repositoryInfoFromTransmitter)
        {
            //arrange
            ManifestBasedUriProvider uriProvider = new ManifestBasedUriProvider(new TraceLogger(LogLevel.Debug));
            List <string>            uris        = uriProvider.GetUris(RepoRoot.FullName).ToList();
            IProjectInfoBuilder      builder     = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                RepositoryName   = repositoryInfoFromTransmitter?.RepositoryName,
                OrganizationName = repositoryInfoFromTransmitter?.OrganizationName,
                RepositoryMode   = repositoryInfoFromTransmitter?.RepositoryMode ?? RepositoryMode.Default,
                TransmissionMode = TransmissionMode.LocalManifestBased,
                ManifestCanOverrideRepositoryInfo = allowOverride
            }, new TraceLogger(LogLevel.Debug));

            //act
            List <ProjectInfo> infos = builder.GetInfos(uris).ToList();

            //assert
            var scriptOne = infos.Single(x => x.ProjectName == "ScriptOne");

            return(scriptOne);
        }
Exemple #8
0
        private ProjectInfo LoadFromManifestWithoutRepositoryInfo(bool allowOverride, RepositoryInfo repositoryInfoFromTransmitter)
        {
            //arrange
            var file = Samples.GetFiles("ProjectManifestWithoutRepository.RepoCat.xml").Single();

            IProjectInfoBuilder builder = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                RepositoryName   = repositoryInfoFromTransmitter?.RepositoryName,
                OrganizationName = repositoryInfoFromTransmitter?.OrganizationName,
                RepositoryMode   = repositoryInfoFromTransmitter?.RepositoryMode ?? RepositoryMode.Default,
                TransmissionMode = TransmissionMode.LocalManifestBased,
                ManifestCanOverrideRepositoryInfo = allowOverride
            }, new TraceLogger(LogLevel.Debug));

            //act
            List <ProjectInfo> infos = builder.GetInfos(new [] { file.FullName }).ToList();

            //assert
            var scriptOne = infos.Single();

            return(scriptOne);
        }
        public void ProjectInfo_ProvidedOk()
        {
            //arrange
            ManifestBasedUriProvider uriProvider = new ManifestBasedUriProvider(new TraceLogger(LogLevel.Debug));
            List <string>            uris        = uriProvider.GetUris(RepoRoot.FullName).ToList();
            IProjectInfoBuilder      builder     = ProjectInfoBuilderFactory.Get(new TransmitterArguments()
            {
                TransmissionMode = TransmissionMode.LocalManifestBased
            }, new TraceLogger(LogLevel.Debug));

            //act
            List <ProjectInfo> infos = builder.GetInfos(uris).ToList();

            //assert
            Assert.AreEqual(2, infos.Count);
            var scriptOne = infos.Single(x => x.ProjectName == "ScriptOne");
            var scriptTwo = infos.Single(x => x.ProjectName == "ScriptTwo");

            //most properties are the same. Also, we care simply about whether the files exist
            ValidateProjectInfo(scriptOne, ".Script", ".Script", "I_AM_FAKE.Script");

            ValidateProjectInfo(scriptTwo, ".scr", "CustomScript", "I_AM_FAKE_TOO.Script");
            Assert.IsTrue(File.Exists(scriptTwo.DocumentationUri));
        }