public OperationTestBase()
 {
     _databaseNamespace      = CoreTestConfiguration.DatabaseNamespace;
     _collectionNamespace    = CoreTestConfiguration.GetCollectionNamespaceForTestClass(GetType());
     _messageEncoderSettings = CoreTestConfiguration.MessageEncoderSettings;
     _session = CoreTestConfiguration.StartSession();
 }
        public void InsertOne_to_oftype_collection_should_generate_id()
        {
            var collectionNamespace = CoreTestConfiguration.GetCollectionNamespaceForTestClass(typeof(CSharp2622Tests));
            var databaseName        = collectionNamespace.DatabaseNamespace.DatabaseName;
            var collectionName      = collectionNamespace.CollectionName;
            var client           = DriverTestConfiguration.Client;
            var database         = client.GetDatabase(databaseName);
            var collection       = database.GetCollection <C>(collectionName);
            var ofTypeCollection = collection.OfType <D>();

            database.DropCollection(collectionName);
            var document = new D {
                X = 1
            };

            ofTypeCollection.InsertOne(document);

            var insertedDocuments = collection.FindSync("{}").ToList();

            insertedDocuments.Count.Should().Be(1);
            insertedDocuments[0].Should().BeOfType <D>();
            var insertedDocument = (D)insertedDocuments[0];

            insertedDocument.Id.Should().NotBe(ObjectId.Empty);
            insertedDocument.X.Should().Be(1);
        }
Esempio n. 3
0
 // constructor
 public DropCollectionOperationTests()
 {
     _collectionNamespace    = CoreTestConfiguration.GetCollectionNamespaceForTestClass(typeof(DropCollectionOperationTests));
     _messageEncoderSettings = CoreTestConfiguration.MessageEncoderSettings;
 }