public async Task CreateIfNotExists_Creates_IfTrue()
        {
            // Arrange
            string databaseName   = "TestDB";
            string collectionName = "TestCollection";

            var databaseUri = UriFactory.CreateDatabaseUri(databaseName);

            var mockService = new Mock <IDocumentDBService>(MockBehavior.Strict);

            mockService
            .Setup(m => m.CreateDatabaseAsync(It.Is <Database>(d => d.Id == databaseName)))
            .ReturnsAsync(new Database());

            mockService
            .Setup(m => m.CreateDocumentCollectionAsync(databaseUri, It.Is <DocumentCollection>(d => d.Id == collectionName)))
            .ReturnsAsync(new DocumentCollection());

            var config = new DocumentDBConfiguration
            {
                ConnectionString         = "AccountEndpoint=http://someuri;AccountKey=some_key",
                DocumentDBServiceFactory = new TestDocumentDBServiceFactory(mockService.Object)
            };

            var provider = new DocumentDBAttributeBindingProvider(new JobHostConfiguration(), config);

            // Act
            await provider.TryCreateAsync(new BindingProviderContext(GetCreateIfNotExistsParameters().Last(), null, CancellationToken.None));

            // Assert
            mockService.VerifyAll();
        }
        private static Task <IBinding> CreateProviderAndTryCreateAsync(ParameterInfo parameter)
        {
            var jobConfig   = new JobHostConfiguration();
            var docDBConfig = new DocumentDBConfiguration
            {
                ConnectionString = "AccountEndpoint=https://someuri;AccountKey=my_key"
            };
            var provider = new DocumentDBAttributeBindingProvider(jobConfig, docDBConfig);

            var context = new BindingProviderContext(parameter, null, CancellationToken.None);

            return(provider.TryCreateAsync(context));
        }
        public async Task CreateIfNotExists_DoesNotCreate_IfFalse()
        {
            // Arrange
            var mockService = new Mock <IDocumentDBService>(MockBehavior.Strict);
            var config      = new DocumentDBConfiguration
            {
                ConnectionString         = "AccountEndpoint=http://someuri;AccountKey=some_key",
                DocumentDBServiceFactory = new TestDocumentDBServiceFactory(mockService.Object)
            };
            var attribute = new DocumentDBAttribute {
                CreateIfNotExists = false
            };
            var provider = new DocumentDBAttributeBindingProvider(new JobHostConfiguration(), config);

            // Act
            await provider.TryCreateAsync(new BindingProviderContext(GetCreateIfNotExistsParameters().First(), null, CancellationToken.None));

            // Assert
            // Nothing to assert. Since the service was null, it was never called.
        }