コード例 #1
0
ファイル: Q1Tests.cs プロジェクト: marmalade/bsp4Airplay
        //[Test]
        public void TestQ1Demo()
        {
            var res = new DemoDocument();

            using (var f = File.OpenRead(@"..\data\demos\demo1.dem"))
            {
                using (var b = new BinaryReader(f))
                {
                    (new Quake1DemoReader()).ReadDemo(b,res);
                }
            }
        }
コード例 #2
0
        public void ReadDemo(BinaryReader source, DemoDocument dest)
        {
            fileStartAt = source.BaseStream.Position;
            ReadHeader(source);

            ReadEntries(source);

            foreach (var de in direntries)
            {
                source.BaseStream.Seek(fileStartAt + de.offset, SeekOrigin.Begin);
                ReadEvents(source,de);
            }
        }
コード例 #3
0
        public void ConcurrentDeletes(string storage)
        {
            var store = NewDocumentStore(false, storage);

            var document = new DemoDocument();
            using (var session = store.OpenSession())
            {
                session.Store(document);
                session.SaveChanges();
            }

            var documentLoaded = new CountdownEvent(2);
            var documentDeleted = new CountdownEvent(2);

            var t1 = Task.Run(() => DeleteDocument(store, document.Id, documentLoaded, documentDeleted));
            var t2 = Task.Run(() => DeleteDocument(store, document.Id, documentLoaded, documentDeleted));

            Assert.True(t1.Result | t2.Result, "the document should be deleted");
            Assert.False(t1.Result && t2.Result, "only one operation should complete successfully");
        }
コード例 #4
0
        public void ConcurrentDeletesWithDtc()
        {
            var store = NewDocumentStore(false, "esent");
            EnsureDtcIsSupported(store);

            var document = new DemoDocument();
            using (var session = store.OpenSession())
            {
                session.Store(document);
                session.SaveChanges();
            }

            var documentLoaded = new CountdownEvent(2);
            var documentDeleted = new CountdownEvent(2);

            var t1 = Task.Run(() =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    var result = DeleteDocument(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            var t2 = Task.Run(() =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    var result = DeleteDocument(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            Assert.True(t1.Result | t2.Result, "the document should be deleted");
            Assert.False(t1.Result && t2.Result, "only one operation should complete successfully");
        }
コード例 #5
0
        public async Task ConcurrentDeletesWithDtcAsync()
        {
            var store = CreateStore();

            var document = new DemoDocument();
            using (var session = store.OpenAsyncSession())
            {
                await session.StoreAsync(document);
                await session.SaveChangesAsync();
            }

            var documentLoaded = new CountdownEvent(2);
            var documentDeleted = new CountdownEvent(2);

            var t1 = Task.Run(async () =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var result = await DeleteDocumentAsync(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            var t2 = Task.Run(async () =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var result = await DeleteDocumentAsync(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            Assert.IsTrue(t1.Result | t2.Result, "the document should be deleted");
            Assert.IsFalse(t1.Result && t2.Result, "only one operation should complete successfully");
        }
コード例 #6
0
 public void ReadDemo(System.IO.BinaryReader source, DemoDocument dest)
 {
     ReadCDTrack(source);
     ParseBlocks(source);
 }
        public async Task Raven_WhenConcurrentDeletesWithDtc_ShouldThrowConcurrencyException()
        {
            // Raven does not throw ConcurrencyExceptions when concurrently deleting documents without using DTC.
            // When using DTC we need to rely on Raven throwing this exception to avoid dispatching duplicate messages.
            // See issue http://issues.hibernatingrhinos.com/issue/RavenDB-4000

            var document = new DemoDocument();
            using (var session = store.OpenAsyncSession())
            {
                await session.StoreAsync(document);
                await session.SaveChangesAsync();
            }

            var documentLoaded = new CountdownEvent(2);
            var documentDeleted = new CountdownEvent(2);

            var t1 = Task.Run(async () =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var result = await TryDeleteDocumentAsync(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            var t2 = Task.Run(async () =>
            {
                using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var result = await TryDeleteDocumentAsync(store, document.Id, documentLoaded, documentDeleted);
                    tx.Complete();
                    return result;
                }
            });

            Assert.IsTrue(await t1 | await t2, "the document should be deleted");
            Assert.IsFalse(t1.Result && t2.Result, "only one operation should complete successfully");
        }