public void ResetsStreamAfterUpdate() { using (var cell = new RamCell("my-cell")) { var content = new InputOf("its so hot outside"); cell.Update(content); Assert.Equal(0, content.Stream().Position); } }
public void CanUpdate() { using (var cell = new RamCell("my-cell")) { cell.Update(new InputOf("its so hot outside")); Assert.Equal( "its so hot outside", new TextOf(cell.Content()).AsString() ); } }
public void WorksWithRamCell() { var cell = new RamCell(); var gate = new LocalSyncPipe(); var synced = new SyncCell(cell, gate); synced.Update(new InputOf("its so hot outside")); Assert.Equal( "its so hot outside", new TextOf(synced.Content()).AsString() ); }
public void InitializesWithMemory() { using (var cell = new RamCell("my-cell", new MemoryStream(new byte[1] { 0x00 }))) { Assert.True( cell.Content()[0] .Equals(0x00) ); } }
public void IsThreadsaveWithDifferentCells() { Parallel.For(0, Environment.ProcessorCount << 4, i => { var cell = new RamCell(); cell.Update(new InputOf("my input")); Assert.Equal( "my input", new TextOf( cell.Content() ).AsString() ); }); }
public void DoesNotBlockItself() { var cell = new RamCell(); var gate = new LocalSyncPipe(); Parallel.For(0, Environment.ProcessorCount << 4, (current) => { var content = "ABC"; var first = new SyncCell(cell, gate); first.Update(new InputOf(content)); var again = new SyncCell(cell, gate); again.Update(new InputOf(content)); var andAgain = new SyncCell(cell, gate); andAgain.Update(new InputOf(content)); System.Threading.Thread.Sleep(1); Assert.Equal( "ABC ABC ABC", $"{new TextOf(first.Content()).AsString()} {new TextOf(again.Content()).AsString()} {new TextOf(andAgain.Content()).AsString()}" ); }); }
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); }