public void HealthyCellConstructorSetsDefaultParameters( ICellVisitor visitor, HealthyCell sut) { sut.Accept(visitor); VerifyHealhyCellWithDefault(visitor); }
public (ConsoleColor, string) GetColorEncodedCell(ICell cell) { (_colorCode, _currentCellCode) = cell switch { InfectedCell _ => (ConsoleColor.Red, "I"), HealthyCell _ => (ConsoleColor.Green, "C"), _ => (ConsoleColor.DarkYellow, string.Empty) }; cell?.Accept(this); return(_colorCode, _currentCellCode); }
public string GetEncodedCell(ICell cell) { _currentCellCode = cell switch { InfectedCell _ => "I", HealthyCell _ => "C", _ => string.Empty }; cell?.Accept(this); return(_currentCellCode); }
internal void VirusCanInfectHealthyCellsInOneOutOfTenTimes( HealthyCell cellToInfect, LyticVirus sut) { var result = new List <ICell>(); var numberOfTries = (int)Ceiling(InfectionFailureRate * 3 * 10); for (int currentTry = 0; currentTry < numberOfTries; currentTry++) { result.Add(sut.InfectCell(cellToInfect).Clone()); } VerifyAtLeastOneCellGotInfected(result); }
public void HealthyCellCloneCreatesNewCellWithSameParametersAsParentCell( ICellVisitor visitsParent, ICellVisitor visitsClone, HealthyCell sut) { sut.Accept(visitsParent); var newCell = sut.Clone(); newCell.Accept(visitsClone); newCell.Should().NotBeSameAs(sut); VerifyHealhyCellWithDefault(visitsParent); VerifyHealhyCellWithDefault(visitsClone); }
public Tissue2D Advance(Tissue2D input) { var result = ImmutableDictionary <Location, ICell> .Empty; foreach ((Location location, ICell cell) in input.Tissue) { result = cell switch { NullCell _ => result.Add(location, GrowTissue(input, location)), InfectedCell currentCell => result.Add(location, PropagateInfection(location, currentCell)), HealthyCell currentCell => result.Add(location, PropagateInfection(location, currentCell)), _ => result.Add(location, cell.Clone()) } } ; return(new Tissue2D(result)); }