public void enqueues_can_come_from_multiple_consumers()
        {
            const int trials = 100;
            int[] count = { 0 };
            var block = new ManualResetEvent(false);

            for (var i = 0; i < trials; i++)
            {
                ThreadPool.QueueUserWorkItem(
                    s =>
                    {
                        var writer = new TransactionFileWriter<object>(Filename, new BinaryFormatter());
                        writer.Enqueue(new object());
                        Interlocked.Increment(ref count[0]);
                        if (count[0] == trials)
                        {
                            block.Set();
                        }
                    });
            }
            block.WaitOne();

            var checksum = new FileChecksum(Filename + ".write.chk");
            Assert.GreaterOrEqual(checksum.GetValue(), 4100, "Final writer checksum for the message content did not match expectations");
        }
        public FileChecksumFixture(string filename)
        {
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            Checksum = new FileChecksum(filename);
        }
        public void using_an_empty_existing_file_resets_file_properly()
        {
            const string filename = "empty_existing_file_is_reset_properly";
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            File.CreateText(filename).Dispose();
            Assert.IsTrue(File.Exists(filename), "Empty file was not created");
            Assert.AreEqual(0, new FileInfo(filename).Length, "Empty file was not empty");

            var checksum = new FileChecksum(filename);
            Assert.IsNotNull(checksum);
            Assert.AreEqual(0, checksum.GetValue(), "Empty file used as checksum base did not get default value");
        }