private void VerifyGermIsMature(IGermVistor vistor, IGerm matureVirus) { matureVirus.Accept(vistor); bool isMature = true; VerifyGerm(isMature, vistor); }
public InfectedCell(bool isAlive, ushort selfSignal, ushort alertSignal, IGerm germ) { _isAlive = isAlive; _selfSignal = selfSignal; _alertSignal = alertSignal; _germ = germ ?? throw new ArgumentNullException(nameof(germ)); }
private HealthyCell(bool isAlive, ushort selfSignal, ushort alertSignal) { _isAlive = isAlive; _selfSignal = selfSignal; _alertSignal = alertSignal; _germ = new NullGerm(); }
public HealthyCell() { _isAlive = true; _selfSignal = ushort.MaxValue; _alertSignal = ushort.MinValue; _germ = new NullGerm(); }
internal void CloningADeadCellDoesNotReplicateTheGermAndReturnsNullCellButAL( [Frozen] IGerm germ, DeadInfectedCell sut) { var result = sut.Clone(); result.Should().BeOfType <NullCell>(); VerifyTimesGermReplicatIsCalled(0, germ); }
internal void InfectedCellIsConstructedWithCorrectAttributes( [Frozen] IGerm germ, [Frozen] ushort signals, [Frozen] bool isAlive, ICellVisitor visitor, InfectedCell sut) { sut.Accept(visitor); VerifyCellExposesCorrectParametersToVisitor(signals, isAlive, visitor); }
private ICell InfectCell(ICell cell, IGerm germ) { if (_random.NextDouble() <= ChanceToEncounterACell) { PublishCellInfection(); return(germ.InfectCell(cell)); } return(cell.Clone()); }
internal void CloningALivingCellDoesReplicatesTheGermAndReturnsInfectedCell( [Frozen] IGerm germ, [Frozen] ushort signals, [Frozen] ICellVisitor visitor, LivingInfectedCell sut) { var result = sut.Clone(); result.Should().BeOfType <InfectedCell>(); VerifyTimesGermReplicatIsCalled(1, germ); VerifySignalsAreCloned(sut, result, signals, visitor); }
internal void VirusMaturesAfterTwoGenerationsSendsMessageAndTellsVisitorItIsMature( [Frozen] EventAggregator eventAggregator, IListenOn <GermGrowthMessage> listener, IGermVistor visitor, LyticVirus sut) { eventAggregator.Subscribe(listener); IGerm matureVirus = sut; for (int gen = 0; gen <= GenerationToMature; gen++) { matureVirus = matureVirus.Replicate(); } VerifyGermIsMature(visitor, matureVirus); VerifyCorrectMessageIsSent(listener, matureVirus); }
private static void VerifyTimesGermReplicatIsCalled(int count, IGerm germ) { Mock.Get(germ) .Verify(g => g.Replicate(), Times.Exactly(count)); }
public DeadInfectedCell(ushort selfSignal, ushort alertSignal, IGerm germ) { _cell = new InfectedCell(false, selfSignal, alertSignal, germ); }
public LivingInfectedCell(ushort selfSignal, ushort alertSignal, IGerm germ) { _cell = new InfectedCell(true, selfSignal, alertSignal, germ); }
private static void VerifyCorrectMessageIsSent(IListenOn <GermGrowthMessage> listener, IGerm matureVirus) { var expectedMessaged = new GermGrowthMessage(true, false, ReplicationMultiplier, matureVirus); Mock.Get(listener).Verify( v => v.ProcessMessageAsync( It.Is <GermGrowthMessage>(m => m.IsEquivalentTo(expectedMessaged))), Times.Once); }
public ICell CreateInfectedCell(IGerm germ) => new InfectedCell(true, ushort.MaxValue / 2, ushort.MaxValue / 2, germ);
public GermGrowthMessage(bool lytic, bool budding, int replicationMultiplier, IGerm germ) { Lytic = lytic; Budding = budding; ReplicationMultiplier = replicationMultiplier; Germ = germ ?? throw new ArgumentNullException(nameof(germ)); }