-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrii Snihyr
committed
Aug 27, 2018
1 parent
3a76301
commit 107276c
Showing
16 changed files
with
273 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
|
||
[](https://ci.appveyor.com/project/BerserkerDotNet/vsts-net) | ||
|
||
[](https://www.nuget.org/packages/VSTS.Net) | ||
[](https://www.nuget.org/packages/VSTS.Net) | ||
|
||
[](https://www.nuget.org/packages/VSTS.Net.AspNetCore) | ||
[](https://www.nuget.org/packages/VSTS.Net.AspNetCore) | ||
|
||
[Api documentation](https://berserkerdotnet.github.io/VSTS.Net/site/api/index.html) | ||
|
||
|
@@ -17,9 +17,11 @@ | |
var query = @"SELECT [System.Id] FROM WorkItems | ||
WHERE [System.WorkItemType] IN ('Bug', 'Task') AND [System.AssignedTo] Ever '[email protected]' AND System.ChangedDate >= '01/01/2018'"; | ||
|
||
var client = VstsClient.Get(instanceName: "foo", accessToken: "secure token"); | ||
var urlBuilderFactory = new OnlineUrlBuilderFactory("foo"); | ||
var client = VstsClient.Get(urlBuilderFactory, accessToken: "secure token"); | ||
var items = await client.GetWorkItemsAsync(new WorkItemsQuery(query)); | ||
``` | ||
For OnPrem (TFS) versions use `OnPremUrlBuilderFactory` instead of `OnlineUrlBuilderFactory` | ||
|
||
### Asp.Net Core | ||
In the `Startup.cs` add `VstsNet` to the services collection | ||
|
@@ -28,6 +30,12 @@ In the `Startup.cs` add `VstsNet` to the services collection | |
services.AddVstsNet(instanceName: "foo", accessToken: "secure token"); | ||
``` | ||
|
||
or if you have OnPrem (TFS) version: | ||
|
||
```csharp | ||
services.AddVstsNet(new Uri("https://foo.mydomain.com"), accessToken: "secure token"); | ||
``` | ||
|
||
Now you can consume Vsts client through DI: | ||
|
||
```csharp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using VSTS.Net.Types; | ||
|
||
namespace VSTS.Net.Tests.UrlBuilder | ||
{ | ||
[TestFixture] | ||
public class UrlBuilderFactoryTests | ||
{ | ||
[Test] | ||
public void OnlineUrlBuilderFactoryTest() | ||
{ | ||
var factory = new OnlineUrlBuilderFactory(instance: "foo", subDomain: "bar"); | ||
var result = factory.Create().Build(); | ||
|
||
result.Should().Be($"https://foo.bar.visualstudio.com?api-version={Constants.CurrentWorkItemsApiVersion}"); | ||
} | ||
|
||
[Test] | ||
public void OnPremUrlBuilderFactoryTest() | ||
{ | ||
var factory = new OnPremUrlBuilderFactory(new Uri("https://foo.com")); | ||
var result = factory.Create().Build(); | ||
|
||
result.Should().Be($"https://foo.com?api-version={Constants.CurrentWorkItemsApiVersion}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using System; | ||
using VSTS.Net.Types; | ||
|
||
namespace VSTS.Net.Tests.UrlBuilder | ||
{ | ||
[TestFixture] | ||
public class UrlBuilderTests | ||
{ | ||
[Test] | ||
public void ComposeOnlineUrlWithInstanceName() | ||
{ | ||
var result = VstsUrlBuilder.Create("foo").Build(); | ||
result.Should().Be($"https://foo.visualstudio.com?api-version={Constants.CurrentWorkItemsApiVersion}"); | ||
} | ||
|
||
[Test] | ||
public void ComposeOnlineUrlWihSubdomainAndInstanceName() | ||
{ | ||
var result = VstsUrlBuilder.Create(instance: "foo", subDomain: "bar.buzz").Build(); | ||
result.Should().Be($"https://foo.bar.buzz.visualstudio.com?api-version={Constants.CurrentWorkItemsApiVersion}"); | ||
} | ||
|
||
[TestCase("http://foo.mycompany.com")] | ||
[TestCase("https://foo.mycompany.com")] | ||
[TestCase("https://foo.mycompany.buzz.com")] | ||
[TestCase("http://localhost:45789")] | ||
[TestCase("http://localhost/")] | ||
public void ComposeUrlWithCustomBaseAddress(string baseAddress) | ||
{ | ||
var result = VstsUrlBuilder.Create(new Uri(baseAddress)).Build(); | ||
result.Should().Be($"{baseAddress.Trim('/')}?api-version={Constants.CurrentWorkItemsApiVersion}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
using VSTS.Net.Types; | ||
|
||
namespace VSTS.Net.Interfaces | ||
{ | ||
public interface IVstsUrlBuilderFactory | ||
{ | ||
VstsUrlBuilder Create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using VSTS.Net.Interfaces; | ||
|
||
namespace VSTS.Net.Types | ||
{ | ||
public class OnPremUrlBuilderFactory : IVstsUrlBuilderFactory | ||
{ | ||
private readonly Uri _baseUri; | ||
|
||
public OnPremUrlBuilderFactory(Uri baseUri) | ||
{ | ||
_baseUri = baseUri; | ||
} | ||
|
||
public VstsUrlBuilder Create() | ||
{ | ||
return VstsUrlBuilder.Create(_baseUri); | ||
} | ||
} | ||
} |
Oops, something went wrong.