Skip to content

Commit

Permalink
Merge pull request #271 from zumicts/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
haroldma-zz committed Sep 8, 2015
2 parents 3f7e258 + 2668af5 commit 8cedb2c
Show file tree
Hide file tree
Showing 40 changed files with 777 additions and 411 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ arm.txt
[Rr]elease_*/
[Dd]ebug_*/
project.lock.json
BundleArtifacts/
Windows/Audiotica.Windows/_pkginfo.txt
Windows/Audiotica.Windows/_scale-400.appx
Windows/Audiotica.Windows/_scale-100.appx
6 changes: 3 additions & 3 deletions Audiotica.Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class StringExtensions
{
public static string ToSha1(this string text) => SHA.ComputeSHA1(text.ToBytes()).ToHex();

public static string ToHex(this byte[] bytes) => BitConverter.ToString(bytes).Replace("-", "");
public static string ToHex(this byte[] bytes) => BitConverter.ToString(bytes).Replace("-", "").ToLower();
public static string ToBase64(this byte[] bytes) => Convert.ToBase64String(bytes);
public static string ToBase64(this string text) => Convert.ToBase64String(text.ToBytes());
public static byte[] ToBytes(this string text) => Encoding.UTF8.GetBytes(text);
Expand Down Expand Up @@ -159,7 +159,7 @@ public static string ToUnaccentedText(this string accentedString)
return string.IsNullOrEmpty(accentedString) ? accentedString : DiacritisHelper.Remove(accentedString);
}

