Exemplo n.º 1
0
        public void S3Service_AmazonClient_IsPassed_Correct_Request()
        {
            // Arrange
            var mockAmazonClient = Substitute.For <IAmazonS3>();
            var s3Service        = new S3Service(mockAmazonClient);

            mockAmazonClient.GetObjectAsync(Arg.Any <GetObjectRequest>()).Returns(new GetObjectResponse());
            var expectedRequest = new GetObjectRequest
            {
                BucketName = "webapp-images-bucket",
                Key        = "DenverCP.jpg"
            };

            // Act
            // only testing what's passed to the client and not making actual request
            // so doesn't need to be awaited
            s3Service.GetImageFromS3(_configuration, "DenverImage");

            // Assert
            mockAmazonClient
            .Received(1)
            .GetObjectAsync(Arg.Is <GetObjectRequest>(request => RequestDataPropertiesMatch(request, expectedRequest)));
        }