示例#1
0
 public async Task GetConversationsReturns503IfStorageUnavailable()
 {
     mockStore.Setup(store => store.GetConversations(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), 50))
     .ThrowsAsync(new StorageUnavailableException("Storage is unavailable!"));
     TestUtils.AssertStatusCode(HttpStatusCode.ServiceUnavailable,
                                await myController.GetConversations("amansour", "11", "11", 50));
 }
示例#2
0
            public async Task WhenGetConversationsGetsCalled()
            {
                Setup();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(false);

                _result = await ConversationsController.GetConversations(_userId);
            }
        public async Task GetConversationsReturns500WhenExceptionIsNotKnown()
        {
            var conversationsServiceMock = new Mock <IConversationsService>();

            conversationsServiceMock.Setup(store => store.GetConversations(_testUsername, _testContinuationToken, _testLimit, _lastSeenTime)).ThrowsAsync(new Exception("Test Exception"));

            var           loggerStub = new ConversationsControllerLoggerStub();
            var           controller = new ConversationsController(conversationsServiceMock.Object, loggerStub, new TelemetryClient());
            IActionResult result     = await controller.GetConversations(_testUsername, _testContinuationToken, _testLimit, _lastSeenTime);

            AssertUtils.HasStatusCode(HttpStatusCode.InternalServerError, result);
            Assert.Contains(LogLevel.Error, loggerStub.LogEntries.Select(entry => entry.Level));
        }