Added more unit tests for members resource

This commit is contained in:
watsonb8 2020-01-20 23:22:58 -05:00
parent df2a6b4bfc
commit f8ad2f459e
2 changed files with 87 additions and 1 deletions

View File

@ -3,6 +3,7 @@ using Aurora.Proto.PartyV2;
using Aurora.Services.Server;
using Grpc.Core;
using System.Threading.Tasks;
using System.Linq;
namespace Aurora.test.ControllerTests
{
@ -56,5 +57,87 @@ namespace Aurora.test.ControllerTests
Assert.NotNull(member);
}
static object[] MultipleMembersCases =
{
new object[] {"Tupac", "Aubrey Grahm", "Beyonce Knowls", "Ke$ha", "A$ap Ferg"},
};
[Test]
[TestCaseSource("MultipleMembersCases")]
public void CreateMultiplMembersTest(object[] memberNames)
{
//Add members
foreach (string name in memberNames)
{
Member member = _remotePartyService.CreateMember(new CreateMemberRequest()
{
Parent = "party1",
Member = new Member()
{
UserName = name
}
});
Assert.NotNull(member);
}
//List members
ListMembersResponse resp = _remotePartyService.ListMembers(new ListMembersRequest()
{
Parent = "party1",
PageSize = 10,
});
Assert.NotNull(resp);
Assert.AreEqual(resp.Members.Count, 6);
}
[Test]
[TestCaseSource("MultipleMembersCases")]
public void DeleteMemberTest(object[] memberNames)
{
//Add members
foreach (string name in memberNames)
{
Member member = _remotePartyService.CreateMember(new CreateMemberRequest()
{
Parent = "party1",
Member = new Member()
{
UserName = name
}
});
Assert.NotNull(member);
}
//List members
ListMembersResponse resp = _remotePartyService.ListMembers(new ListMembersRequest()
{
Parent = "party1",
PageSize = 10,
});
Assert.NotNull(resp);
Assert.AreEqual(resp.Members.Count, 6);
string keshaResourceName = resp.Members.First(member => member.UserName == "Ke$ha").Name;
//Delete member
_remotePartyService.DeleteMember(new DeleteMemberRequest()
{
Name = keshaResourceName
});
//List members
resp = _remotePartyService.ListMembers(new ListMembersRequest()
{
Parent = "party1",
PageSize = 10,
});
Assert.NotNull(resp);
Assert.AreEqual(resp.Members.Count, 5);
Assert.False(resp.Members.Any(member => member.UserName == "Ke$sha"));
}
}
}

View File

@ -163,7 +163,10 @@ namespace Aurora.Services.Server.EventManager
public void CancelEventStream(string sessionIdentifierId)
{
_actionList.TryGetValue(sessionIdentifierId, out EventAction value);
value.Cancel();
if (value != null)
{
value.Cancel();
}
RemoveEventHandler(sessionIdentifierId);
}