コード例 #1
0
        public async Task PublishActor_SendSqsMessage()
        {
            var actor = new Actor {
                FirstName = "Bruce", LastName = "Willis"
            };
            var response = await PublishClient.PublishActor(actor);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            SqsClientMock.Verify(x => x.PostMessageAsync(
                                     It.Is <Actor>(y => JsonConvert.SerializeObject(y) == JsonConvert.SerializeObject(actor))), Times.Once);
        }
コード例 #2
0
        public async Task PublishMovie_SendSqsMessage()
        {
            var movie = new Movie {
                Title = "Die hard", Genre = MovieGenre.Action
            };
            var response = await PublishClient.PublishMovie(movie);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            SqsClientMock.Verify(x => x.PostMessageAsync(
                                     It.Is <Movie>(y => JsonConvert.SerializeObject(y) == JsonConvert.SerializeObject(movie))), Times.Once);
        }
コード例 #3
0
        public async Task GetHealthReport_ReturnsUnhealthy()
        {
            SqsClientMock.Setup(x => x.GetQueueStatusAsync())
            .ReturnsAsync(new SqsStatus {
                IsHealthy = false
            });

            var response = await HealthCheckClient.GetHealth();

            Assert.AreEqual(HttpStatusCode.ServiceUnavailable, response.StatusCode);
            Assert.AreEqual("Unhealthy", response.Result.Status);
        }
コード例 #4
0
        public async Task GetHealthReport_ReturnsHealthy()
        {
            SqsClientMock.Setup(x => x.GetQueueStatusAsync())
            .ReturnsAsync(new SqsStatus {
                IsHealthy = true
            });

            var response = await HealthCheckClient.GetHealth();

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal("Healthy", response.Result.Status);
        }
コード例 #5
0
        public async Task GetHealthReport_ReturnsHealthy()
        {
            //#if (AddSqsPublisher || AddSqsConsumer)
            SqsClientMock.Setup(x => x.GetQueueStatusAsync())
            .ReturnsAsync(new SqsStatus {
                IsHealthy = true
            });

            //#endif
            var response = await HealthCheckClient.GetHealth();

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("Healthy", response.Result.Status);
        }
コード例 #6
0
 public void TestCleanup()
 {
     SqsClientMock.Verify(x => x.CreateQueueAsync(), Times.Once);
     SqsClientMock.VerifyNoOtherCalls();
 }
コード例 #7
0
 public void TestInitialize()
 {
     SqsClientMock.Setup(x => x.GetMessagesAsync(It.IsAny <CancellationToken>()))
     .ReturnsAsync(new List <Message>());
 }