Пример #1
0
        public void GetVariableBlock()
        {
            var provider = new Mock<BaseCommandLineVersionControlProvider>();
            provider.Setup(controlProvider =>
                controlProvider.BuildCommandLineArguments(It.IsAny<VersionControlArguments>()))
                .Returns("args");
            provider.SetupGet(vcp => vcp.FileName).Returns("VcsExecutable.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("username", "password"),
                DestinationPath = "D:\\WorkingFolder\\MyProject",
                Label = "My Label",
                Operation = VersionControlOperation.Get,
                Project = "MyProject",
                Provider = "Vault",
                Server = "server:port",
                SourcePath = "$/MyProject"
            };
            var indexer = new SourceIndexer(provider.Object, args);

            var block = indexer.GetVariableBlock();

            Assert.AreEqual(@"SRCSRV: variables ------------------------------------------
            VCS_EXECUTABLE=VcsExecutable.exe
            VCS_USERNAME=username
            VCS_PASSWORD=password
            VCS_SERVER=server:port
            VCS_PROJECT=MyProject
            SRCSRVTRG=%VCS_EXTRACT_TARGET%
            VCS_EXTRACT_CMD=""%VCS_EXECUTABLE%"" args
            SRCSRVCMD=%VCS_EXTRACT_CMD%
            VCS_EXTRACT_TARGET=" + SourceIndexer.VcsDestinationPath + "\r\n", block, ignoreCase: true);
        }
Пример #2
0
        public void GetIniBlock()
        {
            var provider = new Mock<BaseCommandLineVersionControlProvider>();
            provider.Setup(controlProvider =>
                controlProvider.BuildCommandLineArguments(It.IsAny<VersionControlArguments>()))
                .Returns("args");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("username", "password"),
                DestinationPath = "D:\\WorkingFolder\\MyProject",
                Label = "My Label",
                Operation = VersionControlOperation.Get,
                Project = "MyProject",
                Provider = "Provider",
                Server = "server:port",
                SourcePath = "$/MyProject"
            };
            var indexer = new SourceIndexer(provider.Object, args);

            var block = indexer.GetIniBlock();

            var now = DateTime.Now.ToUniversalTime().ToString("u");

            Assert.AreEqual(@"SRCSRV: ini ------------------------------------------------
            VERSION=1
            VERCTRL=Provider
            DATETIME=" + now, block.Trim(), ignoreCase: true);
        }
        public void GetSourceIndexForFile()
        {
            var provider = new VaultVersionControlProvider("%VCS_EXECUTABLE%");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = @"D:\Source\",
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "$/ProjectName/SourcePath",
                Label = "My Label"
            };
            var indexer = new SourceIndexer(provider, args);

            Assert.AreEqual(@"D:\Source\ProjectName\SourcePath\File.ext*/ProjectName/SourcePath*My Label", indexer.GetVersionIndexForFile(@"d:\Source\ProjectName\SourcePath\File.ext"), ignoreCase: true);
            Assert.AreEqual(@"D:\Source\ProjectName\SourcePath\File.ext*/ProjectName/SourcePath*My Label", indexer.GetVersionIndexForFile(@"D:\Source\ProjectName\SourcePath\File.ext"), ignoreCase: true);
        }
        public void GetVersionCommandForFile()
        {
            var provider = new VaultVersionControlProvider("%VCS_EXECUTABLE%");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = @"D:\Source",
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "$/SourcePath",
                Label = "My Label"
            };
            var indexer = new SourceIndexer(provider, args);

            var command = indexer.GetVersionCommand();

            Assert.AreEqual("\"%VCS_EXECUTABLE%\" getlabel -host \"%VCS_SERVER%\" -user \"%VCS_USERNAME%\" -password \"%VCS_PASSWORD%\" -repository \"%VCS_PROJECT%\" -destpath \"%TARG%\\%VAR3%%fnbksl%(%VAR2%)\" \"$%VAR2%/%fnfile%(%VAR1%)\" \"%VAR3%\"", command, ignoreCase: true);
        }
Пример #5
0
        public void GetVersionIndexForFile()
        {
            var provider = new Mock<BaseCommandLineVersionControlProvider>();
            provider.Setup(controlProvider =>
                controlProvider.BuildCommandLineArguments(It.IsAny<VersionControlArguments>()))
                .Returns("args");

            provider.Setup(versionControlProvider => versionControlProvider
                .MapVersionControlSourcePath(It.IsAny<string>(), It.IsAny<VersionControlArguments>()))
                .Returns("/MyProject/SubFolder");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("username", "password"),
                DestinationPath = "D:\\WorkingFolder\\MyProject",
                Label = "My Label",
                Operation = VersionControlOperation.Get,
                Project = "MyProject",
                Provider = "Vault",
                Server = "server:port",
                SourcePath = "$/MyProject"
            };

            var indexer = new SourceIndexer(provider.Object, args);

            var line = indexer.GetVersionIndexForFile("D:\\WorkingFolder\\MyProject\\SubFolder\\FileName.ext");

            Assert.AreEqual("D:\\WorkingFolder\\MyProject\\SubFolder\\FileName.ext*/MyProject/SubFolder*My Label", line, ignoreCase: true);
        }
Пример #6
0
 public void Requires_BaseCommandLineVersionControlProvider_on_constructor()
 {
     var provider = new Mock<BaseCommandLineVersionControlProvider>();
     var indexer = new SourceIndexer(provider.Object, new Mock<VersionControlArguments>().Object);
     Assert.AreEqual(provider.Object, indexer.versionControlProvider);
 }