public void Should_read_and_create_new_image_file()
        {
            File.Delete(StoreFile);

            if (Directory.Exists(TargetDir))
            {
                Directory.Delete(TargetDir, true);
            }

            Directory.CreateDirectory(TargetDir);

            var storeFile = new HayStackStoreFile(StoreFile);

            var image1Info = SaveImage(storeFile, Path.Combine("images", Image1));

            var image2Info = SaveImage(storeFile, Path.Combine("images", Image2));

            storeFile.Close();

            var anotherStoreFile = new HayStackStoreFile(StoreFile);

            var needl1 = anotherStoreFile.Read(image1Info.Offset, image1Info.Size);

            var needl2 = anotherStoreFile.Read(image2Info.Offset, image2Info.Size);

            File.WriteAllBytes(Path.Combine(TargetDir, Image1), needl1.Data);

            File.WriteAllBytes(Path.Combine(TargetDir, Image2), needl2.Data);

            anotherStoreFile.Close();
        }
        public void Should_able_to_retrieve_with_offset()
        {
            File.Delete("photos.bin");

            var storeFile = new HayStackStoreFile("photos.bin");

            var data = new byte[10000];
            var tobesaved = new Needle
            {
                Key = 1L,
                AlternateKey = 1,
                Cookie = 1,
                Data = data,
                DataCheckSum = 1,
                DataSize = data.Length,
                Flags = 0,
                FooterMagicNumber = 0,
                HeaderMagicNumber = 0,
                Padding = 0
            };

            var offset = storeFile.Append(tobesaved);

            var needle = storeFile.Read(offset, data.Length);

            Assert.AreEqual(tobesaved.Key, needle.Key);
            Assert.AreEqual(tobesaved.AlternateKey, needle.AlternateKey);
            Assert.AreEqual(tobesaved.Cookie, needle.Cookie);
            Assert.AreEqual(tobesaved.Data.Length, needle.Data.Length);
            Assert.AreEqual(tobesaved.DataCheckSum, needle.DataCheckSum);
            Assert.AreEqual(tobesaved.DataSize, needle.DataSize);
            Assert.AreEqual(tobesaved.Flags, needle.Flags);
            Assert.AreEqual(tobesaved.FooterMagicNumber, needle.FooterMagicNumber);
            Assert.AreEqual(tobesaved.HeaderMagicNumber, needle.HeaderMagicNumber);
            Assert.AreEqual(tobesaved.Padding, needle.Padding);

            storeFile.Close();
        }