コード例 #1
0
        public void ShouldNotReadKeyfileIfKeyIsInPath()
        {
            var key           = 1L;
            var filesystem    = new MemoryFileSystem();
            var options       = new FilesystemStorageOptions();
            var mockFormatter = new Mock <IFormatter <BinaryReader, BinaryWriter> >();

            var entityIO = new FilesystemEntityReaderWriter <long, BinaryReader, BinaryWriter>(
                filesystem,
                mockFormatter.Object,
                options
                );

            using (var stream = entityIO.BeginWrite(key)) stream.Write("mock");
            Assert.True(entityIO.Exists(key));
            var keys = entityIO.GetAllKeys();

            Assert.Contains(key, keys);
            Assert.Single(keys);

            mockFormatter.Verify(mock => mock.Deserialize(
                                     It.IsAny <Type>(),
                                     It.IsAny <BinaryReader>(),
                                     null
                                     ), Times.Never());
        }
コード例 #2
0
 private void WriteSampleStringData(long key, string data = "some data")
 {
     using (var stream = entityIO.BeginWrite(key)) stream.Write(data);
 }