Exemplo n.º 1
0
        public void TestOpenContentStreamRead()
        {
            // Arrange
            var testContent = new byte[] {
                0, 1, 2, 3, 4, 5
            };
            Hash expectedContentHash       = Hash.Compute(testContent);
            var  testContentStream         = new MemoryStream(testContent);
            IContentAddressableStore store = ContentAddressableStoreFactory.CreateLocalContentAddressableStore("TestData");

            // Act
            Hash contentHash = store.AddContent(testContentStream);

            byte[] contentFromStore;
            Stream contentStream = store.OpenContentStreamRead(contentHash);

            using (BinaryReader reader = new BinaryReader(contentStream))
            {
                contentFromStore = reader.ReadBytes((int)contentStream.Length);
            }

            // Assert
            Assert.AreEqual(contentHash, expectedContentHash);
            Assert.IsTrue(testContent.SequenceEqual(contentFromStore));
        }
Exemplo n.º 2
0
        public void TestAddContent()
        {
            // Arrange
            var testContent = new byte[] {
                0, 1, 2, 3, 4, 5
            };
            Hash expectedContentHash       = Hash.Compute(testContent);
            var  testContentStream         = new MemoryStream(testContent);
            IContentAddressableStore store = ContentAddressableStoreFactory.CreateLocalContentAddressableStore("TestData");

            // Act
            Hash contentHash = store.AddContent(testContentStream);

            // Assert
            Assert.AreEqual(contentHash, expectedContentHash);
        }