1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2024-09-16 05:30:09 +00:00

Merge pull request #2 from glucaci/testing

Test project
This commit is contained in:
Gabriel Lucaci 2016-12-13 10:56:54 +01:00 committed by GitHub
commit d3452b9844
27 changed files with 364 additions and 1 deletions

7
.gitignore vendored
View File

@ -14,4 +14,9 @@
/LibMpcApp/LibMpcApp.xproj.user
/LibMpcApp/project.lock.json
/LibMpc.sln.DotSettings.user
/LibMpcTest/bin
/LibMpcTest/obj
/LibMpcTest/LibMpcTest.xproj.user
/LibMpcTest/project.lock.json
/LibMpc.sln.DotSettings.user

View File

@ -7,6 +7,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LibMpc", "LibMpc\LibMpc.xpr
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LibMpcApp", "LibMpcApp\LibMpcApp.xproj", "{FF176AD5-D6DA-41EE-B27D-1DBEF0CE462F}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LibMpcTest", "LibMpcTest\LibMpcTest.xproj", "{69F1D68F-9CD5-4EA6-9B47-2A7A9BF8CED9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{FF176AD5-D6DA-41EE-B27D-1DBEF0CE462F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF176AD5-D6DA-41EE-B27D-1DBEF0CE462F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF176AD5-D6DA-41EE-B27D-1DBEF0CE462F}.Release|Any CPU.Build.0 = Release|Any CPU
{69F1D68F-9CD5-4EA6-9B47-2A7A9BF8CED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69F1D68F-9CD5-4EA6-9B47-2A7A9BF8CED9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69F1D68F-9CD5-4EA6-9B47-2A7A9BF8CED9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69F1D68F-9CD5-4EA6-9B47-2A7A9BF8CED9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

38
LibMpcTest/LibMpcTest.cs Normal file
View File

@ -0,0 +1,38 @@
using LibMpc;
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace LibMpcTest
{
public class LibMpcTest : IClassFixture<MpdServerTest>, IDisposable
{
private readonly ITestOutputHelper _output;
private readonly Mpc _mpc;
public LibMpcTest(ITestOutputHelper output)
{
_output = output;
_mpc = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
var connected = _mpc.ConnectAsync().GetAwaiter().GetResult();
if (connected)
{
_output.WriteLine("Connected to MPD.");
}
else
{
_output.WriteLine("Could not connect to MPD.");
}
}
public void Dispose()
{
_mpc?.DisconnectAsync().GetAwaiter().GetResult();
}
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>69f1d68f-9cd5-4ea6-9b47-2a7a9bf8ced9</ProjectGuid>
<RootNamespace>LibMpcTest</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

40
LibMpcTest/MpdConf.cs Normal file
View File

@ -0,0 +1,40 @@
using System.IO;
using System.Text;
namespace LibMpcTest
{
public class MpdConf
{
private const string MPD_CONF_FILE = "mpd.conf";
private const string MPD_LOG_FILE = "mpd_log.txt";
private const string MPD_DB_FILE = "mpd.db";
public static void Create(string rootDirectory)
{
File.Create(Path.Combine(rootDirectory, MPD_LOG_FILE)).Dispose();
CreateConfFile(rootDirectory);
}
private static void CreateConfFile(string rootDirectory)
{
var builder = new StringBuilder();
builder.AppendLine($"log_file \"{Path.Combine(rootDirectory, MPD_LOG_FILE).Replace("\\", "\\\\")}\"");
builder.AppendLine($"db_file \"{Path.Combine(rootDirectory, MPD_DB_FILE).Replace("\\", "\\\\")}\"");
builder.AppendLine($"bind_to_address \"any\"");
builder.AppendLine($"music_directory \"{Path.Combine(rootDirectory, "Music").Replace("\\", "\\\\")}\"");
builder.AppendLine($"playlist_directory \"{Path.Combine(rootDirectory, "Playlists").Replace("\\", "\\\\")}\"");
builder.AppendLine($"port \"6600\"");
builder.AppendLine($"mixer_type \"software\"");
var mpdConfContent = builder.ToString();
using (var file = File.CreateText(Path.Combine(rootDirectory, MPD_CONF_FILE)))
{
file.Write(mpdConfContent);
file.Flush();
}
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Diagnostics;
using System.IO;
namespace LibMpcTest
{
internal class MpdServerTest : IDisposable
{
private Process _process;
public MpdServerTest()
{
var serverPath = Path.Combine(AppContext.BaseDirectory, "Server");
MpdConf.Create(serverPath);
var mpdExePath = Path.Combine(serverPath, "mpd.exe");
var mpdConfPath = Path.Combine(serverPath, "mpd.conf");
_process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = mpdExePath,
WorkingDirectory = serverPath,
Arguments = string.Join(" ", mpdConfPath, "-v"),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
}
};
_process.Start();
var logOutput = _process.StandardOutput.ReadToEnd();
var logError = _process.StandardError.ReadToEnd();
}
public void Dispose()
{
_process?.Kill();
_process?.Dispose();
_process = null;
}
}
}

View File

@ -0,0 +1,19 @@
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: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LibMpcTest")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("69f1d68f-9cd5-4ea6-9b47-2a7a9bf8ced9")]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

155
LibMpcTest/Server/mpd.db Normal file
View File

@ -0,0 +1,155 @@
info_begin
format: 1
mpd_version: 0.17.4
fs_charset: cp1252
tag: Artist
tag: ArtistSort
tag: Album
tag: AlbumArtist
tag: AlbumArtistSort
tag: Title
tag: Track
tag: Name
tag: Genre
tag: Date
tag: Composer
tag: Performer
tag: Disc
tag: MUSICBRAINZ_ARTISTID
tag: MUSICBRAINZ_ALBUMID
tag: MUSICBRAINZ_ALBUMARTISTID
tag: MUSICBRAINZ_TRACKID
info_end
directory: A long name directory with some spaces
mtime: 1481622608
begin: A long name directory with some spaces
song_begin: pouring-water-into-mug-of-coffee.mp3
Time: 4
Artist: Geek & Dummy
Title: Sound effect: pouring water into mug of coffee
Date: 2013
Date: 2013
mtime: 1481622059
song_end
song_begin: short-trouser-pants-zip-closing.mp3
Time: 1
Artist: Geek & Dummy
Title: Sound effect: short trouser pants zip closing
Date: 2013
Date: 2013
mtime: 1481622066
song_end
song_begin: Ghost-Sounds.mp3
Time: 95
Artist: Geek & Dummy
Title: Sound effect: ghostly haunted house (bells, ghostly laughs & knives sharpened)
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622054
song_end
song_begin: starting-engine-Ford-Mondeo-Mk-3-diesel.mp3
Time: 6
Artist: Geek & Dummy
Title: Sound effect: starting engine - Ford Mondeo Mk 3 diesel
Album: Geek & Dummy Sound Library
Date: 2014
Genre: soundfx
mtime: 1481622063
song_end
end: A long name directory with some spaces
directory: Directory
mtime: 1481622608
begin: Directory
song_begin: 2-Kids-Laughing.mp3
Time: 30
Artist: Geek & Dummy
Title: Sound effect: two kids laughing
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622083
song_end
song_begin: ambient-noise-server-room.mp3
Time: 71
Artist: Geek & Dummy
Title: Sound effect: ambient noise - server room
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622020
song_end
end: Directory
directory: Directory With Spaces
mtime: 1481622608
begin: Directory With Spaces
song_begin: coin-spin-light.mp3
Time: 5
Artist: Geek & Dummy
Title: Sound effect: coin spin (light coin)
Date: 2013
Date: 2013
mtime: 1481622036
song_end
song_begin: central-locking-Ford-Mondeo-Mk-3.mp3
Time: 5
Artist: Geek & Dummy
Title: Sound effect: central locking - Ford Mondeo Mk 3
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622024
song_end
song_begin: finger-snap-click.mp3
Time: 0
Artist: Geek & Dummy
Title: Sound effect: finger snap/click
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622047
song_end
end: Directory With Spaces
directory: _My Directory
mtime: 1481622608
begin: _My Directory
song_begin: gas-fire-lighting.mp3
Time: 58
Artist: Geek & Dummy
Title: Sound effect: gas fire lighting and warming up
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481622051
song_end
end: _My Directory
song_begin: teaspoon-stirring-mug-of-coffee.mp3
Time: 4
Artist: Geek & Dummy
Title: Sound effect: teaspoon stirring mug of coffee
Date: 2013
Date: 2013
mtime: 1481622029
song_end
song_begin: whistle-kettle-boiling.mp3
Time: 36
Artist: Geek & Dummy
Title: Sound effect: whistle kettle boiling
Date: 2013
Date: 2013
mtime: 1481622087
song_end
song_begin: wine-glass-double-chink-clink-cheers.mp3
Time: 1
Artist: Geek & Dummy
Title: Sound effect: wine glass double chink/clink/cheers
Date: 2013
Date: 2013
mtime: 1481622090
song_end

BIN
LibMpcTest/Server/mpd.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

32
LibMpcTest/project.json Normal file
View File

@ -0,0 +1,32 @@
{
"buildOptions":
{
"copyToOutput": "Server\\"
},
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies":
{
"xunit": "2.2.0-beta2-build3300",
"LibMpc": "1.0.0-*",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"frameworks":
{
"netcoreapp1.0":
{
"dependencies":
{
"Microsoft.NETCore.App":
{
"type": "platform",
"version": "1.0.0"
}
}
}
}
}