コード例 #1
0
        private SampleEntityWithIntId GetNewEntity()
        {
            var IdValueCounter = 0;

            var sampleEntityWithIntId = new SampleEntityWithIntId()
            {
                Id         = IdValueCounter++,                 // Cheap and nasty autoincrement for INT Id values - Should use an autoincrement key generator and assign it to the BSON serializer, etc..
                EntityName = "New Entity with INT Id"
            };

            return(sampleEntityWithIntId);
        }
コード例 #2
0
        public async Task Test_that_two_records_can_be_added_into_the_collection_with_consecutive_id_values()
        {
            var entity1 = new SampleEntityWithIntId()
            {
                EntityName = "Entity #1"
            };
            var entity2 = new SampleEntityWithIntId()
            {
                EntityName = "Entity #2"
            };

            var entity1Id = await TheSampleRepositoryWithIntId.AddOneAsync(entity1);

            var entity2Id = await TheSampleRepositoryWithIntId.AddOneAsync(entity2);

            Assert.That(entity1Id, Is.Not.Null);
            Assert.That(entity1Id, Is.TypeOf <int>());
            Assert.That(entity2Id, Is.Not.Null);
            Assert.That(entity2Id, Is.TypeOf <int>());
            Assert.That(entity2Id, Is.EqualTo(entity1Id + 1));
        }