예제 #1
0
        public async Task ShouldAcceptInvitation()
        {
            // Arrange
            var playerId           = Guid.NewGuid();
            var corporationId      = Guid.NewGuid();
            var expectedInvitation = new CorporationInvitation
            {
                InvitationId  = Guid.NewGuid(),
                PlayerId      = playerId,
                CorporationId = corporationId,
            };

            // Act
            await When(new PlayerCreatedEvent(new Player {
                PlayerId = playerId
            }));
            await When(new CorporationCreatedEvent(new Corporation {
                CorporationId = corporationId, CreatedByPlayerId = playerId
            }, null));
            await When(new PlayerInvitedToCorporationEvent(expectedInvitation.PlayerId, expectedInvitation.CorporationId, expectedInvitation.InvitationId, null));
            await When(new PlayerJoinedCorporationEvent(expectedInvitation.PlayerId, expectedInvitation.CorporationId, null, expectedInvitation.InvitationId));

            // Assert
            using (var dbContext = GetInMemoryDatabase())
            {
                Assert.NotEmpty(dbContext.CorporationInvitations);
                var invitation = dbContext.CorporationInvitations.First();
                Assert.True(invitation.Completed);
                Assert.True(invitation.Accepted);
                var player = dbContext.Players.First();
                Assert.Equal(corporationId, player.CorporationId);
            }
        }
예제 #2
0
        public async Task ShouldAddCorporationInvitation()
        {
            // Arrange
            var playerId           = Guid.NewGuid();
            var expectedInvitation = new CorporationInvitation
            {
                InvitationId  = Guid.NewGuid(),
                PlayerId      = playerId,
                CorporationId = Guid.NewGuid(),
            };

            // Act
            await When(new PlayerCreatedEvent(new Player {
                PlayerId = playerId
            }));
            await When(new PlayerInvitedToCorporationEvent(expectedInvitation.PlayerId, expectedInvitation.CorporationId, expectedInvitation.InvitationId, null));

            // Assert
            using (var dbContext = GetInMemoryDatabase())
            {
                Assert.NotEmpty(dbContext.CorporationInvitations);
                var invitation = dbContext.CorporationInvitations.First();
                Assert.Equal(expectedInvitation.InvitationId, invitation.InvitationId);
                Assert.Equal(expectedInvitation.PlayerId, invitation.PlayerId);
                Assert.Equal(expectedInvitation.CorporationId, invitation.CorporationId);
            }
        }