public void SkipsMissingS3Bucket()
        {
            // Arrange
            Guid profileId = Guid.NewGuid();
            var  profile   = new AwsProfile {
                Id = profileId, DetailedBillingS3Bucket = null
            };

            AwsProfileRepositoryMock.Setup(x => x.Find(profileId)).Returns(profile);
            var command = new UpdateBillingData(AwsClientFactory, AwsProfileRepository, BillingManager, Clock, new S3PathParser());

            // Act
            command.LoadDeltas(profileId);

            // Assert
            AwsProfileRepositoryMock.Verify(x => x.Update(It.IsAny <AwsProfile>()), Times.Never);
        }
        public void SetsLastModified()
        {
            // Arrange
            Guid profileId = Guid.NewGuid();
            var  profile   = new AwsProfile
            {
                Id = profileId,
                DetailedBillingS3Bucket = "my-bucket",
                IsBillingHistoryLoaded  = true,
                Account = "12345",
            };

            AwsProfileRepositoryMock.Setup(x => x.Find(profileId)).Returns(profile);
            AwsClientFactoryMock.Setup(x => x.GetClient(profile)).Returns(AwsClientMock.Object);

            var now = new DateTime(2014, 6, 14, 16, 15, 14, DateTimeKind.Utc);

            ClockMock.Setup(x => x.UtcNow).Returns(now);

            var storage = new TestStorageService();

            AwsClientMock.Setup(x => x.StorageService).Returns(storage);
            storage.NewLastModified = new DateTime(2020, 1, 1, 1, 1, 1, DateTimeKind.Utc);
            storage.Contents        = new MemoryStream(Resources.LineItemsZip);

            var command = new UpdateBillingData(AwsClientFactory, AwsProfileRepository, BillingManager, Clock, new S3PathParser());

            // Act
            command.LoadDeltas(profileId);

            // Assert
            AwsProfileRepositoryMock.Verify(
                x => x.Update(It.Is((AwsProfile p) =>
                                    p.Id == profileId &&
                                    p.BillingMetadata["2014-06"].LastModified == storage.NewLastModified)
                              ));
        }