Infinity.NET is a .NET client library for the Visual Studio REST API, providing access to Visual Studio Online and Team Foundation Server 14.0 servers.
var client = new TfsClient(new TfsClientConfiguration
{
Url = new Uri("https://my-account.visualstudio.com/DefaultCollection"),
Username = "my-username",
Password = "my-password",
});
IEnumerable<Project> projects = new List<Project>();
Task.Run(async () =>
{
projects = await client.Project.GetProjects();
}).Wait();
Infinity.NET is a work in progress; it is not yet fully complete. Here are the currently implemented client functions:
- Git: 100%
- Projects and Teams
- Projects: 100%
- Teams: 100%
- Team Rooms
- Messages: 100%
- Rooms: 100%
- Users: 100%
The REST APIs are tested by mocking them, using the Visual Studio Online REST API Reference examples. To add a new test:
-
Add the expected JSON output from the REST method in the
Infinity.Tests/Resources
directory. Ensure that the file is added to theInfinity.Tests
project. -
Add the file as a resource to the
Infinity.Tests
project. -
Add a new unit test that expects the appropriate URL and (for
POST
orPUT
methods) the appropriate JSON input and returns the given resource. For example:TfsClient mockClient = NewMockClient( new MockRequestConfiguration { // The URI given in the API Reference Uri = "/_apis/model/action", // The name of the resource containing the JSON response ResponseResource = "Model.Action", }); Model model = base.ExecuteSync<Model>( () => { return client.Model.Action(); });
-
Write the test assertions. You can use the
Infinity.Tests/Resources/test_from_json.pl
script to generate assertions from the expected JSON output.
A simple command-line interface is available in the Infinity.Clients
project. For example, to merge a pull request:
Infinity.Client https://account.visualstudio.com/DefaultCollection
--username=username --password=password Git.UpdatePullRequest
<RepositoryId> <PullRequestId> Completed <CommitId
This project is not made to be authoritative, but it may help in development and debugging.
Copyright (c) Edward Thomson. All rights reserved.
Available under the MIT license (refer to the LICENSE file).