public async Task MessagesNotificationsReadReceipts_Async()
        {
            CommunicationIdentityClient            communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.ConnectionString);
            Response <CommunicationUserIdentifier> threadCreatorIdentifier     = await communicationIdentityClient.CreateUserAsync();

            AccessToken communicationUserToken = await communicationIdentityClient.GetTokenAsync(threadCreatorIdentifier.Value, new[] { CommunicationTokenScope.Chat });

            string userToken = communicationUserToken.Token;
            string endpoint  = TestEnvironment.ChatApiUrl();

            ChatClient chatClient = new ChatClient(
                new Uri(endpoint),
                new CommunicationTokenCredential(userToken));

            CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(topic : "Hello world!", participants : new ChatParticipant[] { });

            ChatThreadClient chatThreadClient = chatClient.GetChatThreadClient(createChatThreadResult.ChatThread.Id);

            #region Snippet:Azure_Communication_Chat_Tests_Samples_SendMessage_KeyConcepts
            string messageId = chatThreadClient.SendMessage("Let's meet at 11am");
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_SendMessage_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_GetMessage_KeyConcepts
            ChatMessage message = chatThreadClient.GetMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_GetMessage_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_GetMessages_KeyConcepts
            Pageable <ChatMessage> messages = chatThreadClient.GetMessages();
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_GetMessages_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_UpdateMessage_KeyConcepts
            chatThreadClient.UpdateMessage(messageId, content: "Instead of 11am, let's meet at 2pm");
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_UpdateMessage_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_DeleteMessage_KeyConcepts
            chatThreadClient.DeleteMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_DeleteMessage_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_SendReadReceipt_KeyConcepts
            chatThreadClient.SendReadReceipt(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_SendReadReceipt_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_GetReadReceipts_KeyConcepts
            Pageable <ChatMessageReadReceipt> readReceipts = chatThreadClient.GetReadReceipts();
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_GetReadReceipts_KeyConcepts

            #region Snippet:Azure_Communication_Chat_Tests_Samples_SendTypingNotification_KeyConcepts
            chatThreadClient.SendTypingNotification();
            #endregion Snippet:Azure_Communication_Chat_Tests_Samples_SendTypingNotification_KeyConcepts
        }
        public void SendGetUpdateDeleteMessagesSendNotificationReadReceipts()
        {
            CommunicationIdentityClient  communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.ConnectionString);
            Response <CommunicationUser> threadMember           = communicationIdentityClient.CreateUser();
            CommunicationUserToken       communicationUserToken = communicationIdentityClient.IssueToken(threadMember.Value, new[] { CommunicationTokenScope.Chat });
            string userToken            = communicationUserToken.Token;
            string endpoint             = TestEnvironment.ChatApiUrl();
            string theadCreatorMemberId = communicationUserToken.User.Id;

            ChatClient chatClient = new ChatClient(
                new Uri(endpoint),
                new CommunicationUserCredential(userToken));

            var chatThreadMember = new ChatThreadMember(new CommunicationUser(theadCreatorMemberId))
            {
                DisplayName      = "UserDisplayName",
                ShareHistoryTime = DateTime.MinValue
            };
            ChatThreadClient chatThreadClient = chatClient.CreateChatThread(topic: "Hello world!", members: new[] { chatThreadMember });
            string           threadId         = chatThreadClient.Id;

            var content           = "hello world";
            var priority          = ChatMessagePriority.Normal;
            var senderDisplayName = "sender name";
            SendChatMessageResult sendMessageResult = chatThreadClient.SendMessage(content, priority, senderDisplayName);

            var                    messageId   = sendMessageResult.Id;
            ChatMessage            chatMessage = chatThreadClient.GetMessage(messageId);
            Pageable <ChatMessage> allMessages = chatThreadClient.GetMessages();

            foreach (ChatMessage message in allMessages)
            {
                Console.WriteLine($"{message.Id}:{message.Sender.Id}:{message.Content}");
            }

            chatThreadClient.UpdateMessage(messageId, "updated message content");
            chatThreadClient.SendReadReceipt(messageId);
            Pageable <ReadReceipt> allReadReceipts = chatThreadClient.GetReadReceipts();

            foreach (ReadReceipt readReceipt in allReadReceipts)
            {
                Console.WriteLine($"{readReceipt.ChatMessageId}:{readReceipt.Sender.Id}:{readReceipt.ReadOn}");
            }
            chatThreadClient.DeleteMessage(messageId);
            chatThreadClient.SendTypingNotification();
            chatClient.DeleteChatThread(threadId);
        }
