示例#1
0
        internal void VirusReplicationReturnsNewVirus(
            LyticVirus sut)
        {
            var result = sut.Replicate();

            result.Should().NotBeSameAs(sut);
        }
示例#2
0
        internal void NewlyConstructedVirusTellsVisitorItIsLyticButNotMature(
            IGermVistor visitor,
            LyticVirus sut)
        {
            sut.Accept(visitor);
            bool isNotMature = false;

            VerifyGerm(isNotMature, visitor);
        }
示例#3
0
        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);
        }
示例#4
0
        internal void VirusDoesNotInfectAlreadyInfectedCellsOrNullCells(
            InfectedCell infectedCellToInfect,
            NullCell nullCellToInfect,
            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(infectedCellToInfect).Clone());
                result.Add(sut.InfectCell(nullCellToInfect).Clone());
            }

            VerifyNoNewlyInfectedCellsArePresent(result, numberOfTries);
        }
示例#5
0
        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);
        }