Exemplo n.º 1
0
        public ConversationsController()
        {
            var context = new ChatDatabaseContext();

            this.conversationsRepository = new ConversationsRepository(context);
            this.usersRepository         = new UsersRepository(context);
        }
            public async Task WhenGetConversationParticipantsGetsCalled()
            {
                Setup();

                _conversationParticipants = new Fixture().CreateMany <ConversationParticipant>().ToList();

                ConversationsRepository.Setup(repository =>
                                              repository.GetConversationParticipantsByConversationId(It.IsAny <Guid>()))
                .ReturnsAsync(_conversationParticipants);

                _participantIds = await ConversationsService.GetConversationParticipants(_conversationId);
            }
        public async void ConversationsUpdate(ExecutionContext context, string url)
        {
            var response = Conexion.GetDataApi(url);

            if (response.IsSuccessStatusCode)
            {
                var dataObjectsTickets = response.Content.ReadAsAsync <IEnumerable <dynamic> >().Result;
                foreach (var item in dataObjectsTickets)
                {
                    var tickets = new Tickets()
                    {
                        TicketID = item.id,
                    };
                    var responseConversations = Conexion.GetDataApi("/tickets/" + tickets.TicketID + "/conversations");
                    if (responseConversations.IsSuccessStatusCode)
                    {
                        var dataObjectsConversations = responseConversations.Content.ReadAsAsync <IEnumerable <dynamic> >().Result;
                        foreach (var itemC in dataObjectsConversations)
                        {
                            Console.WriteLine(itemC.id);
                            JArray to_emails    = (JArray)itemC["to_emails"];
                            JArray cc_emails    = (JArray)itemC["to_emails"];
                            JArray bcc_emails   = (JArray)itemC["to_emails"];
                            var    conversation = new Conversations()
                            {
                                body_text           = (string)itemC.body_text,
                                id                  = itemC.id,
                                incoming            = itemC.incoming,
                                @private            = itemC.@private,
                                user_id             = (string)itemC.user_id,
                                support_email       = (string)itemC.support_email,
                                source              = itemC.source,
                                category            = itemC.category,
                                ticket_id           = itemC.ticket_id,
                                to_emails           = to_emails.ToObject <List <string> >(),  //(itemC.to_emails is null) ? new List<string>() : itemC.to_emails,
                                from_email          = (string)itemC.from_email,
                                cc_emails           = cc_emails.ToObject <List <string> >(),  //(itemC.cc_emails is null) ? new List<string>() : itemC.cc_emails,
                                bcc_emails          = bcc_emails.ToObject <List <string> >(), //(itemC.bcc_emails is null) ? new List<string>() : itemC.bcc_emails,
                                email_failure_count = (string)itemC.email_failure_count,
                                created_at          = (itemC.created_at is null) ? new DateTime() : itemC.created_at,
                                updated_at          = (itemC.updated_at is null) ? new DateTime() : itemC.updated_at,
                            };
                            await ConversationsRepository.Post(conversation, context);
                        }
                    }
                }
            }
            //return await ConversationsRepository.SelectAsync(context);
        }
Exemplo n.º 4
0
            public async Task WhenGetConversationsGetsCalled()
            {
                Setup();

                var fixture = new Fixture();

                _conversationParticipants = fixture.CreateMany <ConversationParticipant>().ToList();
                _expectedConversations    = fixture.CreateMany <Conversation>().ToList();

                ConversationsRepository.Setup(repository => repository.GetConversationParticipantsByUserId(It.IsAny <Guid>()))
                .ReturnsAsync(_conversationParticipants);
                ConversationsRepository.Setup(repository => repository.GetConversationsByIds(It.IsAny <IList <Guid> >()))
                .ReturnsAsync(_expectedConversations).Callback <IList <Guid> >(ids => _usedConversationIds = ids);

                _conversations = await ConversationsService.GetConversations(_userId);
            }
 public void ThenConversationsRepositoryGetConversationParticipantsByConversationIdShouldHaveBeenCalled()
 => ConversationsRepository.Verify(repository => repository.GetConversationParticipantsByConversationId(_conversationId), Times.Once);
 public ConversationsController()
 {
     var context = new ChatDatabaseContext();
     this.conversationsRepository = new ConversationsRepository(context);
     this.usersRepository = new UsersRepository(context);
 }
Exemplo n.º 7
0
 public void ThenConversationsRepositoryGetConversationsByIdsShouldHaveBeenCalled()
 => ConversationsRepository.Verify(
     repository =>
     repository.GetConversationsByIds(It.IsAny <IList <Guid> >()), Times.Once);
Exemplo n.º 8
0
 public void ThenConversationsRepositoryGetConversationParticipantsByUserId()
 => ConversationsRepository.Verify(repository => repository.GetConversationParticipantsByUserId(_userId),
                                   Times.Once);