Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

29 linhas
1.2 KiB

  1. using FluentAssertions;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using MongoDB.Bson;
  4. using MongoDB.Driver;
  5. using Xunit;
  6. namespace DotNetCore.CAP.MongoDB.Test
  7. {
  8. [Collection("MongoDB")]
  9. public class MongoDBStorageTest : DatabaseTestHost
  10. {
  11. [Fact]
  12. public void InitializeAsync_Test()
  13. {
  14. var storage = Provider.GetService<MongoDBStorage>();
  15. var names = MongoClient.ListDatabaseNames()?.ToList();
  16. names.Should().Contain(MongoDBOptions.DatabaseName);
  17. var collections = Database.ListCollectionNames()?.ToList();
  18. collections.Should().Contain(MongoDBOptions.PublishedCollection);
  19. collections.Should().Contain(MongoDBOptions.ReceivedCollection);
  20. collections.Should().Contain(MongoDBOptions.CounterCollection);
  21. var collection = Database.GetCollection<BsonDocument>(MongoDBOptions.CounterCollection);
  22. collection.CountDocuments(new BsonDocument { { "_id", MongoDBOptions.PublishedCollection } }).Should().Be(1);
  23. collection.CountDocuments(new BsonDocument { { "_id", MongoDBOptions.ReceivedCollection } }).Should().Be(1);
  24. }
  25. }
  26. }