Пример #1
0
        public void Commit_WithSimpleData_ShouldWorkCorrectly()
        {
            //Arrange
            var data     = Guid.NewGuid().ToByteArray();
            var capacity = data.Length;

            //Action
            IndexData indexData;

            using (var storage = new FileStorage(_storageFilePath, capacity))
            {
                indexData = storage.Append(new MemoryStream(data));
                storage.Commit();
            }

            //Assert
            using (var storage = new FileStorage(_storageFilePath, capacity))
            {
                using (var resultStream = storage.Get(indexData))
                {
                    byte[] hash1, hash2;
                    Md5Helper.ComputeHashes(data, resultStream, out hash1, out hash2);

                    Assert.IsTrue(hash1.SequenceEqual(hash2));
                }
            }
        }