예제 #1
0
        public void GivenATypedCollectionAndAnUnexistingId_ConcurrencyUpdateThrows_MongoConcurrencyDeletedException()
        {
            var initialObject = GetInitialObject();

            Executing.This(() => TypedCollection.Optimistic().Update(initialObject))
            .Should().Throw <MongoConcurrencyDeletedException>();
        }
예제 #2
0
        public void GivenATntypedCollectionAndAnInvalidVersion_TheObjectCanBeDeleted()
        {
            var initialObject = SaveInitialObject(UnTypedCollection);

            initialObject.Version = 32;

            Executing.This(() => TypedCollection.Optimistic().Remove(initialObject))
            .Should().Throw <MongoConcurrencyUpdatedException>();
        }
예제 #3
0
        public void GivenATntypedCollectionAndAnInvalidVersion_ConcurrencyUpdateThrows_MongoConcurrencyUpdatedException()
        {
            var initialObject = SaveInitialObject(TypedCollection);

            initialObject.Age     = 30;
            initialObject.Version = 8;

            Executing.This(() => TypedCollection.Optimistic().Update(initialObject))
            .Should().Throw <MongoConcurrencyUpdatedException>();
        }
예제 #4
0
        public EntityRef New()
        {
            var components = new TypedCollection <IComponent>();

            while (true)
            {
                var entity = new Entity(unchecked (_entityIdCounter++));
                if (!_entities.TryAdd(entity, components).HasValue)
                {
                    return(new EntityRef(this, entity));
                }
            }
        }