Skip to content

Commit

Permalink
Updated project to .NET 8
Browse files Browse the repository at this point in the history
Changed testing from MSTest to Nunit.
  • Loading branch information
markjamesm committed Dec 4, 2023
1 parent 80a05ce commit 7cb67fb
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 36 deletions.
13 changes: 13 additions & 0 deletions .idea/.idea.MusicSharp/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.MusicSharp/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.MusicSharp/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.MusicSharp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions MusicSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ VisualStudioVersion = 16.0.30621.155
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicSharp", "src\MusicSharp.csproj", "{A1943162-1979-46C6-9082-7F49BEC191BA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicSharpTests", "tests\MusicSharpTests\MusicSharpTests.csproj", "{4D76B590-6B8E-46FC-B79C-C29F93C5C80D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A4109AE-AA05-4695-A7EB-412C02252269}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MusicSharpTests", "MusicSharpTests\MusicSharpTests.csproj", "{B0797164-0016-4ED1-BDDA-42DE8D414CD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,10 +24,10 @@ Global
{A1943162-1979-46C6-9082-7F49BEC191BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1943162-1979-46C6-9082-7F49BEC191BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1943162-1979-46C6-9082-7F49BEC191BA}.Release|Any CPU.Build.0 = Release|Any CPU
{4D76B590-6B8E-46FC-B79C-C29F93C5C80D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D76B590-6B8E-46FC-B79C-C29F93C5C80D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D76B590-6B8E-46FC-B79C-C29F93C5C80D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D76B590-6B8E-46FC-B79C-C29F93C5C80D}.Release|Any CPU.Build.0 = Release|Any CPU
{B0797164-0016-4ED1-BDDA-42DE8D414CD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0797164-0016-4ED1-BDDA-42DE8D414CD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0797164-0016-4ED1-BDDA-42DE8D414CD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0797164-0016-4ED1-BDDA-42DE8D414CD6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 23 additions & 0 deletions MusicSharpTests/MusicSharpTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="NUnit" Version="3.13.3"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
<PackageReference Include="NUnit.Analyzers" Version="3.3.0"/>
<PackageReference Include="coverlet.collector" Version="3.1.2"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\MusicSharp.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions MusicSharpTests/PlaylistLoaderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using MusicSharp.Models;

namespace MusicSharpTests;

public class Tests
{
[Test]
public void Load_NullPlaylist()
{
// Act and assert
Assert.Throws<NullReferenceException>(() => PlaylistLoader.LoadPlaylist(null));
}
}
1 change: 1 addition & 0 deletions MusicSharpTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
26 changes: 26 additions & 0 deletions MusicSharpTests/WinPlayerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using MusicSharp.SoundEngines;

namespace MusicSharpTests;

public class WinPlayerTests
{
[Test]
public void PlayFromPlaylist_NullFile()
{
// arrange
var player = new WinPlayer();

// act and assert
Assert.Throws<NullReferenceException>(() => player.PlayFromPlaylist(null));
}

[Test]
public void OpenStream_NullFile()
{
// arrange
var player = new WinPlayer();

// act and assert
Assert.Throws<NullReferenceException>(() => player.OpenStream(null));
}
}
4 changes: 2 additions & 2 deletions src/MusicSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Version>0.4.8</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>0.4.9</Version>
<Authors>Mark-James McDougall</Authors>
<Company>Mark-James McDougall</Company>
<PackageIcon></PackageIcon>
Expand Down
21 changes: 12 additions & 9 deletions src/SoundEngines/WinPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ public void OpenFile(string path)

if (isFileValid)
{
_audioFileReader = new AudioFileReader(path);
_outputDevice.Init(_audioFileReader);
_outputDevice.Play();
PlayerStatus = ePlayerStatus.Playing;
try
{
_audioFileReader = new AudioFileReader(path);
_outputDevice.Init(_audioFileReader);
_outputDevice.Play();
PlayerStatus = ePlayerStatus.Playing;
}
catch (FileNotFoundException)
{
}
}

// Space for error message, should one be wanted/needed.
Expand Down Expand Up @@ -96,7 +102,7 @@ public void PlayFromPlaylist(string path)
_outputDevice.Play();
PlayerStatus = ePlayerStatus.Playing;
}
catch (System.IO.FileNotFoundException)
catch (FileNotFoundException)
{
}
}
Expand Down Expand Up @@ -162,10 +168,7 @@ public void OpenStream(string streamUrl)
_outputDevice.Init(mf);
_outputDevice.Play();
}
catch (ArgumentException)
{
}
catch (FileNotFoundException)
catch (NullReferenceException)
{
}
}
Expand Down
19 changes: 0 additions & 19 deletions tests/MusicSharpTests/src/PlaylistLoaderTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>

<RootNamespace>MusicSharpTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
File renamed without changes.

0 comments on commit 7cb67fb

Please sign in to comment.