예제 #1
0
        public void ReturnPermissionDeniedWhenPlayerIsNotTheLeader()
        {
            // Setup the client such that it will claim that the party has as leader a different player other than the
            // one making the request.
            var party = new PartyDataModel(_testParty);

            party.UpdatePartyLeader(TestPlayerId2);

            _mockMemoryStoreClient.Setup(client => client.GetAsync <PartyDataModel>(_testUpdatedParty.Id)).ReturnsAsync(party);

            // Check that an exception was thrown signaling that the update operation failed.
            var context = Util.CreateFakeCallContext(TestPlayerId, Pit);
            var request = new UpdatePartyRequest {
                UpdatedParty = _testUpdatedParty
            };
            var exception = Assert.ThrowsAsync <RpcException>(() => _partyService.UpdateParty(request, context));

            Assert.That(exception.Message, Contains.Substring("can only be done by the leader"));
            Assert.AreEqual(StatusCode.PermissionDenied, exception.StatusCode);
        }
예제 #2
0
 public void ReturnFalseIfProposedLeaderIsNotAMember()
 {
     Assert.False(_party.UpdatePartyLeader("Percival"));
 }