Commit 292a038f by Axelander

Initial project commit

parent dc3514c9
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# LightSwitch generated files
GeneratedArtifacts/
ModelManifest.xml
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Media;
using Windows.Media.Playback;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using SonicStreamer.Common.System;
using SonicStreamer.Subsonic.Data;
namespace SonicStreamer.Test.Common
{
[TestClass]
public class PlaybackServiceTest
{
[TestInitialize]
public async Task InitAsync()
{
await SubsonicConnector.Current.SetSubsonicTestServerAsync();
}
private async Task<List<Track>> GetSampleTracks()
{
return await SubsonicConnector.Current.CurrentConnection.GetAlbumTracksAsync("50");
}
[TestMethod]
public async Task AddToPlaybackTestAsync()
{
var tracks = await GetSampleTracks();
await PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
// Duplicate Check
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
// Replace Playback
tracks.RemoveAt(0);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
PlaybackService.Current.ResetPlayabck();
}
private string GetTrackIdOrder()
{
if (PlaybackService.Current.Playback.ShuffleEnabled)
{
return PlaybackService.Current.Playback.ShuffledItems.Aggregate(string.Empty, (current, item) =>
current + item.Source.CustomProperties[Constants.PlaybackTrackId].ToString());
}
return PlaybackService.Current.Playback.Items.Aggregate(string.Empty, (current, item) =>
current + item.Source.CustomProperties[Constants.PlaybackTrackId].ToString());
}
[TestMethod]
public async Task ShuffleModeTestAsync()
{
var tracks = await GetSampleTracks();
PlaybackService.Current.SetShuffleMode(false);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
var playbackItem = PlaybackService.Current.Playback.Items.First();
var displayProperties = playbackItem.GetDisplayProperties();
Assert.AreEqual(tracks.First().Id,
playbackItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString());
Assert.AreEqual(tracks.First().ArtistId,
playbackItem.Source.CustomProperties[Constants.PlaybackArtistId].ToString());
Assert.AreEqual(tracks.First().Cover,
playbackItem.Source.CustomProperties[Constants.PlaybackCover] as CoverArt);
Assert.AreEqual(tracks.First().Duration,
playbackItem.Source.CustomProperties[Constants.PlaybackDuration].ToString());
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
Assert.AreEqual(playbackItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString(),
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
());
Assert.AreEqual(MediaPlaybackType.Music, displayProperties.Type);
Assert.AreEqual(tracks.First().Name, displayProperties.MusicProperties.Title);
Assert.AreEqual(tracks.First().Artist, displayProperties.MusicProperties.Artist);
Assert.AreEqual(tracks.First().Album, displayProperties.MusicProperties.AlbumTitle);
var oldOrder = GetTrackIdOrder();
PlaybackService.Current.SetShuffleMode(true);
Assert.IsTrue(PlaybackService.Current.Playback.ShuffleEnabled);
var newOrder = GetTrackIdOrder();
Assert.AreNotEqual(oldOrder, newOrder);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreNotEqual(newOrder, GetTrackIdOrder());
PlaybackService.Current.ResetPlayabck();
}
[TestMethod]
public async Task PlayPauseTestAsync()
{
var tracks = await GetSampleTracks();
// Add only one track to trigger Play mode
await PlaybackService.Current.AddToPlaybackAsync(tracks.First());
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Pause test from Playing state
PlaybackService.Current.PlayPause();
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Paused, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Add now all tracks to test correct Play/Pause behaviour
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Paused, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Play test from Paused state
PlaybackService.Current.PlayPause();
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Test reset playback
PlaybackService.Current.ResetPlayabck();
await Task.Delay(2000);
Assert.AreNotEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Test Auto Play for empty playback
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
PlaybackService.Current.ResetPlayabck();
}
[TestMethod]
public async Task PlayNextPreviousTestAsync()
{
var tracks = await GetSampleTracks();
PlaybackService.Current.SetShuffleMode(false);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
await Task.Delay(2000);
// Test PlayNext
PlaybackService.Current.PlayNext();
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
Assert.AreEqual(tracks.ElementAt(1).Id,
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
());
// Test PlayPrevious
PlaybackService.Current.PlayPrevious();
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
Assert.AreEqual(tracks.First().Id,
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
());
// Test PlayPrevious on first playback item
PlaybackService.Current.PlayPrevious();
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
Assert.AreEqual(tracks.Last().Id,
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
());
PlaybackService.Current.ResetPlayabck();
}
[TestMethod]
public async Task JumpTestAsync()
{
var tracks = await GetSampleTracks();
await PlaybackService.Current.AddToPlaybackAsync(tracks);
var rnd = new Random();
var rndTrack = tracks.ElementAt(rnd.Next(tracks.Count - 1));
PlaybackService.Current.Jump(rndTrack);
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
Assert.AreEqual(rndTrack.Id,
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
());
PlaybackService.Current.ResetPlayabck();
}
[TestMethod]
[Ignore]
public async Task OfflinePlaybackTestAsync()
{
//TODO Write OfflinePlaybackTest
PlaybackService.Current.ResetPlayabck();
throw new NotImplementedException();
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="63945AlexanderPreibisch.SonicStreamer" Publisher="CN=141DC0BE-8183-47DF-9FFA-3EAE930B2404" Version="1.1.0.0" />
<mp:PhoneIdentity PhoneProductId="655d9deb-1890-4201-b48b-d589d342e5a5" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>SonicStreamer</DisplayName>
<PublisherDisplayName>Alexander Preibisch</PublisherDisplayName>
<Logo>Assets\TestStoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="vstest.executionengine.universal.App" Executable="$targetnametoken$.exe" EntryPoint="SonicStreamer.Test.App">
<uap:VisualElements DisplayName="SonicStreamer" Square150x150Logo="Assets\TestSquare150x150Logo.png" Square44x44Logo="Assets\TestSquare44x44Logo.png" Description="SonicStreamer.Test" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\TestWide310x150Logo.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
<uap:ShowOn Tile="wide310x150Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\TestSplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
\ No newline at end of file
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgende
// Attributgruppe gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("SonicStreamer.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SonicStreamer.Test")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyMetadata("TargetPlatform", "UAP")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [Assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
\ No newline at end of file
<!--
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
developers. However, you can modify these parameters to modify the behavior of the .NET Native
optimizer.
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
To fully enable reflection for App1.MyClass and all of its public/private members
<Type Name="App1.MyClass" Dynamic="Required All"/>
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>
\ No newline at end of file
<?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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{E39BABFF-AA58-4AE9-B8AE-B26CF4A6402D}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SonicStreamer.Test</RootNamespace>
<AssemblyName>SonicStreamer.Test</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>SonicStreamer.Test_TemporaryKey.pfx</PackageCertificateKeyFile>
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">14.0</UnitTestPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>