Ejemplo n.º 1
0
            public async Task WhenGetConversationParticipantsGetsCalled()
            {
                Setup();

                AuthService.Setup(service => service.GetUserIdFromToken(It.IsAny <string>())).Returns(_userId.ToString());
                ConversationsService.Setup(service => service.GetConversationParticipants(It.IsAny <Guid>()))
                .ReturnsAsync(new Fixture().CreateMany <Guid>().ToList());

                _result = await ConversationsController.GetConversationParticipants(_conversationId);
            }
Ejemplo n.º 2
0
            public async Task WhenGetConversationsGetsCalled()
            {
                Setup();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                ConversationsService.Setup(service => service.GetConversations(It.IsAny <Guid>()))
                .ReturnsAsync(new List <Conversation>());

                _result = await ConversationsController.GetConversations(_userId);
            }
Ejemplo n.º 3
0
            public async Task WhenCreateConversationGetsCalled()
            {
                Setup();

                AuthService.Setup(service => service.AuthorizeSelf(
                                      It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                ConversationsService.Setup(service => service.CreateConversationWithParticipants(
                                               _createConversationRequest.SenderId, _createConversationRequest.ReceiverId))
                .ReturnsAsync(_conversationId);

                _result = await ConversationsController.CreateConversation(_createConversationRequest);
            }
            public async Task WhenGetConversationParticipantsGetsCalled()
            {
                Setup();

                var fixture = new Fixture();

                _conversationParticipants = fixture.CreateMany <Guid>().ToList();
                _messages = fixture.CreateMany <Message>().ToList();
                _userId   = _conversationParticipants.Last();

                AuthService.Setup(service => service.GetUserIdFromToken(It.IsAny <string>())).Returns(_userId.ToString());
                ConversationsService.Setup(service => service.GetConversationParticipants(It.IsAny <Guid>()))
                .ReturnsAsync(_conversationParticipants);
                MessagesService.Setup(service => service.GetMessagesFromConversation(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <int>()))
                .ReturnsAsync(_messages);

                _result = await MessagesController.GetMessagesFromConversation(_conversationId);
            }
Ejemplo n.º 5
0
            public async Task WhenCreateMessageGetsCalled()
            {
                Setup();

                var fixture = new Fixture();

                _conversationParticipants = fixture.CreateMany <Guid>().ToList();
                _createMessageRequest     = fixture.Build <CreateMessageRequest>()
                                            .With(request => request.SenderId, _conversationParticipants.Last())
                                            .Create();

                AuthService.Setup(service => service.GetUserIdFromToken(It.IsAny <string>())).Returns(_createMessageRequest.SenderId.ToString());
                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>()))
                .Returns(true);
                ConversationsService.Setup(service => service.GetConversationParticipants(It.IsAny <Guid>()))
                .ReturnsAsync(_conversationParticipants);
                MessagesService.Setup(repository => repository.CreateMessage(It.IsAny <Message>()))
                .Callback <Message>(msg => _usedMessage = msg);

                _result = await MessagesController.CreateMessage(_createMessageRequest);
            }