Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test project and added Master Player Account Entity test and fi… #11

Merged
merged 2 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion PlayFabBuddy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ VisualStudioVersion = 17.0.31815.197
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlayFabHelpers", "src\PlayFabHelpers\PlayFabHelpers.csproj", "{B685C73F-1BBF-421A-BEA2-7B355E1EE1F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateOrLoginUsers", "src\CreateOrLoginUsers\CreateOrLoginUsers.csproj", "{7C4B6CB7-8EEF-4F47-BC19-C22969430F4D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateOrLoginUsers", "src\CreateOrLoginUsers\CreateOrLoginUsers.csproj", "{7C4B6CB7-8EEF-4F47-BC19-C22969430F4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayFabHelpersTests", "src\PlayFabHelpersTests\PlayFabHelpersTests.csproj", "{2AD57216-DCF5-421D-9B05-2D5BAE43A4F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +23,10 @@ Global
{7C4B6CB7-8EEF-4F47-BC19-C22969430F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C4B6CB7-8EEF-4F47-BC19-C22969430F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C4B6CB7-8EEF-4F47-BC19-C22969430F4D}.Release|Any CPU.Build.0 = Release|Any CPU
{2AD57216-DCF5-421D-9B05-2D5BAE43A4F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AD57216-DCF5-421D-9B05-2D5BAE43A4F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AD57216-DCF5-421D-9B05-2D5BAE43A4F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AD57216-DCF5-421D-9B05-2D5BAE43A4F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public MasterPlayerAccountEntity(string id, TitlePlayerAccountEntity playerAccou
{
Id = id;
PlayerAccounts = new List<TitlePlayerAccountEntity>();
PlayerAccounts.Add(playerAccount);
}

[JsonConstructor]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace PlayFabBuddy.PlayFabHelpers.Entities.Accounts.Tests
{
[TestClass()]
public class MasterPlayerAccountEntityTests
{
[TestMethod()]
public void MasterPlayerAccountEntityTestEmptyConstructor()
{
string guid = Guid.NewGuid().ToString();

var emptyList = new List<TitlePlayerAccountEntity>();

var account = new MasterPlayerAccountEntity(guid);

Assert.AreEqual(guid, account.Id);
Assert.AreEqual(emptyList.Count, account.PlayerAccounts.Count);
}

[TestMethod()]
public void MasterPlayerAccountEntityTestMainConstructor()
{
string guid = Guid.NewGuid().ToString();

var filledList = new List<TitlePlayerAccountEntity>();
filledList.Add(new TitlePlayerAccountEntity(guid));

var account2 = new MasterPlayerAccountEntity(guid, filledList);

Assert.AreEqual(filledList, account2.PlayerAccounts);
}

[TestMethod()]
public void MasterPlayerAccountEntityTestConstructor2()
{
string guid = Guid.NewGuid().ToString();

var entity = new TitlePlayerAccountEntity(guid);

var account = new MasterPlayerAccountEntity(guid, entity);

Assert.IsTrue(account.PlayerAccounts.Contains(entity));
Assert.IsTrue(account.PlayerAccounts.Count == 1);
}

[TestMethod()]
public void RemoveTitlePlayerAccountTest()
{
string guid = Guid.NewGuid().ToString();

TitlePlayerAccountEntity entity = new TitlePlayerAccountEntity(Guid.NewGuid().ToString());

var filledList = new List<TitlePlayerAccountEntity>();
filledList.Add(entity);

var account = new MasterPlayerAccountEntity(guid);

account.RemoveTitlePlayerAccount(entity);

Assert.IsFalse(account.PlayerAccounts.Contains(entity));
}

[TestMethod()]
public void AddTitlePlayerAccountTest()
{
string guid = Guid.NewGuid().ToString();

var emptyList = new List<TitlePlayerAccountEntity>();

var account = new MasterPlayerAccountEntity(guid);

TitlePlayerAccountEntity entity = new TitlePlayerAccountEntity(Guid.NewGuid().ToString());

account.AddTitlePlayerAccount(entity);

Assert.IsTrue(account.PlayerAccounts.Contains(entity));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace PlayFabBuddy.PlayFabHelpers.Entities.Accounts.Tests
{
[TestClass()]
public class TitlePlayerAccountEntityTests
{
[TestMethod()]
public void TitlePlayerAccountEntityTest()
{
string guid = Guid.NewGuid().ToString();

var account = new TitlePlayerAccountEntity(guid);

Assert.AreEqual(account.Id, guid);
}

[TestMethod()]
public void TitlePlayerAccountEntityTest1()
{
string guid = Guid.NewGuid().ToString();

var masterAccount = new MasterPlayerAccountEntity(guid);

var titleAccount = new TitlePlayerAccountEntity(guid, masterAccount);

Assert.IsTrue(masterAccount.PlayerAccounts.Count == 1);
Assert.AreEqual(titleAccount, masterAccount.PlayerAccounts.First<TitlePlayerAccountEntity>());
}

[TestMethod()]
public void AssignMasterAccountTest()
{
string guid = Guid.NewGuid().ToString();

var masterAccount = new MasterPlayerAccountEntity(guid);
var newMasterAccount = new MasterPlayerAccountEntity(Guid.NewGuid().ToString());

var titleAccount = new TitlePlayerAccountEntity(guid, masterAccount);
titleAccount.AssignMasterAccount(newMasterAccount);

Assert.IsTrue(newMasterAccount.PlayerAccounts.Count == 1);
Assert.AreEqual(titleAccount, newMasterAccount.PlayerAccounts.First<TitlePlayerAccountEntity>());
}
}
}
21 changes: 21 additions & 0 deletions src/PlayFabHelpersTests/PlayFabHelpersTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

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

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PlayFabHelpers\PlayFabHelpers.csproj" />
</ItemGroup>

</Project>