public static string ToSanitizedFileName(this string str, string invalidMessage)
public static string ToSanitizedFileName(this string str, string invalidMessage = null)
{
if (string.IsNullOrEmpty(str))
{
Expand Down Expand Up @@ -188,7 +188,7 @@ public static string ToSanitizedFileName(this string str, string invalidMessage)
.Replace(">", string.Empty)
.Replace("|", " ");

return string.IsNullOrEmpty(name) ? invalidMessage : name;
return string.IsNullOrEmpty(name) ? invalidMessage ?? "Invalid" : name;
}

public static string ToValidFileNameEnding(this string str)
Expand Down
2 changes: 1 addition & 1 deletion Audiotica.Web/Audiotica.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<Compile Include="Extensions\RestlessExtensions.cs" />
<Compile Include="Extensions\RestRequestExtensions.cs" />
<Compile Include="Extensions\UriExtensions.cs" />
<Compile Include="Extensions\WebSongExtensions.cs" />
<Compile Include="Extensions\MatchSongExtensions.cs" />
<Compile Include="Http\Requets\MatchEngine\Meile\MeileDetailsRequest.cs" />
<Compile Include="Http\Requets\MatchEngine\Meile\MeileSearchRequest.cs" />
<Compile Include="Http\Requets\MatchEngine\Mp3Freex\Mp3FreexSearchRequest.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Audiotica.Web.Extensions
{
public static class WebSongExtensions
public static class MatchSongExtensions
{
/// <summary>
/// Sets the name and artist by extracting it from a title that uses the specified [seperator].
Expand Down
40 changes: 40 additions & 0 deletions Audiotica.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Audiotica.Windows.Player",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Audiotica.Converters", "Audiotica.Converters\Audiotica.Converters.csproj", "{1F2A3DCD-0350-4468-9C9A-85EA6CF0509E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B9A3B453-F483-455D-9EF5-BCB1D4E3073B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Audiotica.Core.Test", "Tests\Audiotica.Core.Test\Audiotica.Core.Test.csproj", "{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Audiotica.Web.Test", "Tests\Audiotica.Web.Test\Audiotica.Web.Test.csproj", "{933A0B43-A631-4381-B86E-2E754E89C803}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -147,6 +153,38 @@ Global
{1F2A3DCD-0350-4468-9C9A-85EA6CF0509E}.Release|x64.Build.0 = Release|Any CPU
{1F2A3DCD-0350-4468-9C9A-85EA6CF0509E}.Release|x86.ActiveCfg = Release|Any CPU
{1F2A3DCD-0350-4468-9C9A-85EA6CF0509E}.Release|x86.Build.0 = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|ARM.ActiveCfg = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|ARM.Build.0 = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|x64.ActiveCfg = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|x64.Build.0 = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|x86.ActiveCfg = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Debug|x86.Build.0 = Debug|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|Any CPU.Build.0 = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|ARM.ActiveCfg = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|ARM.Build.0 = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|x64.ActiveCfg = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|x64.Build.0 = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|x86.ActiveCfg = Release|Any CPU
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}.Release|x86.Build.0 = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|Any CPU.Build.0 = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|ARM.ActiveCfg = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|ARM.Build.0 = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|x64.ActiveCfg = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|x64.Build.0 = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|x86.ActiveCfg = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Debug|x86.Build.0 = Debug|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|Any CPU.ActiveCfg = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|Any CPU.Build.0 = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|ARM.ActiveCfg = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|ARM.Build.0 = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|x64.ActiveCfg = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|x64.Build.0 = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|x86.ActiveCfg = Release|Any CPU
{933A0B43-A631-4381-B86E-2E754E89C803}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -155,5 +193,7 @@ Global
{FEFD3052-DC9D-49F3-B018-5342B4F2FF09} = {EAE11927-100E-47E4-8B82-77B828AF4C74}
{5A3452A6-CF57-43D5-A0D9-26192741FAB1} = {EAE11927-100E-47E4-8B82-77B828AF4C74}
{51F65CD8-3F91-41F5-A18F-AE17FB2F0B69} = {EAE11927-100E-47E4-8B82-77B828AF4C74}
{DD0090D5-AFBD-4D97-842D-C57EF5C168BE} = {B9A3B453-F483-455D-9EF5-BCB1D4E3073B}
{933A0B43-A631-4381-B86E-2E754E89C803} = {B9A3B453-F483-455D-9EF5-BCB1D4E3073B}
EndGlobalSection
EndGlobal
65 changes: 65 additions & 0 deletions Tests/Audiotica.Core.Test/Audiotica.Core.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DD0090D5-AFBD-4D97-842D-C57EF5C168BE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Audiotica.Core.Test</RootNamespace>
<AssemblyName>Audiotica.Core.Test</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\..\Audiotica.Core\Audiotica.Core.csproj">
<Project>{3b0d02a1-a45f-4925-93f0-cb4451317c80}</Project>
<Name>Audiotica.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="ShaTest.cs" />
<Compile Include="StringExtensionsTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
30 changes: 30 additions & 0 deletions Tests/Audiotica.Core.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Audiotica.Core.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Audiotica.Core.Test")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
28 changes: 28 additions & 0 deletions Tests/Audiotica.Core.Test/ShaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Audiotica.Core.Common;
using Audiotica.Core.Extensions;
using NUnit.Framework;

namespace Audiotica.Core.Test
{
[TestFixture]
public class ShaTest
{
[Test]
public void Sha1()
{
const string input = "sha1 input test";
const string expected = "135277461872e58c8baa93f25943752bd5e5b85d";
var actual = SHA.ComputeSHA1(input.ToBytes()).ToHex();
Assert.AreEqual(expected, actual);
}

[Test]
public void Sha256()
{
const string input = "sha256 input test";
const string expected = "d7ecf2c1caa1c5120a2d90ec7411ba6d26cb83f02fafadcef90bcad201d5b37e";
var actual = SHA.ComputeSHA256(input.ToBytes()).ToHex();
Assert.AreEqual(expected, actual);
}
}
}
54 changes: 54 additions & 0 deletions Tests/Audiotica.Core.Test/StringExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Audiotica.Core.Extensions;
using NUnit.Framework;

namespace Audiotica.Core.Test
{
[TestFixture]
public class StringExtensionsTest
{
[Test]
public void ToAudioticaSlug()
{
const string input = "Skrillex and Diplo - Where Are Ü Now (with Justin Bieber)";
const string expected = "skrillex diplo where are u now with justin bieber";
var actual = input.ToAudioticaSlug();
Assert.AreEqual(expected, actual);
}

[Test]
public void ToHtmlStrippedText()
{
const string input = "<a href='test'>Hello</a>";
const string expected = "Hello";
var actual = input.ToHtmlStrippedText();
Assert.AreEqual(expected, actual);
}

[Test]
public void ToSanitizedFileName()
{
const string input = "File* Name?";
const string expected = "File Name";
var actual = input.ToSanitizedFileName();
Assert.AreEqual(expected, actual);
}

[Test]
public void ToUnaccentedText()
{
const string input = "Jason Derülo";
const string expected = "Jason Derulo";
var actual = input.ToUnaccentedText();
Assert.AreEqual(expected, actual);
}

[Test]
public void ToValidFileNameEnding()
{
const string input = "File Name:;";
const string expected = "File Name";
var actual = input.ToValidFileNameEnding();
Assert.AreEqual(expected, actual);
}
}
}
4 changes: 4 additions & 0 deletions Tests/Audiotica.Core.Test/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="portable45-net45+win8+wp8+wpa81" />
</packages>
63 changes: 63 additions & 0 deletions Tests/Audiotica.Web.Test/Audiotica.Web.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{933A0B43-A631-4381-B86E-2E754E89C803}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Audiotica.Web.Test</RootNamespace>
<AssemblyName>Audiotica.Web.Test</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="MatchSongExtensionsTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Audiotica.Web\Audiotica.Web.csproj">
<Project>{0b8c5a00-8c9c-4663-a741-1b494c0e9e46}</Project>
<Name>Audiotica.Web</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
19 changes: 19 additions & 0 deletions Tests/Audiotica.Web.Test/MatchSongExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Audiotica.Web.Extensions;
using Audiotica.Web.Models;
using NUnit.Framework;

namespace Audiotica.Web.Test
{
[TestFixture]
public class MatchSongExtensionsTest
{
[Test]
public void SetNameAndArtistFromTitle()
{
var match = new MatchSong();
match.SetNameAndArtistFromTitle("Childish Gambino - 3005", true);
Assert.AreEqual(match.Title, "3005");
Assert.AreEqual(match.Artist, "Childish Gambino");
}
}
}
Loading

0 comments on commit 8cedb2c

Please sign in to comment.