Rearrangements
Migrate to Sdk projects. Migrate tests to xUnit. Bump version 1.2.0. Migrate to NetStandar2.0.
This commit is contained in:
328
VAR.UrlCompressor.Tests/UrlCompressorTests.cs
Normal file
328
VAR.UrlCompressor.Tests/UrlCompressorTests.cs
Normal file
@@ -0,0 +1,328 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace VAR.UrlCompressor.Tests
|
||||
{
|
||||
public class UrlCompressorTests
|
||||
{
|
||||
#region Helpers
|
||||
|
||||
private Dictionary<string, string> GenerateHostsConversions()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = new Dictionary<string, string> {
|
||||
{ "com", "C" },
|
||||
{ "net", "N" },
|
||||
{ "org", "O" },
|
||||
{ "localhost", "L" },
|
||||
{ "azurewebsites", "A" },
|
||||
{ "unifikas", "U" },
|
||||
{ "cyc", "Y" },
|
||||
{ "es", "E" },
|
||||
{ "google", "G" },
|
||||
{ "facebook", "F" },
|
||||
{ "twitter", "T" },
|
||||
{ "github", "GH" },
|
||||
{ "varstudio", "V" },
|
||||
};
|
||||
return hostConversions;
|
||||
}
|
||||
|
||||
#endregion Helpers
|
||||
|
||||
#region Compress
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://google.com";
|
||||
string compressedUrl = "zBUW9UxS1";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://google.com";
|
||||
string compressedUrl = "oMyuFVR41";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://facebook.com";
|
||||
string compressedUrl = "EAyWnGuy0";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://facebook.com";
|
||||
string compressedUrl = "2AyutHOa0";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Twitter_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com";
|
||||
string compressedUrl = "bpzuhuDB1";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Twitter_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com/Kableado";
|
||||
string compressedUrl = "zYfD7gXd8ApW9HZtR4";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Github_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://github.com/Kableado";
|
||||
string compressedUrl = "JzJv5CTnllbrEVp1BhF";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Localhost_30000_0()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Localhost_30000_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Unifikas_Azurewebsites_Net_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|1";
|
||||
string compressedUrl = "7R15qGtuLPGD";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Unifikas_Azurewebsites_Net_2()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|2";
|
||||
string compressedUrl = "7B54q0pvLPKC";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Varstudio_Net()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://varstudio.net";
|
||||
string compressedUrl = "5B1u05oK";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
#endregion Compress
|
||||
|
||||
#region Decompress
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://google.com";
|
||||
string compressedUrl = "zBUW9UxS1";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://google.com";
|
||||
string compressedUrl = "oMyuFVR41";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://facebook.com";
|
||||
string compressedUrl = "EAyWnGuy0";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://facebook.com";
|
||||
string compressedUrl = "2AyutHOa0";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Twitter_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com";
|
||||
string compressedUrl = "bpzuhuDB1";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Twitter_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com/Kableado";
|
||||
string compressedUrl = "zYfD7gXd8ApW9HZtR4";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Github_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://github.com/Kableado";
|
||||
string compressedUrl = "JzJv5CTnllbrEVp1BhF";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Localhost_30000_0()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Localhost_30000_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Unifikas_Azurewebsites_Net_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|1";
|
||||
string compressedUrl = "7R15qGtuLPGD";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Unifikas_Azurewebsites_Net_2()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|2";
|
||||
string compressedUrl = "7B54q0pvLPKC";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Varstudio_Net()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://varstudio.net";
|
||||
string compressedUrl = "5B1u05oK";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
#endregion Decompress
|
||||
}
|
||||
}
|
||||
26
VAR.UrlCompressor.Tests/VAR.UrlCompressor.Tests.csproj
Normal file
26
VAR.UrlCompressor.Tests/VAR.UrlCompressor.Tests.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VAR.UrlCompressor\VAR.UrlCompressor.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user