Exemplo n.º 3
0
        public void ReadReceiptGS()
        {
            //arr
            Console.WriteLine($"ReadReceiptGS Running on RecordedTestMode : {Mode}");
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (CommunicationUserIdentifier user1, string token1) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user2, string token2) = CreateUserAndToken(communicationIdentityClient);

            string repeatabilityRequestId1 = "contoso-B0A747F1-6245-4307-8267-B974340677DB";

            var participants = new List <ChatParticipant>
            {
                new ChatParticipant(user1),
                new ChatParticipant(user2)
            };
            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient2 = CreateInstrumentedChatClient(token2);

            //act
            CreateChatThreadResult createChatThreadResult = chatClient.CreateChatThread("Thread topic - ReadReceipts Test", participants, repeatabilityRequestId1);
            ChatThreadClient       chatThreadClient       = GetInstrumentedChatThreadClient(chatClient, createChatThreadResult.ChatThread.Id);
            var threadId = chatThreadClient.Id;
            ChatThreadClient chatThreadClient2 = GetInstrumentedChatThreadClient(chatClient2, threadId);

            var messageId2 = chatThreadClient.SendMessage("This is message 1 content");
            var messageId  = chatThreadClient2.SendMessage("This is message 2 content");

            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendReadReceipt
            chatThreadClient.SendReadReceipt(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendReadReceipt
            chatThreadClient2.SendReadReceipt(messageId2);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetReadReceipts
            Pageable <ChatMessageReadReceipt> readReceipts = chatThreadClient.GetReadReceipts();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetReadReceipts
            Pageable <ChatMessageReadReceipt> readReceipts2 = chatThreadClient2.GetReadReceipts();
            var readReceiptsCount  = readReceipts.Count();
            var readReceiptsCount2 = readReceipts2.Count();

            chatClient.DeleteChatThread(threadId);

            //assert
            Assert.AreEqual(2, readReceiptsCount);
            Assert.AreEqual(2, readReceiptsCount2);
        }
        public void ThreadCGUD_MemberAUR_MessageGSU_NotificationT()
        {
            //arr
            Console.WriteLine($"ThreadCGUD_MemberAUR_MessageGSU_NotificationT Running on RecordedTestMode : {Mode}");
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (CommunicationUser user1, string token1) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUser user2, string token2) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUser user3, string token3) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUser user4, string token4) = CreateUserAndToken(communicationIdentityClient);

            var topic = "Thread sync from C# sdk";
            var displayNameMessage = "DisplayName sender message 1";
            var members            = new List <ChatThreadMember>
            {
                new ChatThreadMember(user1),
                new ChatThreadMember(user2),
                new ChatThreadMember(user3)
            };
            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient2 = CreateInstrumentedChatClient(token2);
            ChatClient chatClient3 = CreateInstrumentedChatClient(token3);

            //act
            #region Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            //@@ChatThreadClient chatThreadClient1 = chatClient.CreateChatThread("Thread topic", members);
            // Alternatively, if you have created a chat thread before and you have its threadId, you can create a ChatThreadClient instance using:
            //@@ChatThreadClient chatThreadClient2 = chatClient.GetChatThreadClient("threadId");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            ChatThreadClient chatThreadClient = CreateInstrumentedChatThreadClient(chatClient, topic, members);
            var threadId = chatThreadClient.Id;
            ChatThreadClient chatThreadClient2 = CreateInstrumentedChatThreadClient(chatClient, topic, members);
            ChatThreadClient chatThreadClient3 = GetInstrumentedChatThreadClient(chatClient3, threadId);

            string updatedTopic = "Launch meeting";
            #region Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread
            chatThreadClient.UpdateThread(topic: "Launch meeting");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread
            ChatThread chatThread = chatClient.GetChatThread(threadId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            Pageable <ChatThreadInfo> threads = chatClient.GetChatThreadsInfo();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            var threadsCount = threads.Count();

            string messageContent = "Let's meet at 11am";
            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            SendChatMessageResult sendChatMessageResult = chatThreadClient.SendMessage("Let's meet at 11am");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            var messageContent2 = "Content for message 2";
            SendChatMessageResult sendChatMessageResult2 = chatThreadClient2.SendMessage(messageContent2, ChatMessagePriority.High, displayNameMessage);
            var messageContent3 = "Content for message 3";
            SendChatMessageResult sendChatMessageResult3 = chatThreadClient3.SendMessage(messageContent3, ChatMessagePriority.High, displayNameMessage);
            var messageContent4 = "Content for message 4";
            SendChatMessageResult sendChatMessageResult4 = chatThreadClient3.SendMessage(messageContent4, ChatMessagePriority.High, displayNameMessage);
            var messageContent5 = "Content for message 5";
            SendChatMessageResult sendChatMessageResult5 = chatThreadClient3.SendMessage(messageContent5, ChatMessagePriority.High, displayNameMessage);
            var messageContent6 = "Content for message 6";
            SendChatMessageResult sendChatMessageResult6 = chatThreadClient3.SendMessage(messageContent6, ChatMessagePriority.High, displayNameMessage);

            var messageId  = sendChatMessageResult.Id;
            var messageId2 = sendChatMessageResult2.Id;
            var messageId3 = sendChatMessageResult3.Id;
            var messageId4 = sendChatMessageResult4.Id;
            var messageId5 = sendChatMessageResult5.Id;
            var messageId6 = sendChatMessageResult6.Id;

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage
            ChatMessage message = chatThreadClient.GetMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage
            ChatMessage message2 = chatThreadClient2.GetMessage(messageId2);
            ChatMessage message3 = chatThreadClient3.GetMessage(messageId3);
            ChatMessage message4 = chatThreadClient3.GetMessage(messageId4);
            ChatMessage message5 = chatThreadClient3.GetMessage(messageId5);
            ChatMessage message6 = chatThreadClient3.GetMessage(messageId6);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            Pageable <ChatMessage> messages = chatThreadClient.GetMessages();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            Pageable <ChatMessage> messages2 = chatThreadClient2.GetMessages();
            var getMessagesCount             = messages.Count();
            var getMessagesCount2            = messages2.Count();

            # region Pagination assertions
Exemplo n.º 5
0
        public void E2E_ThreadCreateUpdateGetDelete_MemberAddUpdateRemove_MessageGetSendUpdate_NotificationTyping_ReadReceiptGetSend()
        {
            //arr
            CommunicationUser           user1, user2, user3;
            string                      token1, token2, token3;
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (user1, token1) = CreateUserAndToken(communicationIdentityClient);
            (user2, token2) = CreateUserAndToken(communicationIdentityClient);
            (user3, token3) = CreateUserAndToken(communicationIdentityClient);

            var topic                 = "Thread sync from C# sdk";
            var messageContent        = "This is message 1 content";
            var updatedMessageContent = "This is message 1 content updated";
            var displayNameMessage    = "DisplayName sender message 1";
            var updatedTopic          = "Updated topic - C# sdk";
            var members               = new List <ChatThreadMember>
            {
                new ChatThreadMember(user1),
                new ChatThreadMember(user2)
            };
            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient2 = CreateInstrumentedChatClient(token2);

            //act
            #region Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            //@@ChatThreadClient chatThreadClient1 = chatClient.CreateChatThread("Thread topic", members);
            // Alternatively, if you have created a chat thread before and you have its threadId, you can create a ChatThreadClient instance using:
            //@@ChatThreadClient chatThreadClient2 = chatClient.GetChatThreadClient("threadId");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            ChatThreadClient chatThreadClient  = CreateInstrumentedChatThreadClient(chatClient, topic, members);
            ChatThreadClient chatThreadClient2 = CreateInstrumentedChatThreadClient(chatClient, topic, members);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread
            chatThreadClient.UpdateThread("Updated topic - C# sdk");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread

            var threadId = chatThreadClient.Id;
            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread
            ChatThread chatThread = chatClient.GetChatThread(threadId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            Pageable <ChatThreadInfo> threads = chatClient.GetChatThreadsInfo();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            var threadsCount = threads.Count();

            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            SendChatMessageResult sendChatMessageResult = chatThreadClient.SendMessage("This is message 1 content", ChatMessagePriority.High, displayNameMessage);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            SendChatMessageResult sendChatMessageResult2 = chatThreadClient.SendMessage(messageContent, ChatMessagePriority.High, displayNameMessage);

            var messageId = sendChatMessageResult.Id;
            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage
            ChatMessage message = chatThreadClient.GetMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            Pageable <ChatMessage> messages = chatThreadClient.GetMessages();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            var getMessagesCount = messages.Count();

            #region Snippet:Azure_Communication_Chat_Tests_E2E_UpdateMessage
            chatThreadClient.UpdateMessage(messageId, "This is message 1 content updated");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_UpdateMessage
            Response <ChatMessage> actualUpdateMessage = chatThreadClient.GetMessage(messageId);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_DeleteMessage
            chatThreadClient.DeleteMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_DeleteMessage
            Pageable <ChatMessage> messagesAfterOneDeleted = chatThreadClient.GetMessages();
            ChatMessage            deletedChatMessage      = messagesAfterOneDeleted.First(x => x.Id == messageId);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMembers
            Pageable <ChatThreadMember> chatThreadMembers = chatThreadClient.GetMembers();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMembers
            var chatThreadMembersCount = chatThreadMembers.Count();

            var newMember = new ChatThreadMember(user3);
            #region Snippet:Azure_Communication_Chat_Tests_E2E_AddMembers
            chatThreadClient.AddMembers(members: new[] { newMember });
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_AddMembers
            Pageable <ChatThreadMember> chatThreadMembersAfterOneAdded = chatThreadClient.GetMembers();
            var chatThreadMembersAfterOneAddedCount = chatThreadMembersAfterOneAdded.Count();

            CommunicationUser memberToBeRemoved = user3; //Better name for the snippet
            #region Snippet:Azure_Communication_Chat_Tests_E2E_RemoveMember
            chatThreadClient.RemoveMember(user: memberToBeRemoved);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_RemoveMember
            Pageable <ChatThreadMember> chatThreadMembersAfterOneDeleted = chatThreadClient.GetMembers();
            var chatThreadMembersAfterOneDeletedCount = chatThreadMembersAfterOneDeleted.Count();

            Response typingNotificationResponse = chatThreadClient.SendTypingNotification();
            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendTypingNotification
            chatThreadClient.SendTypingNotification();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendTypingNotification

            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendReadReceipt
            chatThreadClient.SendReadReceipt(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendReadReceipt
            chatThreadClient.SendReadReceipt(sendChatMessageResult2.Id);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetReadReceipts
            Pageable <ReadReceipt> readReceipts = chatThreadClient.GetReadReceipts();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetReadReceipts
            var readReceiptsCount = readReceipts.Count();

            #region Snippet:Azure_Communication_Chat_Tests_E2E_DeleteChatThread
            chatClient.DeleteChatThread(threadId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_DeleteChatThread

            //assert
            Assert.AreEqual(updatedTopic, chatThread.Topic);
            Assert.AreEqual(2, chatThread.Members.Count);
            Assert.AreEqual(messageContent, message.Content);
            Assert.AreEqual(displayNameMessage, message.SenderDisplayName);
            Assert.AreEqual(ChatMessagePriority.High, message.Priority);
            Assert.AreEqual(2, threadsCount);
            Assert.AreEqual(5, getMessagesCount); //Including all types
            Assert.AreEqual(updatedMessageContent, actualUpdateMessage.Value.Content);
            Assert.IsTrue(deletedChatMessage.DeletedOn.HasValue);
            Assert.AreEqual(2, chatThreadMembersCount);
            Assert.AreEqual(3, chatThreadMembersAfterOneAddedCount);
            Assert.AreEqual(2, chatThreadMembersAfterOneDeletedCount);
            Assert.AreEqual((int)HttpStatusCode.OK, typingNotificationResponse.Status);
            // TODO: Commenting out the assert below for now as it is flakey due to server-side delay; currently in investigation
            // Assert.AreEqual(1, readReceiptsCount);
        }
        public void ThreadCGUD_ParticipantAUR_MessageGSU_NotificationT()
        {
            //arr
            Console.WriteLine($"ThreadCGUD_ParticipantAUR_MessageGSU_NotificationT Running on RecordedTestMode : {Mode}");
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (CommunicationUserIdentifier user1, string token1) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user2, _)             = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user3, string token3) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user4, _)             = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user5, _)             = CreateUserAndToken(communicationIdentityClient);

            string repeatabilityRequestId1 = "contoso-F0A747F1-6245-4307-8267-B974340677D2";
            string repeatabilityRequestId2 = "contoso-A0A747F1-6245-4307-8267-B974340677DA";

            var topic = "Thread sync from C# sdk";
            var displayNameMessage = "DisplayName sender message 1";
            var participants       = new[]
            {
                new ChatParticipant(user1)
                {
                    DisplayName = "user1"
                },
                new ChatParticipant(user2)
                {
                    DisplayName = "user2"
                },
                new ChatParticipant(user3)
                {
                    DisplayName = "user3"
                }
            };

            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient3 = CreateInstrumentedChatClient(token3);

            //act
            CreateChatThreadResult createChatThreadResult = chatClient.CreateChatThread(topic, participants, repeatabilityRequestId1);
            ChatThreadClient       chatThreadClient       = GetInstrumentedChatThreadClient(chatClient, createChatThreadResult.ChatThread.Id);
            var threadId = chatThreadClient.Id;

            CreateChatThreadResult createChatThreadResult2 = chatClient.CreateChatThread(topic, participants, repeatabilityRequestId2);
            ChatThreadClient       chatThreadClient2       = GetInstrumentedChatThreadClient(chatClient, createChatThreadResult2.ChatThread.Id);
            ChatThreadClient       chatThreadClient3       = GetInstrumentedChatThreadClient(chatClient3, threadId);

            Pageable <ChatParticipant> chatParticipantsOnCreation = chatThreadClient.GetParticipants();
            var chatParticipantsOnCreationCount = chatParticipantsOnCreation.Count();

            string updatedTopic = "Launch meeting";

            chatThreadClient.UpdateTopic(topic: "Launch meeting");

            ChatThread chatThread = chatClient.GetChatThread(threadId);

            string messageContent  = "Let's meet at 11am";
            string messageId       = chatThreadClient.SendMessage("Let's meet at 11am");
            string messageContent2 = "Content for message 2";
            string messageId2      = chatThreadClient2.SendMessage(messageContent2, ChatMessageType.Text, displayNameMessage);
            string messageContent3 = "Content for message 3";
            string messageId3      = chatThreadClient3.SendMessage(messageContent3, ChatMessageType.Html, displayNameMessage);
            string messageContent4 = "Content for message 4";
            string messageId4      = chatThreadClient3.SendMessage(messageContent4, ChatMessageType.Text, displayNameMessage);
            string messageContent5 = "Content for message 5";
            string messageId5      = chatThreadClient3.SendMessage(messageContent5, ChatMessageType.Html, displayNameMessage);
            string messageContent6 = "Content for message 6";
            string messageId6      = chatThreadClient3.SendMessage(messageContent6, ChatMessageType.Text, displayNameMessage);

            ChatMessage message  = chatThreadClient.GetMessage(messageId);
            ChatMessage message2 = chatThreadClient2.GetMessage(messageId2);
            ChatMessage message3 = chatThreadClient3.GetMessage(messageId3);
            ChatMessage message4 = chatThreadClient3.GetMessage(messageId4);
            ChatMessage message5 = chatThreadClient3.GetMessage(messageId5);
            ChatMessage message6 = chatThreadClient3.GetMessage(messageId6);

            Pageable <ChatMessage> messages  = chatThreadClient.GetMessages();
            Pageable <ChatMessage> messages2 = chatThreadClient2.GetMessages();
            var getMessagesCount             = messages.Count();
            var getMessagesCount2            = messages2.Count();

            Pageable <ChatMessage> pageableMessages = chatThreadClient.GetMessages();

            PageableTester <ChatMessage> .AssertPagination(enumerableResource : pageableMessages, expectedPageSize : 2, expectedTotalResources : 8);

            string updatedMessageContent = "Instead of 11am, let's meet at 2pm";

            chatThreadClient.UpdateMessage(messageId, content: "Instead of 11am, let's meet at 2pm");
            Response <ChatMessage> actualUpdateMessage = chatThreadClient.GetMessage(messageId);

            chatThreadClient.DeleteMessage(messageId);
            Pageable <ChatMessage> messagesAfterOneDeleted = chatThreadClient.GetMessages();
            ChatMessage            deletedChatMessage      = messagesAfterOneDeleted.First(x => x.Id == messageId);

            Pageable <ChatParticipant> chatParticipants = chatThreadClient.GetParticipants();
            var chatParticipantsCount = chatParticipants.Count();

            var newParticipant = new ChatParticipant(user4)
            {
                DisplayName = "user4"
            };
            var newParticipant2 = new ChatParticipant(user5)
            {
                DisplayName = "user5"
            };

            chatThreadClient.AddParticipants(participants: new[] { newParticipant });
            AddChatParticipantsResult addChatParticipantsResult = chatThreadClient.AddParticipant(newParticipant2);

            Pageable <ChatParticipant> chatParticipantsAfterTwoAdded = chatThreadClient.GetParticipants();

            PageableTester <ChatParticipant> .AssertPagination(enumerableResource : chatParticipantsAfterTwoAdded, expectedPageSize : 2, expectedTotalResources : 5);

            var chatParticipantsAfterTwoAddedCount = chatParticipantsAfterTwoAdded.Count();

            Pageable <ChatMessage> messagesAfterParticipantsAdded = chatThreadClient.GetMessages();
            ChatMessage            participantAddedMessage        = messagesAfterParticipantsAdded.First(x => x.Type == ChatMessageType.ParticipantAdded);

            CommunicationUserIdentifier participantToBeRemoved = user4;

            chatThreadClient.RemoveParticipant(identifier: participantToBeRemoved);
            Pageable <ChatParticipant> chatParticipantAfterOneDeleted = chatThreadClient.GetParticipants();
            var chatParticipantAfterOneDeletedCount = chatParticipantAfterOneDeleted.Count();

            Pageable <ChatMessage> messagesAfterParticipantRemoved = chatThreadClient.GetMessages();
            ChatMessage            participantRemovedMessage       = messagesAfterParticipantRemoved.First(x => x.Type == ChatMessageType.ParticipantRemoved);

            Response typingNotificationResponse = chatThreadClient.SendTypingNotification();

            chatThreadClient.SendTypingNotification();

            Pageable <ChatThreadInfo> threads = chatClient.GetChatThreadsInfo();
            var threadsCount = threads.Count();

            chatClient.DeleteChatThread(threadId);

            //assert
            Assert.AreEqual(updatedTopic, chatThread.Topic);
            Assert.AreEqual(3, chatParticipantsOnCreationCount);
            Assert.AreEqual(messageContent, message.Content.Message);
            Assert.AreEqual(updatedMessageContent, actualUpdateMessage.Value.Content.Message);
            Assert.AreEqual(ChatMessageType.Text, message.Type);

            Assert.AreEqual(messageContent2, message2.Content.Message);
            Assert.AreEqual(displayNameMessage, message2.SenderDisplayName);
            Assert.AreEqual(messageContent3, message3.Content.Message);
            Assert.AreEqual(messageContent4, message4.Content.Message);
            Assert.AreEqual(messageContent5, message5.Content.Message);
            Assert.AreEqual(messageContent6, message6.Content.Message);

            Assert.AreEqual(2, threadsCount);
            Assert.AreEqual(8, getMessagesCount);  //Including all types : 5 text message, 3 control messages
            Assert.AreEqual(3, getMessagesCount2); //Including all types : 1 text message, 2 control messages

            Assert.AreEqual(1, participantAddedMessage.Content.Participants.Count);
            Assert.AreEqual(user5.Id, CommunicationIdentifierSerializer.Serialize(participantAddedMessage.Content.Participants[0].User).CommunicationUser.Id);
            Assert.AreEqual("user5", participantAddedMessage.Content.Participants[0].DisplayName);

            Assert.AreEqual(1, participantRemovedMessage.Content.Participants.Count);
            Assert.AreEqual(user4.Id, CommunicationIdentifierSerializer.Serialize(participantRemovedMessage.Content.Participants[0].User).CommunicationUser.Id);
            Assert.AreEqual("user4", participantRemovedMessage.Content.Participants[0].DisplayName);

            Assert.IsTrue(deletedChatMessage.DeletedOn.HasValue);
            Assert.AreEqual(3, chatParticipantsCount);
            Assert.AreEqual(5, chatParticipantsAfterTwoAddedCount);
            Assert.AreEqual(4, chatParticipantAfterOneDeletedCount);
            Assert.IsNull(addChatParticipantsResult.Errors);
            Assert.AreEqual((int)HttpStatusCode.OK, typingNotificationResponse.Status);
        }