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 WorksWithFileCell() { using (var file = new TempFile()) { var path = file.Value(); var gate = new LocalSyncPipe(); Parallel.For(0, Environment.ProcessorCount << 4, (current) => { var cell = new SyncCell(new FileCell(path), gate); cell.Update(new InputOf("File cell Input")); Assert.Equal("File cell 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()}" ); }); }