Ejemplo n.º 1
0
        public async void GetIssuesDoesNotConsumeException()
        {
            // Arrange
            var restServiceMoq = new Mock<IRestService>();
            restServiceMoq.Setup(moq => moq.GetAsync(_restRequest, It.IsAny<CancellationToken>()))
                .Throws(new Exception(RestServiceExceptionMessage));

            var issueService = new IssueService(restServiceMoq.Object, _gitApiProvider);

            // Act
            await issueService.GetIssuesAsync(It.IsAny<string>(), CancellationToken.None);

            // Assert
        }
Ejemplo n.º 2
0
        public async void GetIssuesCallsIRestService()
        {
            // Arrange
            var issuesList = new List<IIssue>();

            var restServiceMoq = new Mock<IRestService>();
            restServiceMoq.Setup(moq => moq.GetAsync(_restRequest, It.IsAny<CancellationToken>()))
                .ReturnsAsync(issuesList);

            var issueService = new IssueService(restServiceMoq.Object, _gitApiProvider);

            // Act
            var issues = await issueService.GetIssuesAsync(It.IsAny<string>(), CancellationToken.None);

            // Assert
            Mock.Get(_gitApiProvider).Verify(moq => moq.GetIssuesRequest(It.IsAny<string>()), Times.Once);

            restServiceMoq.Verify(moq => moq.GetAsync(_restRequest, It.IsAny<CancellationToken>()),
                Times.Once);

            Assert.AreEqual(issues, issuesList);
        }