mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
Reworked some tests
This commit is contained in:
parent
fadf401308
commit
a1ae37eae4
5 changed files with 86 additions and 79 deletions
|
@ -24,7 +24,6 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
using System.Diagnostics;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@ -41,7 +40,7 @@ namespace PlexRequests.Helpers.Tests
|
|||
var hash = PasswordHasher.ComputeHash(password, salt);
|
||||
|
||||
Assert.That(hash, Is.Not.EqualTo(password));
|
||||
|
||||
|
||||
var match = PasswordHasher.VerifyPassword(password, salt, hash);
|
||||
|
||||
Assert.That(match, Is.True);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PlexRequests.Helpers.Tests</RootNamespace>
|
||||
<AssemblyName>PlexRequests.Helpers.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
@ -16,6 +16,7 @@
|
|||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace PlexRequests.Helpers.Tests
|
||||
|
@ -35,11 +36,9 @@ namespace PlexRequests.Helpers.Tests
|
|||
public class UriHelperTests
|
||||
{
|
||||
[TestCaseSource(nameof(UriData))]
|
||||
public void CreateUri1(string uri, Uri expected)
|
||||
public Uri CreateUri1(string uri)
|
||||
{
|
||||
var result = uri.ReturnUri();
|
||||
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
return uri.ReturnUri();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -52,54 +51,58 @@ namespace PlexRequests.Helpers.Tests
|
|||
}
|
||||
|
||||
[TestCaseSource(nameof(UriDataWithPort))]
|
||||
public void CreateUri2(string uri, int port, Uri expected)
|
||||
public Uri CreateUri2(string uri, int port)
|
||||
{
|
||||
var result = uri.ReturnUri(port);
|
||||
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
return uri.ReturnUri(port);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(UriDataWithSubDir))]
|
||||
public void CreateUriWithSubDir(string uri, int port, bool ssl, string subDir, Uri expected)
|
||||
public Uri CreateUriWithSubDir(string uri, int port, bool ssl, string subDir)
|
||||
{
|
||||
var result = uri.ReturnUriWithSubDir(port, ssl, subDir);
|
||||
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
return uri.ReturnUriWithSubDir(port, ssl, subDir);
|
||||
}
|
||||
|
||||
static readonly object[] UriData =
|
||||
private static IEnumerable<TestCaseData> UriData
|
||||
{
|
||||
new object[] { "google.com", new Uri("http://google.com/"), },
|
||||
new object[] { "http://google.com", new Uri("http://google.com/"), },
|
||||
new object[] { "https://google.com", new Uri("https://google.com/"), },
|
||||
new object[] { "192.168.1.1", new Uri("http://192.168.1.1")},
|
||||
new object[] { "0.0.0.0:5533", new Uri("http://0.0.0.0:5533")},
|
||||
new object[] {"www.google.com", new Uri("http://www.google.com/")},
|
||||
new object[] {"http://www.google.com/", new Uri("http://www.google.com/") },
|
||||
new object[] {"https://www.google.com", new Uri("https://www.google.com/") },
|
||||
new object[] {"www.google.com:443", new Uri("http://www.google.com:443/") },
|
||||
new object[] {"https://www.google.com:443", new Uri("https://www.google.com:443/") },
|
||||
new object[] {"http://www.google.com:443/id=2", new Uri("http://www.google.com:443/id=2") },
|
||||
new object[] {"www.google.com:4438/id=22", new Uri("http://www.google.com:4438/id=22") }
|
||||
};
|
||||
get
|
||||
{
|
||||
yield return new TestCaseData("google.com").Returns(new Uri("http://google.com/"));
|
||||
yield return new TestCaseData("http://google.com").Returns(new Uri("http://google.com/"));
|
||||
yield return new TestCaseData("https://google.com").Returns(new Uri("https://google.com/"));
|
||||
yield return new TestCaseData("192.168.1.1").Returns(new Uri("http://192.168.1.1"));
|
||||
yield return new TestCaseData("0.0.0.0:5533").Returns(new Uri("http://0.0.0.0:5533"));
|
||||
yield return new TestCaseData("www.google.com").Returns(new Uri("http://www.google.com/"));
|
||||
yield return new TestCaseData("http://www.google.com/").Returns(new Uri("http://www.google.com/"));
|
||||
yield return new TestCaseData("https://www.google.com").Returns(new Uri("https://www.google.com/"));
|
||||
yield return new TestCaseData("www.google.com:443").Returns(new Uri("http://www.google.com:443/"));
|
||||
yield return new TestCaseData("https://www.google.com:443").Returns(new Uri("https://www.google.com/"));
|
||||
yield return new TestCaseData("http://www.google.com:443/id=2").Returns(new Uri("http://www.google.com:443/id=2"));
|
||||
yield return new TestCaseData("www.google.com:4438/id=22").Returns(new Uri("http://www.google.com:4438/id=22"));
|
||||
}
|
||||
}
|
||||
|
||||
static readonly object[] UriDataWithPort =
|
||||
private static IEnumerable<TestCaseData> UriDataWithPort
|
||||
{
|
||||
new object[] {"www.google.com", 80, new Uri("http://www.google.com:80/"), },
|
||||
new object[] {"www.google.com", 443, new Uri("http://www.google.com:443/") },
|
||||
new object[] {"http://www.google.com", 443, new Uri("http://www.google.com:443/") },
|
||||
new object[] {"https://www.google.com", 443, new Uri("https://www.google.com:443/") },
|
||||
new object[] {"http://www.google.com/id=2", 443, new Uri("http://www.google.com:443/id=2") },
|
||||
new object[] {"http://www.google.com/id=2", 443, new Uri("http://www.google.com:443/id=2") },
|
||||
new object[] {"https://www.google.com/id=2", 443, new Uri("https://www.google.com:443/id=2") },
|
||||
};
|
||||
get
|
||||
{
|
||||
yield return new TestCaseData("www.google.com", 80).Returns(new Uri("http://www.google.com:80/"));
|
||||
yield return new TestCaseData("www.google.com", 443).Returns(new Uri("http://www.google.com:443/"));
|
||||
yield return new TestCaseData("http://www.google.com", 443).Returns(new Uri("http://www.google.com:443/"));
|
||||
yield return new TestCaseData("https://www.google.com", 443).Returns(new Uri("https://www.google.com:443/"));
|
||||
yield return new TestCaseData("http://www.google.com/id=2", 443).Returns(new Uri("http://www.google.com:443/id=2"));
|
||||
yield return new TestCaseData("https://www.google.com/id=2", 443).Returns(new Uri("https://www.google.com:443/id=2"));
|
||||
}
|
||||
}
|
||||
|
||||
static readonly object[] UriDataWithSubDir =
|
||||
{
|
||||
new object[] {"www.google.com", 80, false,"test", new Uri("http://www.google.com:80/test"), },
|
||||
new object[] {"www.google.com", 443, false,"test", new Uri("http://www.google.com:443/test") },
|
||||
new object[] {"http://www.google.com", 443, true,"test", new Uri("https://www.google.com:443/test") },
|
||||
new object[] {"https://www.google.com", 443,true,"test", new Uri("https://www.google.com:443/test") },
|
||||
};
|
||||
private static IEnumerable<TestCaseData> UriDataWithSubDir
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new TestCaseData("www.google.com", 80, false, "test").Returns(new Uri("http://www.google.com:80/test"));
|
||||
yield return new TestCaseData("www.google.com", 443, false, "test").Returns(new Uri("http://www.google.com:443/test"));
|
||||
yield return new TestCaseData("http://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test"));
|
||||
yield return new TestCaseData("https://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue