Added unit test project

This commit is contained in:
watsonb8 2020-01-20 18:38:05 -05:00
parent 320967be89
commit 28afcf12e4
8 changed files with 142 additions and 131 deletions

View File

@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aurora", "Aurora\Aurora.csp
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aurora.gtk", "Aurora.gtk\Aurora.gtk.csproj", "{E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aurora.gtk", "Aurora.gtk\Aurora.gtk.csproj", "{E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aurora.test", "Aurora.test\Aurora.test.csproj", "{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator Debug|iPhoneSimulator = Debug|iPhoneSimulator
@ -39,5 +41,17 @@ Global
{E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator {E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator {E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
{E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Release|Any CPU.Build.0 = Release|iPhoneSimulator {E8C8C24A-5C51-47CB-B241-F5A9F0E808B1}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|iPhone.Build.0 = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|iPhone.ActiveCfg = Release|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|iPhone.Build.0 = Release|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45680D8A-1AF1-4D93-AAC0-59CDB01CED5D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Grpc.Core" Version="2.26.0" />
<PackageReference Include="Grpc.Tools" Version="2.26.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Grpc" Version="2.26.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Remove="..\Aurora\Proto\general.proto" />
<Protobuf Remove="..\Aurora\Proto\party.v2.proto" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aurora\Aurora.csproj" />
</ItemGroup>
</Project>

31
Aurora.test/UnitTest1.cs Normal file
View File

@ -0,0 +1,31 @@
using NUnit.Framework;
using Aurora.Proto.PartyV2;
using Aurora.Services.Server;
using Grpc.Core;
namespace Aurora.test
{
public class Tests
{
private RemotePartyService.RemotePartyServiceClient _remotePartyService;
private Channel _channel;
[SetUp]
public void Setup()
{
ServerService.Instance.Start("testParty", "asdf");
_channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
_remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
}
[Test]
public void Test2()
{
ListMembersResponse resp = _remotePartyService.ListMembers(new ListMembersRequest()
{
Parent = "party1",
PageSize = 10,
});
Assert.NotNull(resp);
}
}
}

View File

@ -1,158 +1,88 @@
<Project <Project Sdk="Microsoft.NET.Sdk">
Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<ProduceAssemblyReference>true</ProduceAssemblyReference> <ProduceAssemblyReference>true</ProduceAssemblyReference>
</PropertyGroup> </PropertyGroup>
<PropertyGroup <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Debug|AnyCPU&apos;">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference <PackageReference Include="Xamarin.Forms" Version="4.3.0.991211" />
Include="Xamarin.Forms" <PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
Version="4.3.0.991211"/> <PackageReference Include="taglib-sharp-netstandard2.0" Version="2.1.0" />
<PackageReference <PackageReference Include="LibVLCSharp.Forms" Version="3.3.1" />
Include="Xamarin.Essentials" <PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3.1" />
Version="1.3.1"/> <PackageReference Include="Grpc" Version="2.25.0" />
<PackageReference <PackageReference Include="Grpc.Tools" Version="2.25.0" PrivateAssests="All">
Include="taglib-sharp-netstandard2.0"
Version="2.1.0"/>
<PackageReference
Include="LibVLCSharp.Forms"
Version="3.3.1"/>
<PackageReference
Include="VideoLAN.LibVLC.Mac"
Version="3.1.3.1"/>
<PackageReference
Include="Grpc"
Version="2.25.0"/>
<PackageReference
Include="Grpc.Tools"
Version="2.25.0"
PrivateAssests="All">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference <PackageReference Include="Google.Protobuf" Version="3.10.1" />
Include="Google.Protobuf" <PackageReference Include="Xam.Plugins.Settings" Version="3.1.1" />
Version="3.10.1"/> <PackageReference Include="Sharpnado.Forms.HorizontalListView" Version="1.3.0" />
<PackageReference <PackageReference Include="DLToolkit.Forms.Controls.FlowListView" Version="2.0.11" />
Include="Xam.Plugins.Settings" <PackageReference Include="CarouselView.FormsPlugin" Version="5.2.0" />
Version="3.1.1"/>
<PackageReference
Include="Sharpnado.Forms.HorizontalListView"
Version="1.3.0"/>
<PackageReference
Include="DLToolkit.Forms.Controls.FlowListView"
Version="2.0.11"/>
<PackageReference
Include="CarouselView.FormsPlugin"
Version="5.2.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder <Folder Include="Design\" />
Include="Design\"/> <Folder Include="Design\Components\" />
<Folder <Folder Include="Design\Views\" />
Include="Design\Components\"/> <Folder Include="Design\Views\Songs\" />
<Folder <Folder Include="Design\Views\MainView\" />
Include="Design\Views\"/> <Folder Include="Design\Behaviors\" />
<Folder <Folder Include="Design\Components\NavigationMenu\" />
Include="Design\Views\Songs\"/> <Folder Include="Design\Views\Albums\" />
<Folder <Folder Include="Design\Views\Artists\" />
Include="Design\Views\MainView\"/> <Folder Include="Design\Views\Stations\" />
<Folder <Folder Include="Utils\" />
Include="Design\Behaviors\"/> <Folder Include="Models\" />
<Folder <Folder Include="Services\" />
Include="Design\Components\NavigationMenu\"/> <Folder Include="Design\Views\Party\" />
<Folder <Folder Include="Design\Components\MemberList\" />
Include="Design\Views\Albums\"/> <Folder Include="Design\Components\Library\" />
<Folder <Folder Include="Design\Views\Profile\" />
Include="Design\Views\Artists\"/> <Folder Include="Design\Components\DataGrid\" />
<Folder <Folder Include="Resources\" />
Include="Design\Views\Stations\"/> <Folder Include="Design\Extensions\" />
<Folder <Folder Include="Design\Components\ImageButton\" />
Include="Utils\"/> <Folder Include="Design\Components\Dialogs\" />
<Folder <Folder Include="Design\Views\Party\NewPartyDialog\" />
Include="Models\"/> <Folder Include="Design\Components\TabView\" />
<Folder
Include="Services\"/>
<Folder
Include="Design\Views\Party\"/>
<Folder
Include="Design\Components\MemberList\"/>
<Folder
Include="Design\Components\Library\"/>
<Folder
Include="Design\Views\Profile\"/>
<Folder
Include="Design\Components\DataGrid\"/>
<Folder
Include="Resources\"/>
<Folder
Include="Design\Extensions\"/>
<Folder
Include="Design\Components\ImageButton\"/>
<Folder
Include="Design\Components\Dialogs\"/>
<Folder
Include="Design\Views\Party\NewPartyDialog\"/>
<Folder
Include="Design\Components\TabView\"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile <Compile Remove="Design\Behaviors\DeselectItemBehaviorBase.cs" />
Remove="Design\Behaviors\DeselectItemBehaviorBase.cs"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile <Compile Update="Design\Components\MusicPlayer\Player.xaml.cs">
Update="Design\Components\MusicPlayer\Player.xaml.cs">
<DependentUpon>Player.xaml</DependentUpon> <DependentUpon>Player.xaml</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Protobuf <Protobuf Include="Proto\general.proto" />
Include="Proto\general.proto"/> <Protobuf Include="Proto\party.proto" />
<Protobuf <Protobuf Include="Proto\events.proto" />
Include="Proto\party.proto"/> <Protobuf Include="Proto\playback.proto" />
<Protobuf <Protobuf Include="Proto\sync.proto" />
Include="Proto\events.proto"/> <Protobuf Include="Proto\party.v2.proto" />
<Protobuf
Include="Proto\playback.proto"/>
<Protobuf
Include="Proto\sync.proto"/>
<Protobuf
Include="Proto\party.v2.proto"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource <EmbeddedResource Include="Resources\backward.png" />
Include="Resources\backward.png"/> <EmbeddedResource Include="Resources\forwards.png" />
<EmbeddedResource <EmbeddedResource Include="Resources\like.png" />
Include="Resources\forwards.png"/> <EmbeddedResource Include="Resources\play.png" />
<EmbeddedResource
Include="Resources\like.png"/>
<EmbeddedResource
Include="Resources\play.png"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource <EmbeddedResource Update="Design\Components\NavigationMenu\NavigationMenu.css">
Update="Design\Components\NavigationMenu\NavigationMenu.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None <None Remove="Design\Resources\unselected.png" />
Remove="Design\Resources\unselected.png"/> <None Remove="Design\Components\MediaPlayer\play.png" />
<None <None Remove="Resources\backward.png" />
Remove="Design\Components\MediaPlayer\play.png"/> <None Remove="Resources\forwards.png" />
<None <None Remove="Resources\like.png" />
Remove="Resources\backward.png"/> <None Remove="Resources\play.png" />
<None
Remove="Resources\forwards.png"/>
<None
Remove="Resources\like.png"/>
<None
Remove="Resources\play.png"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -25,8 +25,15 @@ namespace Aurora.Services.Server.Controllers
startIdx = _memberList.IndexOfKey(request.PageToken) + 1; startIdx = _memberList.IndexOfKey(request.PageToken) + 1;
} }
//Assign pageSize
if (request.PageSize > _memberList.Count)
{
request.PageSize = _memberList.Count;
}
//Gather page //Gather page
List<Member> members = (List<Member>)_memberList.Values; List<Member> members = new List<Member>(_memberList.Values);
resp.Members.AddRange(members.GetRange(startIdx, request.PageSize)); resp.Members.AddRange(members.GetRange(startIdx, request.PageSize));
//Set next page token //Set next page token

View File

@ -26,7 +26,7 @@ namespace Aurora.Services.Server.Controllers
this._description = description; this._description = description;
this._memberList = new SortedList<string, Member>(); this._memberList = new SortedList<string, Member>();
string userName = SettingsService.Instance.Username; string userName = "testUser";
this._eventManager = new EventManager.EventManager(); this._eventManager = new EventManager.EventManager();
@ -36,6 +36,8 @@ namespace Aurora.Services.Server.Controllers
UserName = userName, UserName = userName,
IpAddress = ServerService.GetLocalIPAddress(), IpAddress = ServerService.GetLocalIPAddress(),
}; };
this._memberList.Add(_hostMember.Name, _hostMember);
} }
public override Task<Party> GetParty(Proto.General.Empty request, Grpc.Core.ServerCallContext context) public override Task<Party> GetParty(Proto.General.Empty request, Grpc.Core.ServerCallContext context)

View File

@ -11,7 +11,7 @@ namespace Aurora.Services.Server
{ {
public class ServerService : BaseService<ServerService> public class ServerService : BaseService<ServerService>
{ {
private int _port = SettingsService.Instance.DefaultPort; private int _port = 8080;
private string _hostname; private string _hostname;
private Grpc.Core.Server _server; private Grpc.Core.Server _server;

View File

@ -9,6 +9,9 @@
"**/bin": true, "**/bin": true,
"**/obj": true, "**/obj": true,
"**/packages": true "**/packages": true
} },
"nxunitExplorer.nunit": "/Users/brandonwatson/Documents/Gitlab/Aurora/aurora-sharp-desktop/Aurora.test/bin/Debug/nunit.framework.dll",
"nxunitExplorer.logpanel": true,
"dotnet-test-explorer.testProjectPath": "./Aurora.test"
} }
} }