示例#1
0
 public async Task WhenGetConversationsGetsCalled()
 {
     Setup();
     _createConversationRequest.SenderId   = Guid.NewGuid();
     _createConversationRequest.ReceiverId = Guid.NewGuid();
     _createConversationRequest.Content    = "Hi Bob!";
     AuthService.Setup(service => service.AuthorizeSelf(
                           It.IsAny <string>(), It.IsAny <Guid>())).Returns(false);
     _result = await ConversationsController.CreateConversation(_createConversationRequest);
 }
示例#2
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 CreateConversationReturns500WhenUnknownExceptionIsThrown()
        {
            conversationsStoreMock.Setup(store => store.AddConversation(It.IsAny <Conversation>()))
            .ThrowsAsync(new UnknownException());

            CreateConversationDto newConversation = new CreateConversationDto()
            {
                Participants = new[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }
            };

            var           conversationsController = new ConversationsController(conversationsStoreMock.Object, profileStoreMock.Object, loggerMock.Object, metricsMock.Object, notificationServiceMock.Object);
            IActionResult result = await conversationsController.CreateConversation(
                newConversation);

            TestUtils.AssertStatusCode(HttpStatusCode.InternalServerError, result);
        }
        public async Task CreateConversationReturns503WhenStorageIsUnavailable()
        {
            conversationsStoreMock.Setup(store => store.AddConversation(It.IsAny <Conversation>()))
            .ThrowsAsync(new StorageErrorException("Test Failure"));

            CreateConversationDto newConversation = new CreateConversationDto()
            {
                Participants = new[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }
            };

            var           conversationsController = new ConversationsController(conversationsStoreMock.Object, profileStoreMock.Object, loggerMock.Object, metricsMock.Object, notificationServiceMock.Object);
            IActionResult result = await conversationsController.CreateConversation(
                newConversation);

            TestUtils.AssertStatusCode(HttpStatusCode.ServiceUnavailable, result);
        }