public void ResetsStreamAfterUpdate()
 {
     using (var cell = new MemorizedCell("my-cell", new RamMnemonic()))
     {
         var content = new InputOf("its so hot outside");
         cell.Update(content);
         Assert.Equal(0, content.Stream().Position);
     }
 }
        public void CanUpdate()
        {
            var cell = new MemorizedCell("my-cell", new RamMnemonic());

            cell.Update(new InputOf("its so hot outside"));
            Assert.Equal(
                "its so hot outside",
                new TextOf(cell.Content()).AsString()
                );
        }
Beispiel #3
0
        public void DoesNotCacheOversized()
        {
            var mem   = new RamMnemonic();
            var cache = new CachedMnemonic(mem, 4);
            var cell  =
                new MemorizedCell(
                    "a/file/which/is/oversized",
                    cache
                    );

            cell.Update(new InputOf(new byte[128]));
            cell.Content();
            mem.Contents().UpdateBytes("a/file/which/is/oversized", new byte[0]);

            Assert.True(cache.Contents().Bytes("a/file/which/is/oversized", () => new byte[0]).Length == 0);
        }
Beispiel #4
0
        public void IgnoresItems()
        {
            var mem   = new RamMnemonic();
            var cache = new CachedMnemonic(mem, "a/*/blacklisted/*");
            var cell  =
                new MemorizedCell(
                    "a/file\\which/is\\blacklisted/data.dat",
                    cache
                    );

            cell.Content();
            mem.Contents()
            .UpdateBytes("a/file\\which/is\\blacklisted/data.dat", new byte[128]);

            Assert.False(cache.Contents().Knowledge().Contains("a/file\\which/is\\blacklisted/data.dat"));
        }
        public void IsCaseSensitive()
        {
            var mem = new RamMnemonic();

            using (var cell = new MemorizedCell("this-is/MY-cell", mem))
            {
                cell.Update(new InputOf("its so cold outside"));
            }
            using (var cell = new MemorizedCell(@"this-is\MY-cell", mem))
            {
                Assert.Equal(
                    "its so cold outside",
                    new TextOf(cell.Content()).AsString()
                    );
            }
        }
        public void IsInsensitiveToSeparatorChars()
        {
            var mem = new RamMnemonic();

            using (var cell = new MemorizedCell("this-is/my-cell", mem))
            {
                cell.Update(new InputOf("its so hot outside"));
            }
            using (var cell = new MemorizedCell(@"this-is\my-cell", mem))
            {
                Assert.Equal(
                    "its so hot outside",
                    new TextOf(cell.Content()).AsString()
                    );
            }
        }
        public void InitializesWithMemory()
        {
            var mem = new RamMnemonic();

            mem.Contents().UpdateBytes("my-cell", new byte[1] {
                0x02
            });

            using (var cell = new MemorizedCell("my-cell", mem))
            {
                Assert.True(
                    cell.Content()[0]
                    .Equals(0x02)
                    );
            }
        }
Beispiel #8
0
        public ICell Cell(string name)
        {
            ICell result;

            if (name.Equals("_guts.xml"))
            {
                var patch = GutsDirectives();
                result =
                    new RamCell(
                        "_guts.xml",
                        new MemoryStream(
                            new BytesOf(
                                new Xambler(patch).Dom().ToString()
                                ).AsBytes()
                            )
                        );
            }
            else
            {
                result = new MemorizedCell($"{this.name}/{name}", this.memory);
            }
            return(result);
        }