public async Task GivenARegistryInitializer_WhenDatabaseIsNew_SearchParametersShouldBeUpserted() { ICosmosQuery <dynamic> cosmosQuery = Substitute.For <ICosmosQuery <dynamic> >(); _cosmosDocumentQueryFactory.Create <dynamic>(Arg.Any <Container>(), Arg.Any <CosmosQueryContext>()) .Returns(cosmosQuery); cosmosQuery .ExecuteNextAsync() .Returns(Substitute.ForPartsOf <FeedResponse <dynamic> >()); Container container = Substitute.For <Container>(); await _initializer.ExecuteAsync(container); container.Received().CreateTransactionalBatch(Arg.Any <PartitionKey>()); }
public async Task GivenARegistryInitializer_WhenDatabaseIsNew_SearchParametersShouldBeUpserted() { IDocumentQuery <dynamic> documentQuery = Substitute.For <IDocumentQuery <dynamic> >(); _cosmosDocumentQueryFactory.Create <dynamic>(Arg.Any <IDocumentClient>(), Arg.Any <CosmosQueryContext>()) .Returns(documentQuery); documentQuery .ExecuteNextAsync() .Returns(new FeedResponse <dynamic>(new dynamic[0])); IDocumentClient documentClient = Substitute.For <IDocumentClient>(); var relativeCollectionUri = new Uri("/collection1", UriKind.Relative); await _initializer.ExecuteAsync(documentClient, new DocumentCollection(), relativeCollectionUri); await documentClient.Received().UpsertDocumentAsync( relativeCollectionUri, Arg.Is <SearchParameterStatusWrapper>(x => x.Uri == _testParameterUri)); }