Example #1
0
        public MongoDbTest()
        {
            var db = new MongoDb(ConnectionString, DatabaseId);

            db.DeleteCollection(NewCollectionId).Wait();
            db.DeleteCollection(CollectionId).Wait();
            db.CreateCollection(CollectionId).Wait();
        }
 public static void AddSalesProductReportsFromFilesToDatabase(IEnumerable<ProductReportClass> reports)
 {
     var db = new MongoDb("MarketSystem");
     db.CreateCollection<ProductReportClass>("SaleProducts");
     foreach (var report in reports)
     {
         db.Collections["SaleProducts"].Insert(report);
     }
 }
Example #3
0
        public async Task CreateCollection_NullCollectionId_ThrowsException(string collectionId)
        {
            // Arrange
            var db = new MongoDb(ConnectionString, DatabaseId);

            // Act
            var exception = await Record.ExceptionAsync(() => db.CreateCollection(collectionId));

            // Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentNullException>();
        }
Example #4
0
        public async Task CreateCollection_NewCollectionNameProvided_NewCollectionCreated()
        {
            // Arrange
            var db = new MongoDb(ConnectionString, DatabaseId);

            // Act
            await db.CreateCollection(NewCollectionId);

            // Assert
            var exists = await db.CollectionExists(NewCollectionId);

            exists.Should().BeTrue();
        }