2 // Microsoft.TeamFoundation.Client.CommonStructureServiceTest
5 // Joel Reed (joelwreed@gmail.com)
7 // Copyright (C) 2007 Joel Reed
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Microsoft
.TeamFoundation
;
32 using Microsoft
.TeamFoundation
.Client
;
33 using Microsoft
.TeamFoundation
.Server
;
35 namespace Microsoft
.TeamFoundation
.Client
37 using NUnit
.Framework
;
40 public class CommonStructureServiceTest
42 private string tfsUrl
;
43 private ICredentials credentials
;
46 public void FixtureSetUp()
48 tfsUrl
= Environment
.GetEnvironmentVariable("TFS_URL");
49 if (String
.IsNullOrEmpty(tfsUrl
))
51 Console
.WriteLine("Warning: Environment variable TFS_URL not set.");
52 Console
.WriteLine(" Some tests cannot be executed without TFS_URL.");
56 string username
= Environment
.GetEnvironmentVariable("TFS_USERNAME");
57 if (String
.IsNullOrEmpty(username
))
59 Console
.WriteLine("Warning: No TFS user credentials specified.");
63 credentials
= new NetworkCredential(username
,
64 Environment
.GetEnvironmentVariable("TFS_PASSWORD"),
65 Environment
.GetEnvironmentVariable("TFS_DOMAIN"));
69 public void GetService_CommonStructureService()
71 // need TFS_ envvars for this test
72 if (String
.IsNullOrEmpty(tfsUrl
)) return;
73 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
75 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
76 Assert
.IsNotNull(css
);
80 public void ListProjects()
82 // need TFS_ envvars for this test
83 if (String
.IsNullOrEmpty(tfsUrl
)) return;
84 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
86 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
87 ProjectInfo
[] projects
= css
.ListProjects();
89 foreach (ProjectInfo pinfo
in projects
)
91 Assert
.IsNotNull(pinfo
.Name
);
96 public void ListAllProjects()
98 // need TFS_ envvars for this test
99 if (String
.IsNullOrEmpty(tfsUrl
)) return;
100 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
102 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
103 ProjectInfo
[] projects
= css
.ListAllProjects();
105 foreach (ProjectInfo pinfo
in projects
)
107 Assert
.IsNotNull(pinfo
.Name
);
108 Assert
.IsNotNull(pinfo
.Status
);
109 Assert
.IsNotNull(pinfo
.Uri
);
114 public void GetProjectFromName()
116 // need TFS_ envvars for this test
117 if (String
.IsNullOrEmpty(tfsUrl
)) return;
118 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
120 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
121 ProjectInfo pinfo
= css
.GetProjectFromName(Environment
.GetEnvironmentVariable("TFS_PROJECT"));
123 Assert
.IsNotNull(pinfo
.Name
);
124 Assert
.IsNotNull(pinfo
.Status
);
125 Assert
.IsNotNull(pinfo
.Uri
);
129 public void GetProject()
131 // need TFS_ envvars for this test
132 if (String
.IsNullOrEmpty(tfsUrl
)) return;
133 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
135 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
136 ProjectInfo p1
= css
.GetProjectFromName(Environment
.GetEnvironmentVariable("TFS_PROJECT"));
137 ProjectInfo p2
= css
.GetProject(p1
.Uri
);
139 Assert
.IsNotNull(p2
.Name
);
140 Assert
.IsNotNull(p2
.Status
);
141 Assert
.IsNotNull(p2
.Uri
);
145 public void GetProjectProperties()
147 // need TFS_ envvars for this test
148 if (String
.IsNullOrEmpty(tfsUrl
)) return;
149 TeamFoundationServer tfs
= new TeamFoundationServer(tfsUrl
, credentials
);
151 ICommonStructureService css
= (ICommonStructureService
) tfs
.GetService(typeof(ICommonStructureService
));
152 ProjectInfo p1
= css
.GetProjectFromName(Environment
.GetEnvironmentVariable("TFS_PROJECT"));
154 string projectName
= "";
157 ProjectProperty
[] properties
= null;
159 css
.GetProjectProperties(p1
.Uri
, out projectName
, out state
, out templateId
, out properties
);
160 Assert
.IsNotNull(projectName
);