Exemplo n.º 1
0
 public void InviteToPlay(Invitation invitation)
 {
     if (invitation != null)
     {
         invitation.ErrorOccurred += OnErrorOccured;
         InviteStatus status = InviteManager.IsValidInvite(invitation);
         switch (status.StatusType)
         {
             case InviteStatusType.Invalid:
             case InviteStatusType.Rejected:
                 Clients.Caller.notify(new UserNotification(status.Message, UserNotificationType.Red));
                 break;
             case InviteStatusType.Valid:
             default:
                 Clients.Client(invitation.To.Id).showInviteModal(invitation.InviteToMarkup());
                 break;
         }
     }
 }
Exemplo n.º 2
0
        public void Invitation_InviteToMarkup_CopesWithNullInviteMembers()
        {
            //Arrange
            Guid id = Guid.Parse("A499F757-C538-4559-A156-5D658BDEC0F3");
            Player p1 = null;
            Player p2 = null;
            DateTime dateTime = DateTime.MinValue;
            Invitation invite = new Invitation(id, p1, p2, dateTime);

            //Act
            string markup = invite.InviteToMarkup();

            //Assert
            Assert.AreEqual<string>(string.Empty, markup);
        }
Exemplo n.º 3
0
        public void Invitation_InviteToMarkup_CreatesInvitationMarkup()
        {
            //Arrange
            Guid id = Guid.Parse("A499F757-C538-4559-A156-5D658BDEC0F3");
            Player p1 = new Player("Alex", "9C6109F9-5320-4411-9D1C-FA13D1CEC544", string.Empty);
            Player p2 = new Player("Bogdan", "3D072B37-0937-43EB-A77F-137B4DD08E03", string.Empty);
            DateTime dateTime = new DateTime(2012, 12, 9, 10, 0, 0);
            Invitation invite = new Invitation(id, p1, p2, dateTime);

            //Act
            string markup = invite.InviteToMarkup();

            //Assert
            Assert.AreNotEqual<string>(string.Empty, markup);
        }
Exemplo n.º 4
0
        public void Invitation_InviteToMarkup_RaisesErrorEvent()
        {
            //Arrange
            Guid id = Guid.Parse("A499F757-C538-4559-A156-5D658BDEC0F3");
            Player p1 = null;
            Player p2 = null;
            DateTime dateTime = DateTime.MinValue;
            Invitation invite = new Invitation(id, p1, p2, dateTime);

            string expectedMessage = "Error when creating invite markup!";
            string gottenMessage = string.Empty;
            EventHandler<NotificationEventArgs<string>> ErrorHandlerFunction = new EventHandler<NotificationEventArgs<string>>((o,e) =>
            {
                gottenMessage = e.Message;
            });

            //Act
            invite.ErrorOccurred += ErrorHandlerFunction;
            string markup = invite.InviteToMarkup();

            //Assert
            Assert.AreEqual<string>(expectedMessage, gottenMessage);
        }