Convert non-Mircosoft test projects to Xunit.
Required changing test project dependencies, changing code to use Xunit attribute markup (instead of mstest markup), and adding the Xunit.Wpf single-thread-apartment utility.
This commit is contained in:
Родитель
ce1c34bb18
Коммит
39067c751b
|
@ -1,34 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Alm.Authentication;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Net;
|
||||
using Microsoft.Alm.Authentication;
|
||||
using Xunit;
|
||||
|
||||
namespace Atlassian.Bitbucket.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class AuthenticationTest
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyBitbucketOrgIsIdentified()
|
||||
{
|
||||
var targetUri = new TargetUri("https://bitbucket.org");
|
||||
var bbAuth = Authentication.GetAuthentication(targetUri, new MockCredentialStore(), null, null);
|
||||
|
||||
Assert.IsNotNull(bbAuth);
|
||||
Assert.NotNull(bbAuth);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyNonBitbucketOrgIsIgnored()
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var bbAuth = Authentication.GetAuthentication(targetUri, new MockCredentialStore(), null, null);
|
||||
|
||||
Assert.IsNull(bbAuth);
|
||||
Assert.Null(bbAuth);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifySetCredentialStoresValidCredentials()
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
|
@ -45,72 +44,82 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
&& wc.Key.Contains(credentials.Username)
|
||||
&& wc.Key.Contains(credentials.Password));
|
||||
|
||||
Assert.AreEqual(writeCalls.Count(), 1);
|
||||
Assert.Equal(writeCalls.Count(), 1);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
[Fact]
|
||||
public void VerifySetCredentialDoesNotStoreForNullTargetUri()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential("a", "b");
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential("a", "b");
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
|
||||
bbAuth.SetCredentials(null, credentials);
|
||||
bbAuth.SetCredentials(null, credentials);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
[Fact]
|
||||
public void VerifySetCredentialDoesNotStoresForNullCredentials()
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
|
||||
bbAuth.SetCredentials(targetUri, null);
|
||||
bbAuth.SetCredentials(targetUri, null);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Fact]
|
||||
public void VerifySetCredentialDoesNotStoreForTooLongPassword()
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential("a", new string('x', 2047 + 1));
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential("a", new string('x', 2047 + 1));
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
|
||||
bbAuth.SetCredentials(targetUri, credentials);
|
||||
bbAuth.SetCredentials(targetUri, credentials);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Fact]
|
||||
public void VerifySetCredentialDoesNotStoreForTooLongUsername()
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential(new string('x', 2047 + 1), "b");
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
var targetUri = new TargetUri("https://example.com");
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var credentials = new Credential(new string('x', 2047 + 1), "b");
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
|
||||
bbAuth.SetCredentials(targetUri, credentials);
|
||||
bbAuth.SetCredentials(targetUri, credentials);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
[Fact]
|
||||
public void VerifyDeleteCredentialDoesNotDeleteForNullTargetUri()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
var bbAuth = new Authentication(credentialStore, null, null);
|
||||
|
||||
bbAuth.DeleteCredentials(null);
|
||||
bbAuth.DeleteCredentials(null);
|
||||
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
.SelectMany(mc => mc.Value);
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
.SelectMany(mc => mc.Value);
|
||||
|
||||
Assert.AreEqual(deleteCalls.Count(), 0);
|
||||
Assert.Equal(deleteCalls.Count(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyDeleteCredentialForBasicAuthReadsTwiceDeletesOnce()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -127,21 +136,21 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
.SelectMany(mc => mc.Value);
|
||||
|
||||
// 2 read calls, 1 for the basic uri and 1 for /refresh_token
|
||||
Assert.AreEqual(2, readCalls.Count());
|
||||
Assert.IsTrue(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.IsTrue(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(2, readCalls.Count());
|
||||
Assert.True(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.True(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
.SelectMany(mc => mc.Value);
|
||||
|
||||
// 1 delete call, 1 for the basic uri 0 for /refresh_token as there isn't one
|
||||
Assert.AreEqual(1, deleteCalls.Count());
|
||||
Assert.IsTrue(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.IsFalse(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(1, deleteCalls.Count());
|
||||
Assert.True(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.False(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyDeleteCredentialForOAuthReadsTwiceDeletesTwice()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -159,21 +168,21 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
.SelectMany(mc => mc.Value);
|
||||
|
||||
// 2 read calls, 1 for the basic uri and 1 for /refresh_token
|
||||
Assert.AreEqual(2, readCalls.Count());
|
||||
Assert.IsTrue(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.IsTrue(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(2, readCalls.Count());
|
||||
Assert.True(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.True(readCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
.SelectMany(mc => mc.Value);
|
||||
|
||||
// 2 delete call, 1 for the basic uri, 1 for /refresh_token as there is one
|
||||
Assert.AreEqual(2, deleteCalls.Count());
|
||||
Assert.IsTrue(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.IsTrue(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(2, deleteCalls.Count());
|
||||
Assert.True(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.True(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyDeleteCredentialForBasicAuthReadsQuinceDeletesTwiceIfHostCredentialsExistAndShareUsername()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -198,11 +207,11 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
// 1 for the basic uri to compare username
|
||||
// 1 for the basic uri without username
|
||||
// 1 for /refresh_token without username
|
||||
Assert.AreEqual(5, readCalls.Count());
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/refresh_token")));
|
||||
Assert.AreEqual(2, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(5, readCalls.Count());
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/refresh_token")));
|
||||
Assert.Equal(2, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
|
@ -211,13 +220,13 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
// 2 delete calls
|
||||
// 1 for the basic uri with username
|
||||
// 1 for the basic uri without username
|
||||
Assert.AreEqual(2, deleteCalls.Count());
|
||||
Assert.AreEqual(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.IsFalse(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.AreEqual(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.Equal(2, deleteCalls.Count());
|
||||
Assert.Equal(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.False(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.Equal(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyDeleteCredentialForBasicAuthReadsThriceDeletesOnceIfHostCredentialsExistAndDoNotShareUsername()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -240,10 +249,10 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
// 1 for the basic uri with username
|
||||
// 1 for /refresh_token with username
|
||||
// 1 for the basic uri to compare username
|
||||
Assert.AreEqual(3, readCalls.Count());
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/refresh_token")));
|
||||
Assert.AreEqual(1, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.Equal(3, readCalls.Count());
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/refresh_token")));
|
||||
Assert.Equal(1, readCalls.Count(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
|
||||
var deleteCalls = credentialStore.MethodCalls
|
||||
.Where(mc => mc.Key.Equals("DeleteCredentials"))
|
||||
|
@ -252,13 +261,13 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
// 1 delete calls
|
||||
// 1 for the basic uri with username
|
||||
// DOES NOT delete the Host credentials because they are for a different username.
|
||||
Assert.AreEqual(1, deleteCalls.Count());
|
||||
Assert.AreEqual(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.IsFalse(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.IsFalse(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
Assert.Equal(1, deleteCalls.Count());
|
||||
Assert.Equal(1, deleteCalls.Count(rc => rc.Key[0].Equals("https://john@example.com/")));
|
||||
Assert.False(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/refresh_token")));
|
||||
Assert.False(deleteCalls.Any(rc => rc.Key[0].Equals("https://example.com/")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyGetPerUserTargetUriInsertsMissingUsernameToActualUri()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -269,21 +278,21 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
|
||||
var resultUri = targetUri.GetPerUserTargetUri(username);
|
||||
|
||||
Assert.AreEqual("/", resultUri.AbsolutePath);
|
||||
Assert.AreEqual("https://johnsquire@example.com/", resultUri.ActualUri.AbsoluteUri);
|
||||
Assert.AreEqual("example.com", resultUri.DnsSafeHost);
|
||||
Assert.AreEqual("example.com", resultUri.Host);
|
||||
Assert.AreEqual(true, resultUri.IsAbsoluteUri);
|
||||
Assert.AreEqual(true, resultUri.IsDefaultPort);
|
||||
Assert.AreEqual(443, resultUri.Port);
|
||||
Assert.AreEqual(null, resultUri.ProxyUri);
|
||||
Assert.AreEqual("https://johnsquire@example.com/", resultUri.QueryUri.AbsoluteUri);
|
||||
Assert.AreEqual("https", resultUri.Scheme);
|
||||
Assert.AreEqual(new WebProxy().Address, resultUri.WebProxy.Address);
|
||||
Assert.AreEqual("https://example.com/", resultUri.ToString());
|
||||
Assert.Equal("/", resultUri.AbsolutePath);
|
||||
Assert.Equal("https://johnsquire@example.com/", resultUri.ActualUri.AbsoluteUri);
|
||||
Assert.Equal("example.com", resultUri.DnsSafeHost);
|
||||
Assert.Equal("example.com", resultUri.Host);
|
||||
Assert.Equal(true, resultUri.IsAbsoluteUri);
|
||||
Assert.Equal(true, resultUri.IsDefaultPort);
|
||||
Assert.Equal(443, resultUri.Port);
|
||||
Assert.Equal(null, resultUri.ProxyUri);
|
||||
Assert.Equal("https://johnsquire@example.com/", resultUri.QueryUri.AbsoluteUri);
|
||||
Assert.Equal("https", resultUri.Scheme);
|
||||
Assert.Equal(new WebProxy().Address, resultUri.WebProxy.Address);
|
||||
Assert.Equal("https://example.com/", resultUri.ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void VerifyGetPerUserTargetUriDoesNotDuplicateUsernameOnActualUri()
|
||||
{
|
||||
var credentialStore = new MockCredentialStore();
|
||||
|
@ -294,22 +303,22 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
|
||||
var resultUri = targetUri.GetPerUserTargetUri(username);
|
||||
|
||||
Assert.AreEqual("/", resultUri.AbsolutePath);
|
||||
Assert.AreEqual("https://johnsquire@example.com/", resultUri.ActualUri.AbsoluteUri);
|
||||
Assert.AreEqual("example.com", resultUri.DnsSafeHost);
|
||||
Assert.AreEqual("example.com", resultUri.Host);
|
||||
Assert.AreEqual(true, resultUri.IsAbsoluteUri);
|
||||
Assert.AreEqual(true, resultUri.IsDefaultPort);
|
||||
Assert.AreEqual(443, resultUri.Port);
|
||||
Assert.AreEqual(null, resultUri.ProxyUri);
|
||||
Assert.AreEqual("https://johnsquire@example.com/", resultUri.QueryUri.AbsoluteUri);
|
||||
Assert.AreEqual("https", resultUri.Scheme);
|
||||
Assert.AreEqual(new WebProxy().Address, resultUri.WebProxy.Address);
|
||||
Assert.AreEqual("https://example.com/", resultUri.ToString());
|
||||
Assert.Equal("/", resultUri.AbsolutePath);
|
||||
Assert.Equal("https://johnsquire@example.com/", resultUri.ActualUri.AbsoluteUri);
|
||||
Assert.Equal("example.com", resultUri.DnsSafeHost);
|
||||
Assert.Equal("example.com", resultUri.Host);
|
||||
Assert.Equal(true, resultUri.IsAbsoluteUri);
|
||||
Assert.Equal(true, resultUri.IsDefaultPort);
|
||||
Assert.Equal(443, resultUri.Port);
|
||||
Assert.Equal(null, resultUri.ProxyUri);
|
||||
Assert.Equal("https://johnsquire@example.com/", resultUri.QueryUri.AbsoluteUri);
|
||||
Assert.Equal("https", resultUri.Scheme);
|
||||
Assert.Equal(new WebProxy().Address, resultUri.WebProxy.Address);
|
||||
Assert.Equal("https://example.com/", resultUri.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class MockCredentialStore: ICredentialStore
|
||||
public class MockCredentialStore : ICredentialStore
|
||||
{
|
||||
public Dictionary<string, Dictionary<List<string>, int>> MethodCalls =
|
||||
new Dictionary<string, Dictionary<List<string>, int>>();
|
||||
|
@ -329,20 +338,20 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
public void DeleteCredentials(TargetUri targetUri)
|
||||
{
|
||||
// do nothing
|
||||
RecordMethodCall("DeleteCredentials", new List<string>() {targetUri.ActualUri.AbsoluteUri });
|
||||
RecordMethodCall("DeleteCredentials", new List<string>() { targetUri.ActualUri.AbsoluteUri });
|
||||
}
|
||||
|
||||
public Credential ReadCredentials(TargetUri targetUri)
|
||||
{
|
||||
// do nothing
|
||||
RecordMethodCall("ReadCredentials", new List<string>() {targetUri.ActualUri.AbsoluteUri });
|
||||
RecordMethodCall("ReadCredentials", new List<string>() { targetUri.ActualUri.AbsoluteUri });
|
||||
return Credentials != null && Credentials.Keys.Contains(targetUri.ActualUri.AbsoluteUri) ? Credentials[targetUri.ActualUri.AbsoluteUri] : null;
|
||||
}
|
||||
|
||||
public void WriteCredentials(TargetUri targetUri, Credential credentials)
|
||||
{
|
||||
// do nothing
|
||||
RecordMethodCall("WriteCredentials", new List<string>() {targetUri.ActualUri.AbsoluteUri, credentials.Username, credentials.Password });
|
||||
RecordMethodCall("WriteCredentials", new List<string>() { targetUri.ActualUri.AbsoluteUri, credentials.Username, credentials.Password });
|
||||
}
|
||||
|
||||
private void RecordMethodCall(string methodName, List<string> args)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -39,19 +40,19 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="BitbucketAuthTests.cs" />
|
||||
<Compile Include="AuthenticationTest.cs" />
|
||||
|
@ -68,26 +69,12 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -95,6 +82,7 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System.Diagnostics;
|
||||
using Microsoft.Alm.Authentication;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace Atlassian.Bitbucket.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class BitbucketAuthTests
|
||||
{
|
||||
public BitbucketAuthTests()
|
||||
|
@ -12,7 +11,7 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
Trace.Listeners.AddRange(Debug.Listeners);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void BitbucketAuthDeleteCredentialsTest()
|
||||
{
|
||||
var targetUri = new TargetUri("http://localhost");
|
||||
|
@ -24,11 +23,11 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
|
||||
bitbucketAuth.DeleteCredentials(targetUri);
|
||||
|
||||
Assert.IsNull(credentials = bitbucketAuth.PersonalAccessTokenStore.ReadCredentials(targetUri),
|
||||
"User credentials were not deleted as expected");
|
||||
// "User credentials were not deleted as expected"
|
||||
Assert.Null(credentials = bitbucketAuth.PersonalAccessTokenStore.ReadCredentials(targetUri));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void BitbucketAuthGetCredentialsTest()
|
||||
{
|
||||
var targetUri = new TargetUri("http://localhost");
|
||||
|
@ -36,18 +35,18 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
|
||||
Credential credentials = null;
|
||||
|
||||
Assert.IsNull(credentials = bitbucketAuth.GetCredentials(targetUri),
|
||||
"User credentials were unexpectedly retrieved.");
|
||||
// "User credentials were unexpectedly retrieved."
|
||||
Assert.Null(credentials = bitbucketAuth.GetCredentials(targetUri));
|
||||
|
||||
credentials = new Credential("username", "password");
|
||||
|
||||
bitbucketAuth.PersonalAccessTokenStore.WriteCredentials(targetUri, credentials);
|
||||
|
||||
Assert.IsNotNull(credentials = bitbucketAuth.GetCredentials(targetUri),
|
||||
"User credentials were unexpectedly not retrieved.");
|
||||
// "User credentials were unexpectedly not retrieved."
|
||||
Assert.NotNull(credentials = bitbucketAuth.GetCredentials(targetUri));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void BitbucketAuthSetCredentialsTest()
|
||||
{
|
||||
var targetUri = new TargetUri("http://localhost");
|
||||
|
@ -55,23 +54,20 @@ namespace Atlassian.Bitbucket.Authentication.Test
|
|||
|
||||
Credential credentials = null;
|
||||
|
||||
Assert.IsNull(credentials = bitbucketAuth.GetCredentials(targetUri),
|
||||
"User credentials were unexpectedly retrieved.");
|
||||
try
|
||||
// "User credentials were unexpectedly retrieved."
|
||||
Assert.Null(credentials = bitbucketAuth.GetCredentials(targetUri));
|
||||
|
||||
Assert.Throws<System.ArgumentNullException>(() =>
|
||||
{
|
||||
bitbucketAuth.SetCredentials(targetUri, credentials);
|
||||
Assert.Fail("User credentials were unexpectedly set.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
credentials = new Credential("username", "password");
|
||||
|
||||
bitbucketAuth.SetCredentials(targetUri, credentials);
|
||||
|
||||
Assert.IsNotNull(credentials = bitbucketAuth.GetCredentials(targetUri),
|
||||
"User credentials were unexpectedly not retrieved.");
|
||||
// "User credentials were unexpectedly not retrieved."
|
||||
Assert.NotNull(credentials = bitbucketAuth.GetCredentials(targetUri));
|
||||
}
|
||||
|
||||
private Authentication GetBitbucketAuthentication(string @namespace)
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -57,7 +56,6 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
|
@ -90,6 +88,10 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
|
@ -98,8 +100,8 @@
|
|||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<package id="Castle.Core" version="4.1.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="Moq" version="4.7.63" targetFramework="net452" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26612.0
|
||||
VisualStudioVersion = 15.0.26621.2
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{663DC05D-FDC6-4EAB-AC4B-983D486B92B9}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
|
@ -13,6 +13,7 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{D6456F11-40CB-4E55-8761-FF2199A7004C}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
analysisRules.ruleset = analysisRules.ruleset
|
||||
xunit.runner.json = xunit.runner.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Alm.Git", "Microsoft.Alm.Git\Microsoft.Alm.Git.csproj", "{19770407-5C58-406D-AB3F-3700BB0D06FE}"
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
using GitHub.Shared.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class ActionCommandTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void CanExecuteIsTrueByDefault()
|
||||
{
|
||||
var command = new ActionCommand(_ => { });
|
||||
Assert.IsTrue(command.CanExecute(null));
|
||||
Assert.True(command.CanExecute(null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void CanExecuteReturnsFalseWhenIsEnabledIsFalse()
|
||||
{
|
||||
var command = new ActionCommand(_ => { }) { IsEnabled = false };
|
||||
Assert.IsFalse(command.CanExecute(null));
|
||||
Assert.False(command.CanExecute(null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ExecuteCallsActionWhenExecuted()
|
||||
{
|
||||
var parameter = new object();
|
||||
|
@ -28,7 +27,7 @@ namespace GitHub.Authentication.Test
|
|||
var command = new ActionCommand(_ => { suppliedParameter = parameter; }) { IsEnabled = true };
|
||||
command.Execute(parameter);
|
||||
|
||||
Assert.AreSame(parameter, suppliedParameter);
|
||||
Assert.Same(parameter, suppliedParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
using GitHub.Shared.Controls;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test.Controls
|
||||
{
|
||||
[TestClass]
|
||||
public class MaskedPasswordBoxTests
|
||||
{
|
||||
[TestMethod]
|
||||
[WpfFact]
|
||||
public void TextReplacedWithMaskCharacterAndPasswordPropertyContainsRealPassword()
|
||||
{
|
||||
var passwordTextInput = new MaskedPasswordBox();
|
||||
// Set the base Text property. The one that entering text into the UI would set.
|
||||
((PromptTextBox)passwordTextInput).Text = "secr3t!";
|
||||
|
||||
Assert.AreEqual("●●●●●●●", ((PromptTextBox)passwordTextInput).Text);
|
||||
Assert.AreEqual("secr3t!", passwordTextInput.Password);
|
||||
Assert.Equal("●●●●●●●", ((PromptTextBox)passwordTextInput).Text);
|
||||
Assert.Equal("secr3t!", passwordTextInput.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,39 @@
|
|||
using GitHub.Authentication.ViewModels;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class CredentialsViewModelTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidatesLoginAndPassword()
|
||||
{
|
||||
var viewModel = new CredentialsViewModel();
|
||||
Assert.IsFalse(viewModel.LoginValidator.ValidationResult.IsValid);
|
||||
Assert.IsFalse(viewModel.PasswordValidator.ValidationResult.IsValid);
|
||||
Assert.False(viewModel.LoginValidator.ValidationResult.IsValid);
|
||||
Assert.False(viewModel.PasswordValidator.ValidationResult.IsValid);
|
||||
|
||||
viewModel.Login = "Tyrion";
|
||||
viewModel.Password = "staying alive";
|
||||
|
||||
Assert.IsTrue(viewModel.LoginValidator.ValidationResult.IsValid);
|
||||
Assert.IsTrue(viewModel.PasswordValidator.ValidationResult.IsValid);
|
||||
Assert.True(viewModel.LoginValidator.ValidationResult.IsValid);
|
||||
Assert.True(viewModel.PasswordValidator.ValidationResult.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void IsValidWhenBothLoginAndPasswordIsValid()
|
||||
{
|
||||
var viewModel = new CredentialsViewModel();
|
||||
Assert.IsFalse(viewModel.ModelValidator.IsValid);
|
||||
Assert.False(viewModel.ModelValidator.IsValid);
|
||||
viewModel.Login = "Tyrion";
|
||||
Assert.IsFalse(viewModel.ModelValidator.IsValid);
|
||||
Assert.False(viewModel.ModelValidator.IsValid);
|
||||
|
||||
viewModel.Password = "staying alive";
|
||||
|
||||
Assert.IsTrue(viewModel.ModelValidator.IsValid);
|
||||
Assert.True(viewModel.ModelValidator.IsValid);
|
||||
|
||||
viewModel.Login = "";
|
||||
|
||||
Assert.IsFalse(viewModel.ModelValidator.IsValid);
|
||||
Assert.False(viewModel.ModelValidator.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -36,7 +37,6 @@
|
|||
<CodeAnalysisRuleSet>..\analysisRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
|
@ -45,6 +45,18 @@
|
|||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActionCommandTests.cs" />
|
||||
|
@ -59,6 +71,11 @@
|
|||
<Compile Include="Validation\ValidatableTestObject.cs" />
|
||||
<Compile Include="Validation\ValidationExtensionsTests.cs" />
|
||||
<Compile Include="Validation\ValidationMessageTests.cs" />
|
||||
<Compile Include="Xunit\WpfFactAttribute.cs.cs" />
|
||||
<Compile Include="Xunit\WpfFactDiscoverer.cs" />
|
||||
<Compile Include="Xunit\WpfTestCase.cs" />
|
||||
<Compile Include="Xunit\WpfTheoryAttribute.cs" />
|
||||
<Compile Include="Xunit\WpfTheoryDiscoverer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GitHub.Authentication\GitHub.Authentication.csproj">
|
||||
|
@ -74,6 +91,10 @@
|
|||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
@ -82,6 +103,7 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,59 +1,58 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class GitHubTokenScopeTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void AddOperator()
|
||||
{
|
||||
var val = TokenScope.Gist + TokenScope.Notifications;
|
||||
Assert.AreEqual(val.Value, TokenScope.Gist.Value + " " + TokenScope.Notifications.Value);
|
||||
Assert.Equal(val.Value, TokenScope.Gist.Value + " " + TokenScope.Notifications.Value);
|
||||
|
||||
val += TokenScope.OrgAdmin;
|
||||
Assert.AreEqual(val.Value, TokenScope.Gist.Value + " " + TokenScope.Notifications.Value + " " + TokenScope.OrgAdmin);
|
||||
Assert.Equal(val.Value, TokenScope.Gist.Value + " " + TokenScope.Notifications.Value + " " + TokenScope.OrgAdmin);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void AndOperator()
|
||||
{
|
||||
var val = (TokenScope.Gist & TokenScope.Gist);
|
||||
Assert.AreEqual(TokenScope.Gist, val);
|
||||
Assert.Equal(TokenScope.Gist, val);
|
||||
|
||||
val = TokenScope.OrgAdmin + TokenScope.OrgHookAdmin + TokenScope.Gist;
|
||||
Assert.IsTrue((val & TokenScope.OrgAdmin) == TokenScope.OrgAdmin);
|
||||
Assert.IsTrue((val & TokenScope.OrgHookAdmin) == TokenScope.OrgHookAdmin);
|
||||
Assert.IsTrue((val & TokenScope.Gist) == TokenScope.Gist);
|
||||
Assert.IsFalse((val & TokenScope.OrgRead) == TokenScope.OrgRead);
|
||||
Assert.IsTrue((val & TokenScope.OrgRead) == TokenScope.None);
|
||||
Assert.True((val & TokenScope.OrgAdmin) == TokenScope.OrgAdmin);
|
||||
Assert.True((val & TokenScope.OrgHookAdmin) == TokenScope.OrgHookAdmin);
|
||||
Assert.True((val & TokenScope.Gist) == TokenScope.Gist);
|
||||
Assert.False((val & TokenScope.OrgRead) == TokenScope.OrgRead);
|
||||
Assert.True((val & TokenScope.OrgRead) == TokenScope.None);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Equality()
|
||||
{
|
||||
Assert.AreEqual(TokenScope.OrgWrite, TokenScope.OrgWrite);
|
||||
Assert.AreEqual(TokenScope.None, TokenScope.None);
|
||||
Assert.Equal(TokenScope.OrgWrite, TokenScope.OrgWrite);
|
||||
Assert.Equal(TokenScope.None, TokenScope.None);
|
||||
|
||||
Assert.AreNotEqual(TokenScope.Gist, TokenScope.PublicKeyAdmin);
|
||||
Assert.AreNotEqual(TokenScope.Gist, TokenScope.None);
|
||||
Assert.NotEqual(TokenScope.Gist, TokenScope.PublicKeyAdmin);
|
||||
Assert.NotEqual(TokenScope.Gist, TokenScope.None);
|
||||
|
||||
Assert.AreEqual(TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
Assert.AreEqual(TokenScope.OrgHookAdmin | TokenScope.OrgRead | TokenScope.PublicKeyRead, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
Assert.Equal(TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
Assert.Equal(TokenScope.OrgHookAdmin | TokenScope.OrgRead | TokenScope.PublicKeyRead, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
|
||||
Assert.AreNotEqual(TokenScope.OrgRead | TokenScope.PublicKeyWrite | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
Assert.AreNotEqual(TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead);
|
||||
Assert.NotEqual(TokenScope.OrgRead | TokenScope.PublicKeyWrite | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin);
|
||||
Assert.NotEqual(TokenScope.OrgRead | TokenScope.PublicKeyRead | TokenScope.OrgHookAdmin, TokenScope.OrgRead | TokenScope.PublicKeyRead);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void HashCode()
|
||||
{
|
||||
HashSet<int> hashCodes = new HashSet<int>();
|
||||
|
||||
foreach (var item in TokenScope.EnumerateValues())
|
||||
{
|
||||
Assert.IsTrue(hashCodes.Add(item.GetHashCode()));
|
||||
Assert.True(hashCodes.Add(item.GetHashCode()));
|
||||
}
|
||||
|
||||
int loop1 = 0;
|
||||
|
@ -65,11 +64,11 @@ namespace GitHub.Authentication.Test
|
|||
{
|
||||
if (loop1 < loop2)
|
||||
{
|
||||
Assert.IsTrue(hashCodes.Add((item1 | item2).GetHashCode()));
|
||||
Assert.True(hashCodes.Add((item1 | item2).GetHashCode()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(hashCodes.Add((item1 | item2).GetHashCode()));
|
||||
Assert.False(hashCodes.Add((item1 | item2).GetHashCode()));
|
||||
}
|
||||
|
||||
loop2++;
|
||||
|
@ -79,48 +78,48 @@ namespace GitHub.Authentication.Test
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void OrOperator()
|
||||
{
|
||||
var val1 = (TokenScope.Gist | TokenScope.Gist);
|
||||
Assert.AreEqual(TokenScope.Gist, val1);
|
||||
Assert.Equal(TokenScope.Gist, val1);
|
||||
|
||||
val1 = TokenScope.OrgAdmin + TokenScope.OrgHookAdmin + TokenScope.Gist;
|
||||
var val2 = val1 | TokenScope.OrgAdmin;
|
||||
Assert.AreEqual(val1, val2);
|
||||
Assert.Equal(val1, val2);
|
||||
|
||||
val2 = TokenScope.OrgAdmin | TokenScope.OrgHookAdmin | TokenScope.Gist;
|
||||
Assert.AreEqual(val1, val2);
|
||||
Assert.IsTrue((val2 & TokenScope.OrgAdmin) == TokenScope.OrgAdmin);
|
||||
Assert.IsTrue((val2 & TokenScope.OrgHookAdmin) == TokenScope.OrgHookAdmin);
|
||||
Assert.IsTrue((val2 & TokenScope.Gist) == TokenScope.Gist);
|
||||
Assert.IsFalse((val2 & TokenScope.OrgRead) == TokenScope.OrgRead);
|
||||
Assert.Equal(val1, val2);
|
||||
Assert.True((val2 & TokenScope.OrgAdmin) == TokenScope.OrgAdmin);
|
||||
Assert.True((val2 & TokenScope.OrgHookAdmin) == TokenScope.OrgHookAdmin);
|
||||
Assert.True((val2 & TokenScope.Gist) == TokenScope.Gist);
|
||||
Assert.False((val2 & TokenScope.OrgRead) == TokenScope.OrgRead);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void MinusOperator()
|
||||
{
|
||||
var val1 = TokenScope.Gist | TokenScope.Repo | TokenScope.RepoDelete;
|
||||
var val2 = val1 - TokenScope.RepoDelete;
|
||||
Assert.AreEqual(val2, TokenScope.Gist | TokenScope.Repo);
|
||||
Assert.Equal(val2, TokenScope.Gist | TokenScope.Repo);
|
||||
|
||||
var val3 = val1 - val2;
|
||||
Assert.AreEqual(val3, TokenScope.RepoDelete);
|
||||
Assert.Equal(val3, TokenScope.RepoDelete);
|
||||
|
||||
var val4 = val3 - TokenScope.RepoDeployment;
|
||||
Assert.AreEqual(val3, val4);
|
||||
Assert.Equal(val3, val4);
|
||||
|
||||
var val5 = (TokenScope.Gist + TokenScope.Repo) - (TokenScope.Repo | TokenScope.RepoHookAdmin | TokenScope.OrgWrite);
|
||||
Assert.AreEqual(val5, TokenScope.Gist);
|
||||
Assert.Equal(val5, TokenScope.Gist);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void XorOperator()
|
||||
{
|
||||
var val1 = TokenScope.RepoDelete + TokenScope.PublicKeyAdmin;
|
||||
var val2 = TokenScope.PublicKeyAdmin + TokenScope.PublicKeyRead;
|
||||
var val3 = val1 ^ val2;
|
||||
Assert.AreEqual(val3, TokenScope.RepoDelete | TokenScope.PublicKeyRead);
|
||||
Assert.Equal(val3, TokenScope.RepoDelete | TokenScope.PublicKeyRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
using GitHub.Authentication.ViewModels;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class TwoFactorViewModelTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void IsValidIsTrueWhenAuthenticationCodeIsSixCharacters()
|
||||
{
|
||||
var vm = new TwoFactorViewModel();
|
||||
vm.AuthenticationCode = "012345";
|
||||
Assert.IsTrue(vm.IsValid);
|
||||
Assert.True(vm.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void IsValidIsFalseWhenAuthenticationCodeIsLessThanSixCharacters()
|
||||
{
|
||||
var vm = new TwoFactorViewModel();
|
||||
vm.AuthenticationCode = "01234";
|
||||
Assert.IsFalse(vm.IsValid);
|
||||
Assert.False(vm.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
using GitHub.Shared.ViewModels.Validation;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test.Validation
|
||||
{
|
||||
[TestClass]
|
||||
public class ModelValidatorTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void IsValidWhenAllValidatorsAreValid()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -18,19 +17,19 @@ namespace GitHub.Authentication.Test.Validation
|
|||
.Required("Error occurred!");
|
||||
var modelValidator = new ModelValidator(validator, anotherValidator);
|
||||
|
||||
Assert.IsFalse(modelValidator.IsValid);
|
||||
Assert.False(modelValidator.IsValid);
|
||||
|
||||
validatableObject.SomeStringProperty = "valid";
|
||||
|
||||
Assert.IsFalse(modelValidator.IsValid);
|
||||
Assert.False(modelValidator.IsValid);
|
||||
|
||||
validatableObject.AnotherStringProperty = "valid";
|
||||
|
||||
Assert.IsTrue(modelValidator.IsValid);
|
||||
Assert.True(modelValidator.IsValid);
|
||||
|
||||
validatableObject.AnotherStringProperty = "";
|
||||
|
||||
Assert.IsFalse(modelValidator.IsValid);
|
||||
Assert.False(modelValidator.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using GitHub.Shared.ViewModels.Validation;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test.Validation
|
||||
{
|
||||
[TestClass]
|
||||
public class PropertyValidatorTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidationResultReturnsUnvalidatedIfNoValidators()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -15,10 +14,10 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.AreEqual(PropertyValidationResult.Unvalidated, result);
|
||||
Assert.Equal(PropertyValidationResult.Unvalidated, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidationResultReturnsSuccessIfValidatorsPass()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -30,10 +29,10 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsTrue(result.IsValid);
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidationResultReturnsFailureIfAnyValidatorsFail()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -46,11 +45,11 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsFalse(result.IsValid);
|
||||
Assert.AreEqual("Error occurred!", result.Message);
|
||||
Assert.False(result.IsValid);
|
||||
Assert.Equal("Error occurred!", result.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidatorsRunInOrderAndStopWhenInvalid()
|
||||
{
|
||||
List<int> results = new List<int>();
|
||||
|
@ -66,13 +65,13 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsFalse(result.IsValid);
|
||||
Assert.AreEqual("Error occurred!", result.Message);
|
||||
Assert.AreEqual(4, results.Count);
|
||||
for (int i = 0; i < 4; i++) Assert.AreEqual(i, results[i]);
|
||||
Assert.False(result.IsValid);
|
||||
Assert.Equal("Error occurred!", result.Message);
|
||||
Assert.Equal(4, results.Count);
|
||||
for (int i = 0; i < 4; i++) Assert.Equal(i, results[i]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ValidationResultNotifiesWhenValidationStateChanges()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -86,12 +85,12 @@ namespace GitHub.Authentication.Test.Validation
|
|||
if (e.PropertyName == nameof(validator.ValidationResult))
|
||||
validationResult = validator.ValidationResult;
|
||||
};
|
||||
Assert.IsNull(validationResult); // Precondition
|
||||
Assert.Null(validationResult); // Precondition
|
||||
|
||||
validatableObject.SomeStringProperty = "not empty";
|
||||
|
||||
Assert.AreEqual(validationResult, validator.ValidationResult);
|
||||
Assert.IsFalse(validationResult.IsValid);
|
||||
Assert.Equal(validationResult, validator.ValidationResult);
|
||||
Assert.False(validationResult.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
using GitHub.Shared.ViewModels.Validation;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test.Validation
|
||||
{
|
||||
[TestClass]
|
||||
public class ValidationExtensionsTests
|
||||
{
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void RequiredIsUnvalidatedAndNotValidIfPropertyNeverChanges()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -16,11 +15,11 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsFalse(result.IsValid);
|
||||
Assert.AreEqual(PropertyValidationResult.Unvalidated, result);
|
||||
Assert.False(result.IsValid);
|
||||
Assert.Equal(PropertyValidationResult.Unvalidated, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void RequiredValidatesPropertyNotNull()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -32,11 +31,11 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsFalse(result.IsValid);
|
||||
Assert.AreEqual("Please provide a value for SomeStringProperty!", result.Message);
|
||||
Assert.False(result.IsValid);
|
||||
Assert.Equal("Please provide a value for SomeStringProperty!", result.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void RequiredValidatesPropertyNotEmpty()
|
||||
{
|
||||
var validatableObject = new ValidatableTestObject();
|
||||
|
@ -47,8 +46,8 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
var result = validator.ValidationResult;
|
||||
|
||||
Assert.IsFalse(result.IsValid);
|
||||
Assert.AreEqual("Please provide a value for SomeStringProperty!", result.Message);
|
||||
Assert.False(result.IsValid);
|
||||
Assert.Equal("Please provide a value for SomeStringProperty!", result.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,13 @@ using System.Windows.Data;
|
|||
using GitHub.Shared.ViewModels;
|
||||
using GitHub.Shared.ViewModels.Validation;
|
||||
using GitHub.UI;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.Authentication.Test.Validation
|
||||
{
|
||||
[TestClass]
|
||||
public class ValidationMessageTests
|
||||
{
|
||||
[TestMethod]
|
||||
[WpfFact]
|
||||
public void DoesNotShowErrorWhenUnvalidated()
|
||||
{
|
||||
var viewModel = new ValidatableTestObject();
|
||||
|
@ -21,10 +20,10 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
validationMessage.Validator = testValidator;
|
||||
|
||||
Assert.IsFalse(validationMessage.ShowError);
|
||||
Assert.False(validationMessage.ShowError);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[WpfFact]
|
||||
public void ShowsErrorWhenValidationResultIsInvalid()
|
||||
{
|
||||
var viewModel = new ValidatableTestObject();
|
||||
|
@ -36,11 +35,11 @@ namespace GitHub.Authentication.Test.Validation
|
|||
viewModel.SomeStringProperty = "valid";
|
||||
viewModel.SomeStringProperty = "";
|
||||
|
||||
Assert.AreEqual(ValidationStatus.Invalid, testValidator.ValidationResult.Status);
|
||||
Assert.IsTrue(validationMessage.ShowError);
|
||||
Assert.Equal(ValidationStatus.Invalid, testValidator.ValidationResult.Status);
|
||||
Assert.True(validationMessage.ShowError);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[WpfFact]
|
||||
public void EndToEndTestShowsErrorMessageWhenReactiveValidatorIsNotValid()
|
||||
{
|
||||
var textBox = new TextBox();
|
||||
|
@ -52,15 +51,15 @@ namespace GitHub.Authentication.Test.Validation
|
|||
|
||||
validationMessage.Validator = testValidator;
|
||||
|
||||
Assert.IsFalse(validationMessage.ShowError);
|
||||
Assert.False(validationMessage.ShowError);
|
||||
|
||||
textBox.Text = "x";
|
||||
Assert.AreEqual("x", viewModel.SomeStringProperty);
|
||||
Assert.Equal("x", viewModel.SomeStringProperty);
|
||||
textBox.Text = "";
|
||||
Assert.AreEqual("", viewModel.SomeStringProperty);
|
||||
Assert.Equal("", viewModel.SomeStringProperty);
|
||||
|
||||
Assert.IsFalse(testValidator.ValidationResult.IsValid);
|
||||
Assert.IsTrue(validationMessage.ShowError);
|
||||
Assert.False(testValidator.ValidationResult.IsValid);
|
||||
Assert.True(validationMessage.ShowError);
|
||||
}
|
||||
|
||||
private void BindControlToViewModel(ViewModel viewModel, string viewModelProperty, FrameworkElement control, DependencyProperty controlProperty)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Borrowed from: https://github.com/xunit/samples.xunit/blob/master/STAExamples/WpfFactAttribute.cs
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
[XunitTestCaseDiscoverer("Xunit.WpfFactDiscoverer", "GitHub.Authentication.Test")]
|
||||
public class WpfFactAttribute : FactAttribute { }
|
|
@ -0,0 +1,25 @@
|
|||
// Borrowed from: https://github.com/xunit/samples.xunit/blob/master/STAExamples/WpfFactDiscoverer.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
public class WpfFactDiscoverer : IXunitTestCaseDiscoverer
|
||||
{
|
||||
readonly FactDiscoverer factDiscoverer;
|
||||
|
||||
public WpfFactDiscoverer(IMessageSink diagnosticMessageSink)
|
||||
{
|
||||
factDiscoverer = new FactDiscoverer(diagnosticMessageSink);
|
||||
}
|
||||
|
||||
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
|
||||
{
|
||||
return factDiscoverer.Discover(discoveryOptions, testMethod, factAttribute)
|
||||
.Select(testCase => new WpfTestCase(testCase));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
// Borrowed from: https://github.com/xunit/samples.xunit/blob/master/STAExamples/WpfTestCase.cs
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps test cases for FactAttribute and TheoryAttribute so the test case runs on the WPF STA thread
|
||||
/// </summary>
|
||||
[DebuggerDisplay(@"\{ class = {TestMethod.TestClass.Class.Name}, method = {TestMethod.Method.Name}, display = {DisplayName}, skip = {SkipReason} \}")]
|
||||
public class WpfTestCase : LongLivedMarshalByRefObject, IXunitTestCase
|
||||
{
|
||||
IXunitTestCase testCase;
|
||||
|
||||
public WpfTestCase(IXunitTestCase testCase)
|
||||
{
|
||||
this.testCase = testCase;
|
||||
}
|
||||
|
||||
/// <summary/>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("Called by the de-serializer", error: true)]
|
||||
public WpfTestCase() { }
|
||||
|
||||
public IMethodInfo Method
|
||||
{
|
||||
get { return testCase.Method; }
|
||||
}
|
||||
|
||||
public Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink,
|
||||
IMessageBus messageBus,
|
||||
object[] constructorArguments,
|
||||
ExceptionAggregator aggregator,
|
||||
CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<RunSummary>();
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// Set up the SynchronizationContext so that any awaits
|
||||
// resume on the STA thread as they would in a GUI app.
|
||||
SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());
|
||||
|
||||
// Start off the test method.
|
||||
var testCaseTask = this.testCase.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource);
|
||||
|
||||
// Arrange to pump messages to execute any async work associated with the test.
|
||||
var frame = new DispatcherFrame();
|
||||
Task.Run(async delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
await testCaseTask;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// The test case's execution is done. Terminate the message pump.
|
||||
frame.Continue = false;
|
||||
}
|
||||
});
|
||||
Dispatcher.PushFrame(frame);
|
||||
|
||||
// Report the result back to the Task we returned earlier.
|
||||
CopyTaskResultFrom(tcs, testCaseTask);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.SetException(e);
|
||||
}
|
||||
});
|
||||
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return testCase.DisplayName; }
|
||||
}
|
||||
|
||||
public string SkipReason
|
||||
{
|
||||
get { return testCase.SkipReason; }
|
||||
}
|
||||
|
||||
public ISourceInformation SourceInformation
|
||||
{
|
||||
get { return testCase.SourceInformation; }
|
||||
set { testCase.SourceInformation = value; }
|
||||
}
|
||||
|
||||
public ITestMethod TestMethod
|
||||
{
|
||||
get { return testCase.TestMethod; }
|
||||
}
|
||||
|
||||
public object[] TestMethodArguments
|
||||
{
|
||||
get { return testCase.TestMethodArguments; }
|
||||
}
|
||||
|
||||
public Dictionary<string, List<string>> Traits
|
||||
{
|
||||
get { return testCase.Traits; }
|
||||
}
|
||||
|
||||
public string UniqueID
|
||||
{
|
||||
get { return testCase.UniqueID; }
|
||||
}
|
||||
|
||||
public void Deserialize(IXunitSerializationInfo info)
|
||||
{
|
||||
testCase = info.GetValue<IXunitTestCase>("InnerTestCase");
|
||||
}
|
||||
|
||||
public void Serialize(IXunitSerializationInfo info)
|
||||
{
|
||||
info.AddValue("InnerTestCase", testCase);
|
||||
}
|
||||
|
||||
private static void CopyTaskResultFrom<T>(TaskCompletionSource<T> tcs, Task<T> template)
|
||||
{
|
||||
if (tcs == null)
|
||||
throw new ArgumentNullException("tcs");
|
||||
if (template == null)
|
||||
throw new ArgumentNullException("template");
|
||||
if (!template.IsCompleted)
|
||||
throw new ArgumentException("Task must be completed first.", "template");
|
||||
|
||||
if (template.IsFaulted)
|
||||
tcs.SetException(template.Exception);
|
||||
else if (template.IsCanceled)
|
||||
tcs.SetCanceled();
|
||||
else
|
||||
tcs.SetResult(template.Result);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// Borrowed from: https://github.com/xunit/samples.xunit/blob/master/STAExamples/WpfTheoryAttribute.cs
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
[XunitTestCaseDiscoverer("Xunit.WpfTheoryDiscoverer", "GitHub.Authentication.Test")]
|
||||
public class WpfTheoryAttribute : TheoryAttribute { }
|
|
@ -0,0 +1,25 @@
|
|||
// Borrowed from: https://github.com/xunit/samples.xunit/blob/master/STAExamples/WpfTheoryDiscoverer.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
public class WpfTheoryDiscoverer : IXunitTestCaseDiscoverer
|
||||
{
|
||||
readonly TheoryDiscoverer theoryDiscoverer;
|
||||
|
||||
public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink)
|
||||
{
|
||||
theoryDiscoverer = new TheoryDiscoverer(diagnosticMessageSink);
|
||||
}
|
||||
|
||||
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
|
||||
{
|
||||
return theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute)
|
||||
.Select(testCase => new WpfTestCase(testCase));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Alm.Authentication.Test
|
||||
|
@ -7,193 +8,103 @@ namespace Microsoft.Alm.Authentication.Test
|
|||
{
|
||||
private const string Namespace = "test";
|
||||
|
||||
[Fact]
|
||||
public void UriToName_GitHubSimple()
|
||||
public static object[] CredentialData
|
||||
{
|
||||
const string Expected = Namespace + ":https://www.github.com";
|
||||
const string Original = "https://www.github.com";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_VstsSimple()
|
||||
{
|
||||
const string Expected = Namespace + ":https://account.visualstudio.com";
|
||||
const string Original = "https://account.visualstudio.com";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_HttpsWithPath()
|
||||
{
|
||||
const string Expected = Namespace + ":https://github.com/Microsoft/Git-Credential-Manager-for-Windows.git";
|
||||
const string Original = "https://github.com/Microsoft/Git-Credential-Manager-for-Windows.git";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_HttpsWithTrailingSlash()
|
||||
{
|
||||
const string Expected = Namespace + ":https://www.github.com";
|
||||
const string Original = "https://www.github.com";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_ComplexVsts()
|
||||
{
|
||||
const string Expected = Namespace + ":https://mytenant.visualstudio.com/MYTENANT/_git/App.MyApp";
|
||||
const string Original = "https://mytenant.visualstudio.com/MYTENANT/_git/App.MyApp";
|
||||
|
||||
var uri = new Uri(Original);
|
||||
var actual = Secret.UriToName(uri, Namespace);
|
||||
|
||||
Assert.Equal(Expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_Unc()
|
||||
{
|
||||
const string Expected = Namespace + ":file://unc/path";
|
||||
const string Original = @"\\unc\path";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_UncWithPrefix()
|
||||
{
|
||||
const string Expected = Namespace + ":file://unc/path";
|
||||
const string Original = @"file://unc/path";
|
||||
|
||||
UriToNameTest(Namespace, Original, Expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriToName_UncWithTrailingSlash()
|
||||
{
|
||||
const string Expected = Namespace + ":file://unc/path";
|
||||
const string Original = @"\\unc\path\";
|
||||
|
||||
var uri = new Uri(Original);
|
||||
var actual = Secret.UriToName(uri, Namespace);
|
||||
|
||||
Assert.Equal(Expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStoreUrl()
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStoreUrlWithParams()
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing?with=params", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStoreUnc()
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), @"\\unc\share\test", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStoreUsernameNullReject()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
get
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing", null, "null_usernames_are_illegal");
|
||||
});
|
||||
List<object[]> data = new List<object[]>()
|
||||
{
|
||||
new object[] { false, "http://dummy.url/for/testing", "username", "password", false },
|
||||
new object[] { false, "http://dummy.url/for/testing?with=params", "username", "password", false },
|
||||
new object[] { false, "file://unc/share/test", "username", "password", false },
|
||||
new object[] { false, "http://dummy.url/for/testing", null, "null_usernames_are_illegal", true },
|
||||
new object[] { false, "http://dummy.url/for/testing", "", "blank_usernames_are_legal", false },
|
||||
new object[] { false, "http://dummy.url/for/testing", "null_passwords_are_legal", null, false },
|
||||
new object[] { false, "http://dummy.url/for/testing", "blank_passwords_are_legal", "", false },
|
||||
new object[] { false, "http://dummy.url/for/testing", "username", "password", false },
|
||||
new object[] { false, "http://dummy.url:999/for/testing", "username", "password", false },
|
||||
|
||||
new object[] { true, "http://dummy.url/for/testing", "username", "password", false },
|
||||
new object[] { true, "http://dummy.url/for/testing?with=params", "username", "password", false },
|
||||
new object[] { true, "file://unc/share/test", "username", "password", false },
|
||||
new object[] { true, "http://dummy.url/for/testing", null, "null_usernames_are_illegal", true },
|
||||
new object[] { true, "http://dummy.url/for/testing", "", "blank_usernames_are_legal", false },
|
||||
new object[] { true, "http://dummy.url/for/testing", "null_passwords_are_legal", null, false },
|
||||
new object[] { true, "http://dummy.url/for/testing", "blank_passwords_are_legal", "", false },
|
||||
new object[] { true, "http://dummy.url/for/testing", "username", "password", false },
|
||||
new object[] { true, "http://dummy.url:999/for/testing", "username", "password", false },
|
||||
};
|
||||
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStoreUsernameBlank()
|
||||
public static object[] UriToNameData
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing", "", "blank_usernames_are_legal");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStorePasswordNull()
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing", "null_passwords_are_illegal", null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CredentialStorePassswordBlank()
|
||||
{
|
||||
ICredentialStoreTest(new SecretStore("test", null, null, Secret.UriToName), "http://dummy.url/for/testing", "blank_passwords_are_legal", "");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCacheUrl()
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache"), "http://dummy.url/for/testing", "username", "password");
|
||||
ICredentialStoreTest(new SecretCache("test-cache"), "http://dummy.url/for/testing", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCacheUrlWithParams()
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache", Secret.UriToName), "http://dummy.url/for/testing?with=params", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCacheUnc()
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache", Secret.UriToName), @"\\unc\share\test", "username", "password");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCacheUsernameNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
get
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache", Secret.UriToName), "http://dummy.url/for/testing", null, "null_usernames_are_illegal");
|
||||
});
|
||||
var data = new List<object[]>()
|
||||
{
|
||||
new object[] { "https://microsoft.visualstudio.com", null },
|
||||
new object[] { "https://www.github.com", null },
|
||||
new object[] { "https://bitbucket.org", null },
|
||||
new object[] { "https://github.com/Microsoft/Git-Credential-Manager-for-Windows.git", null },
|
||||
new object[] { "https://microsoft.visualstudio.com/", "https://microsoft.visualstudio.com" },
|
||||
new object[] { "https://mytenant.visualstudio.com/MYTENANT/_git/App.MyApp", null },
|
||||
new object[] { "file://unc/path", null },
|
||||
new object[] { "file://tfs01/vc/repos", null },
|
||||
new object[] { "http://vsts-tfs:8080/tfs", null },
|
||||
};
|
||||
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCacheUsernameBlankReject()
|
||||
[Theory]
|
||||
[MemberData(nameof(CredentialData))]
|
||||
public void Credential_WriteDelete(bool useCache, string url, string username, string password, bool throws)
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache", Secret.UriToName), "http://dummy.url/for/testing", "", "blank_usernames_are_illegal");
|
||||
Action action = () =>
|
||||
{
|
||||
var uri = new TargetUri(url);
|
||||
var writeCreds = new Credential(username, password);
|
||||
var credentialStore = useCache
|
||||
? new SecretCache("test", Secret.UriToName) as ICredentialStore
|
||||
: new SecretStore("test", null, null, Secret.UriToName) as ICredentialStore;
|
||||
Credential readCreds = null;
|
||||
|
||||
credentialStore.WriteCredentials(uri, writeCreds);
|
||||
|
||||
readCreds = credentialStore.ReadCredentials(uri);
|
||||
Assert.NotNull(readCreds);
|
||||
Assert.Equal(writeCreds.Password, readCreds.Password);
|
||||
Assert.Equal(writeCreds.Username, readCreds.Username);
|
||||
|
||||
credentialStore.DeleteCredentials(uri);
|
||||
|
||||
Assert.Null(readCreds = credentialStore.ReadCredentials(uri));
|
||||
};
|
||||
|
||||
if (throws)
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecretCachePasswordNull()
|
||||
{
|
||||
ICredentialStoreTest(new SecretCache("test-cache", Secret.UriToName), "http://dummy.url/for/testing", "null_passwords_are_illegal", null);
|
||||
}
|
||||
|
||||
private static void ICredentialStoreTest(ICredentialStore credentialStore, string url, string username, string password)
|
||||
{
|
||||
TargetUri uri = new TargetUri(url);
|
||||
Credential writeCreds = new Credential(username, password);
|
||||
Credential readCreds = null;
|
||||
|
||||
credentialStore.WriteCredentials(uri, writeCreds);
|
||||
|
||||
readCreds = credentialStore.ReadCredentials(uri);
|
||||
Assert.NotNull(readCreds);
|
||||
Assert.Equal(writeCreds.Password, readCreds.Password);
|
||||
Assert.Equal(writeCreds.Username, readCreds.Username);
|
||||
|
||||
credentialStore.DeleteCredentials(uri);
|
||||
|
||||
Assert.Null(readCreds = credentialStore.ReadCredentials(uri));
|
||||
}
|
||||
|
||||
private static void UriToNameTest(string @namespace, string original, string expected)
|
||||
[Theory]
|
||||
[MemberData(nameof(UriToNameData))]
|
||||
public void UriToName(string original, string expected)
|
||||
{
|
||||
var uri = new Uri(original);
|
||||
var actual = Secret.UriToName(uri, @namespace);
|
||||
var actual = Secret.UriToName(uri, Namespace);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
expected = $"{Namespace}:{expected ?? original}";
|
||||
|
||||
Assert.Equal(expected, actual, StringComparer.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -57,7 +57,6 @@
|
|||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
|
@ -85,11 +84,12 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="xunit.runner.json">
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
@ -97,8 +97,8 @@
|
|||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Alm.Authentication.Test
|
||||
{
|
||||
|
@ -6,47 +7,38 @@ namespace Microsoft.Alm.Authentication.Test
|
|||
{
|
||||
private const string TokenString = "The Azure AD Authentication Library (ADAL) for .NET enables client application developers to easily authenticate users to cloud or on-premises Active Directory (AD), and then obtain access tokens for securing API calls. ADAL for .NET has many features that make authentication easier for developers, such as asynchronous support, a configurable token cache that stores access tokens and refresh tokens, automatic token refresh when an access token expires and a refresh token is available, and more. By handling most of the complexity, ADAL can help a developer focus on business logic in their application and easily secure resources without being an expert on security.";
|
||||
|
||||
[Fact]
|
||||
public void TokenStoreUrl()
|
||||
public static object[] TokenStoreData
|
||||
{
|
||||
ITokenStoreTest(new SecretStore("test-token"), "http://dummy.url/for/testing", TokenString);
|
||||
get
|
||||
{
|
||||
var data = new List<object[]>()
|
||||
{
|
||||
new object[] { true, "test-token", "http://dummy.url/for/testing", TokenString },
|
||||
new object[] { true, "test-token", "http://dummy.url/for/testing?with=params", TokenString },
|
||||
new object[] { true, "test-token", @"\\unc\share\test", TokenString },
|
||||
new object[] { true, "test-token", "file://dummy.url/for/testing", TokenString },
|
||||
new object[] { true, "test-token", "http://dummy.url:9090/for/testing", TokenString },
|
||||
new object[] { false, "test-token", "http://dummy.url/for/testing", TokenString },
|
||||
new object[] { false, "test-token", "http://dummy.url/for/testing?with=params", TokenString },
|
||||
new object[] { false, "test-token", @"\\unc\share\test", TokenString },
|
||||
new object[] { false, "test-token", "file://dummy.url/for/testing", TokenString },
|
||||
new object[] { false, "test-token", "http://dummy.url:9090/for/testing", TokenString },
|
||||
};
|
||||
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TokenStoreUrlWithParams()
|
||||
[Theory]
|
||||
[MemberData(nameof(TokenStoreData))]
|
||||
public void Token_WriteDelete(bool useCache, string secretName, string url, string token)
|
||||
{
|
||||
ITokenStoreTest(new SecretStore("test-token"), "http://dummy.url/for/testing?with=params", TokenString);
|
||||
}
|
||||
var tokenStore = useCache
|
||||
? new SecretCache(secretName) as ITokenStore
|
||||
: new SecretStore(secretName) as ITokenStore;
|
||||
var uri = new TargetUri(url);
|
||||
|
||||
[Fact]
|
||||
public void TokenStoreUnc()
|
||||
{
|
||||
ITokenStoreTest(new SecretStore("test-token"), @"\\unc\share\test", TokenString);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TokenCacheUrl()
|
||||
{
|
||||
ITokenStoreTest(new SecretCache("test-token"), "http://dummy.url/for/testing", TokenString);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TokenCacheUrlWithParams()
|
||||
{
|
||||
ITokenStoreTest(new SecretCache("test-token"), "http://dummy.url/for/testing?with=params", TokenString);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TokenCacheUnc()
|
||||
{
|
||||
ITokenStoreTest(new SecretCache("test-token"), @"\\unc\share\test", TokenString);
|
||||
}
|
||||
|
||||
private static void ITokenStoreTest(ITokenStore tokenStore, string url, string token)
|
||||
{
|
||||
TargetUri uri = new TargetUri(url);
|
||||
|
||||
Token writeToken = new Token(token, TokenType.Test);
|
||||
var writeToken = new Token(token, TokenType.Test);
|
||||
Token readToken = null;
|
||||
|
||||
tokenStore.WriteToken(uri, writeToken);
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<package id="Castle.Core" version="4.1.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="Moq" version="4.7.63" targetFramework="net452" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"appDomain": "denied",
|
||||
"diagnosticMessages": true,
|
||||
"methodDisplay": "method",
|
||||
"parallelizeAssembly": true
|
||||
}
|
|
@ -5,21 +5,17 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.Alm.Git.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to test <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
public class ConfigurationTests
|
||||
{
|
||||
|
||||
public static object[] ParseData
|
||||
{
|
||||
get
|
||||
{
|
||||
var data = new List<object[]>()
|
||||
{
|
||||
new object[] { "\n[core]\n autocrlf = false\n", "core.autocrlf", "false", StringComparer.OrdinalIgnoreCase },
|
||||
new object[] { "\n[core]\n autocrlf = true\n autocrlf = ThisShouldBeInvalidButIgnored\n autocrlf = false\n", "core.autocrlf", "false", StringComparer.OrdinalIgnoreCase },
|
||||
new object[] { "\n[core \"oneQuote]\n autocrlf = \"false\n", "core.oneQuote.autocrlf", "false", StringComparer.OrdinalIgnoreCase },
|
||||
new object[] { "\n[core]\n autocrlf = false\n", "core.autocrlf", "false", true },
|
||||
new object[] { "\n[core]\n autocrlf = true\n autocrlf = ThisShouldBeInvalidButIgnored\n autocrlf = false\n", "core.autocrlf", "false", true },
|
||||
new object[] { "\n[core \"oneQuote]\n autocrlf = \"false\n", "core.oneQuote.autocrlf", "false", true },
|
||||
};
|
||||
|
||||
return data.ToArray();
|
||||
|
@ -28,12 +24,12 @@ namespace Microsoft.Alm.Git.Test
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(ParseData))]
|
||||
public void GitConfif_Parse(string input, string expectedName, string expected, StringComparer comparer)
|
||||
public void GitConfif_Parse(string input, string expectedName, string expected, bool ignoreCase)
|
||||
{
|
||||
var values = TestParseGitConfig(input);
|
||||
Assert.NotNull(values);
|
||||
|
||||
Assert.Equal(expected, values[expectedName], comparer);
|
||||
Assert.Equal(expected, values[expectedName], ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -55,19 +55,15 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -87,10 +83,11 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="xunit.runner.json">
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
@ -98,8 +95,8 @@
|
|||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="xunit.longRunningTestSeconds" value="2.0"/>
|
||||
<add key="xunit.maxParallelThreads" value="0"/>
|
||||
<add key="xunit.methodDisplay" value="method"/>
|
||||
<add key="xunit.parallelizeAssembly" value="false"/>
|
||||
<add key="xunit.parallelizeTestCollections" value="true"/>
|
||||
<add key="xunit.preEnumerateTheories" value="true"/>
|
||||
</appSettings>
|
||||
</configuration>
|
|
@ -3,11 +3,11 @@
|
|||
<package id="Castle.Core" version="4.1.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="Moq" version="4.7.63" targetFramework="net452" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"appDomain": "denied",
|
||||
"diagnosticMessages": true,
|
||||
"methodDisplay": "method",
|
||||
"parallelizeAssembly": true,
|
||||
"preEnumerateTheories": true
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -49,7 +49,6 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
|
@ -84,6 +83,10 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\xunit.runner.json">
|
||||
<Link>xunit.runner.json</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
|
@ -92,8 +95,8 @@
|
|||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<package id="Castle.Core" version="4.1.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="Moq" version="4.7.63" targetFramework="net452" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net451" developmentDependency="true" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
|
||||
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
|
||||
</packages>
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"appDomain": "ifAvailable",
|
||||
"diagnosticMessages": false,
|
||||
"methodDisplay": "method",
|
||||
"parallelizeAssembly": true,
|
||||
"parallelizeTestCollections": true,
|
||||
"preEnumerateTheories": true,
|
||||
"shadowCopy": false
|
||||
}
|
Загрузка…
Ссылка в новой задаче