public async Task WhenAadConnectionString_InjectsSecrets(bool shouldOpen)
            {
                // Arrange
                var factory = new MockFactory(MockConnectionStrings.AadSqlConnectionString);

                // Act
                var connection = await ConnectAsync(factory, shouldOpen);

                // Assert
                factory.MockSecretReader.Verify(x => x.GetSecretAsync("cert"), Times.Once);

                // Note that AAD keys are extracted for internal use only
                Assert.True(connection.ConnectionString.Equals(
                                $"{MockConnectionStrings.BaseConnectionString}", StringComparison.InvariantCultureIgnoreCase));

                Assert.Equal(shouldOpen, factory.Opened);
            }
            public async Task WhenSqlConnectionString_InjectsSecrets(bool shouldOpen)
            {
                // Arrange
                var factory = new MockFactory(MockConnectionStrings.SqlConnectionString);

                // Act
                var connection = await ConnectAsync(factory, shouldOpen);

                // Assert
                factory.MockSecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Exactly(2));
                factory.MockSecretReader.Verify(x => x.GetSecretAsync("user"), Times.Once);
                factory.MockSecretReader.Verify(x => x.GetSecretAsync("pass"), Times.Once);

                Assert.True(connection.ConnectionString.Equals(
                                $"{MockConnectionStrings.BaseConnectionString};User ID=user;Password=pass", StringComparison.InvariantCultureIgnoreCase));

                Assert.Equal(shouldOpen, factory.Opened);
            }
 private Task <SqlConnection> ConnectAsync(MockFactory factory, bool shouldOpen)
 {
     return(shouldOpen ? factory.OpenAsync() : factory.CreateAsync());
 }