Exemple #1
0
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            ITfsDataService tfsDataService = input.Target as ITfsDataService;

            if (null == tfsDataService)
            {
                return(getNext()(input, getNext));
            }

            switch (input.MethodBase.Name)
            {
            case nameof(ITfsDataService.RetrieveProjectCollections):
                return(RetrieveProjectCollections(input, getNext));

            case nameof(ITfsDataService.RetrieveProjects):
                return(RetrieveProjects(input, getNext));

            case nameof(ITfsDataService.RetrieveBuilds):
                return(RetrieveBuilds(input, getNext));

            case nameof(ITfsDataService.RetrieveBuildDefinitions):
                return(RetrieveBuildDefinitions(input, getNext));

            default:
                return(getNext()(input, getNext));
            }
        }
Exemple #2
0
        public void TestInitialize()
        {
            JObject projectcCollection1 = JObject.Parse("{ \"name\": \"collection1\" }");
            JObject projectcCollection2 = JObject.Parse("{ \"name\": \"collection2\" }");

            Dictionary <string, JArray> projectsLookup = new Dictionary <string, JArray> {
                { "collection1", JArray.Parse("[{ \"name\": \"Playground1\" },{ \"name\": \"Playground11\" }]") },
                { "collection2", JArray.Parse("[{ \"name\": \"Playground2\" },{ \"name\": \"Playground22\" }]") }
            };

            TfsDataService = new StubITfsDataService {
                RetrieveProjectCollections           = () => new JArray(projectcCollection1, projectcCollection2),
                RetrieveProjectsTfsProjectCollection = projectCollection => projectsLookup[projectCollection.Name]
            };

            PowerShell = PowerShell.Create(RunspaceMode.NewRunspace);
            PowerShell.NewDrive(TfsDriveName, TfsDataService);
        }
 public TfsDrive(TfsDriveInfo driveInfo) : base(driveInfo.Root)
 {
     DataService = driveInfo.TfsDataService;
 }
        public static PowerShell NewDrive(this PowerShell powerShell, string driveName, ITfsDataService tfsDataService)
        {
            powerShell.AddScript($@"
        param (
          [{typeof(ITfsDataService).FullName}]$tfsDataService
        )
        $env:PSModulePath = ""$env:PSModulePath;{AbsoluteModulePath}"";
        Import-Module PSDT.TfsProvider;
        $driveInfo = New-PSDrive -PSProvider TeamFoundationServer -Name {driveName} -Root {driveName}:\ -DataService $tfsDataService;
        Set-Location {driveName}:;");

            powerShell.AddParameter("tfsDataService", new PSObject(tfsDataService));

            powerShell.Streams.Error.ForwardToConsole();

            return(powerShell);
        }