Ejemplo n.º 1
0
        public void AddAwsSecretHappyPath()
        {
            ISecret secret      = null;
            var     builderMock = new Mock <ISecretsConfigurationBuilder>();

            builderMock
            .Setup(bm => bm.AddSecret(It.IsAny <ISecret>()))
            .Callback <ISecret>(s => secret = s);

            var configurationKey  = "configurationKey";
            var secretId          = "secretId";
            var secretKey         = "secretKey";
            var awsSecretsManager = new Mock <IAmazonSecretsManager>().Object;

            builderMock.Object.AddAwsSecret(configurationKey, secretId, secretKey, awsSecretsManager);

            builderMock.Verify(bm => bm.AddSecret(It.IsAny <ISecret>()), Times.Once);

            var awsSecret = secret.Should().BeOfType <AwsSecret>().Subject;

            awsSecret.ConfigurationKey.Should().Be(configurationKey);
            awsSecret.SecretId.Should().Be(secretId);
            awsSecret.SecretKey.Should().Be(secretKey);
            awsSecret.SecretsManager.Should().BeSameAs(awsSecretsManager);
        }