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); }
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)); }
static NullCellTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is 0", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, 0, referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "columnsSpanned is 0; must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is -1", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, -1, referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "columnsSpanned is -1; must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is negative number", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, A.Dummy <NegativeInteger>(), referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "columnsSpanned", "must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentException when parameter 'validationEvents' contains a null element", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details, referenceObject.Validation, new[] { A.Dummy <CellValidationEventBase>(), null, A.Dummy <CellValidationEventBase>() }, referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "validationEvents contains a null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentException when parameter 'validation' is is null but parameter 'validationEvents' is not null nor empty.", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details, null, Some.ReadOnlyDummies <CellValidationEventBase>().ToList(), referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "There is no validation specified, however one or more validationEvents exists.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'defaultAvailability' is neither Availability.Enabled nor Availabilty.Disabled", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, Availability.Unknown, referenceObject.AvailabilityCheck, referenceObject.AvailabilityCheckEvents, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "defaultAvailability is neither Availability.Enabled nor Availability.Disabled", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentException when parameter 'availabilityCheckEvents' contains a null element", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, referenceObject.DefaultAvailability, referenceObject.AvailabilityCheck, new[] { A.Dummy <CellAvailabilityCheckEventBase>(), null, A.Dummy <CellAvailabilityCheckEventBase>() }, referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "availabilityCheckEvents contains a null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <NullCell> { Name = "constructor should throw ArgumentException when parameter 'availabilityCheck' is is null but parameter 'availabilityCheckEvents' is not null nor empty.", ConstructionFunc = () => { var referenceObject = A.Dummy <NullCell>(); var result = new NullCell( referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details, referenceObject.Validation, referenceObject.ValidationEvents, referenceObject.DefaultAvailability, null, Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(), referenceObject.Format, referenceObject.HoverOver); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "There is no availabilityCheck specified, however one or more availabilityCheckEvents exists", }, }); }
public DataStructureDummyFactory() { // <------------------- ENUMS ------------------------> AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(Availability.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(AvailabilityCheckStatus.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(AvailabilityCheckStepAction.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BorderStyle.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BorderWeight.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(BytesPayloadLinkedResourceKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CellOpExecutionOutcome.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CellOpExecutionStatus.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CompareOperator.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(FillPatternStyle.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(HorizontalAlignment.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(InnerBorderEdges.None); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(LinkTarget.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(MediaReferenceKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(MessageFormatKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatDigitGroupKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatNegativeDisplayKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(NumberFormatPercentDisplayKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(OuterBorderSides.None); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(SlotSelectionStrategy.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(StringPayloadLinkedResourceKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(UrlLinkedResourceKind.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(ValidationStatus.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(ValidationStepAction.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(Validity.Unknown); AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(VerticalAlignment.Unknown); // <------------------- INTERFACES ------------------------> AutoFixtureBackedDummyFactory.AddDummyCreator <IAvailabilityCheckCell>(A.Dummy <NotSlottedCellBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <ICell>(A.Dummy <CellBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <INotSlottedCell>(A.Dummy <NotSlottedCellBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <IValidationCell>(A.Dummy <NotSlottedCellBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <ICellValueFormat <Version> >(A.Dummy <CellValueFormatBase <Version> >); AutoFixtureBackedDummyFactory.AddDummyCreator <IHoverOver>(A.Dummy <HoverOverBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <ILink>(A.Dummy <SimpleLink>); AutoFixtureBackedDummyFactory.AddDummyCreator <ILinkedResource>(A.Dummy <LinkedResourceBase>); AutoFixtureBackedDummyFactory.AddDummyCreator <IOperationOutputCell <Version> >(A.Dummy <OperationCell <Version> >); // <------------------- OPERATIONS ------------------------> RegisterReturningOperation <bool>(); RegisterReturningOperation <decimal>(); RegisterReturningOperation <string>(); RegisterReturningOperation <ValidationResult>(); RegisterReturningOperation <AvailabilityCheckResult>(); RegisterReturningOperation <Availability>(); RegisterReturningOperation <Validity>(); RegisterReturningOperation <CellLocatorBase>(); RegisterReturningOperation <CompareOperator>(); // <------------------- MODELS ------------------------> // Report AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var numberOfSections = ThreadSafeRandom.Next(1, 4); var result = new Report(A.Dummy <string>(), Some.ReadOnlyDummies <Section>(numberOfSections).ToList(), A.Dummy <string>(), A.Dummy <UtcDateTime>(), Some.ReadOnlyDummies <SimpleLink>().ToList(), A.Dummy <AdditionalReportInfo>(), A.Dummy <ReportFormat>()); return(result); }); // TreeTable AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var numberOfColumns = GetRandomNumberOfColumns(); var columns = Some.ReadOnlyDummies <Column>(numberOfColumns).ToList(); var tableColumns = new TableColumns(columns, A.Dummy <ColumnFormat>()); var tableRows = BuildTableRows(columns.Count); var result = new TreeTable(tableColumns, tableRows, A.Dummy <TableFormat>()); return(result); }); // TableRows AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = BuildTableRows(GetRandomNumberOfColumns()); return(result); }); // HeaderRows AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var headerRows = BuildFlatRows(GetRandomNumberOfColumns()); var result = new HeaderRows(headerRows, A.Dummy <HeaderRowsFormat>()); return(result); }); // DataRows AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var allDataRows = BuildDataRows(GetRandomNumberOfColumns()); var result = new DataRows(allDataRows, A.Dummy <DataRowsFormat>()); return(result); }); // FooterRows AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var footerRows = BuildFlatRows(GetRandomNumberOfColumns()); var result = new FooterRows(footerRows, A.Dummy <FooterRowsFormat>()); return(result); }); // Row AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = BuildDataRow(GetRandomNumberOfColumns()); return(result); }); // FlatRow AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = BuildFlatRow(GetRandomNumberOfColumns(), allowSpanningCells: true); return(result); }); // SlottedCell AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var columnsSpanned = GetRandomColumnsSpannedByCell(); var cells = Some.ReadOnlyDummies <NotSlottedCellBase>().Select(_ => _.DeepCloneWithColumnsSpanned(columnsSpanned)).Cast <NotSlottedCellBase>().ToList(); var slotIdToCellMap = cells.ToDictionary(_ => A.Dummy <string>(), _ => (INotSlottedCell)_); var defaultSlotId = slotIdToCellMap.ElementAt(ThreadSafeRandom.Next(0, slotIdToCellMap.Count)).Key; var result = new SlottedCell(slotIdToCellMap, defaultSlotId, A.Dummy <string>(), columnsSpanned, A.Dummy <string>()); return(result); }); // InputCell<Version> AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new InputCell <Version>( A.Dummy <string>(), GetRandomColumnsSpannedByCell(), A.Dummy <string>(), A.Dummy <Validation>(), Some.ReadOnlyDummies <CellValidationEventBase>().ToList(), A.Dummy <Availability>(), A.Dummy <AvailabilityCheck>(), Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(), Some.ReadOnlyDummies <CellInputEventBase>().ToList(), A.Dummy <ICellValueFormat <Version> >(), A.Dummy <CellFormat>(), A.Dummy <IHoverOver>()); return(result); }); // NullCell AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new NullCell( A.Dummy <string>(), GetRandomColumnsSpannedByCell(), A.Dummy <string>(), A.Dummy <Validation>(), Some.ReadOnlyDummies <CellValidationEventBase>().ToList(), A.Dummy <Availability>(), A.Dummy <AvailabilityCheck>(), Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(), A.Dummy <CellFormat>(), A.Dummy <IHoverOver>(), A.Dummy <ILink>()); return(result); }); // ConstCell<Version> AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new ConstCell <Version>( A.Dummy <Version>(), A.Dummy <string>(), GetRandomColumnsSpannedByCell(), A.Dummy <string>(), A.Dummy <Validation>(), Some.ReadOnlyDummies <CellValidationEventBase>().ToList(), A.Dummy <Availability>(), A.Dummy <AvailabilityCheck>(), Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(), A.Dummy <ICellValueFormat <Version> >(), A.Dummy <CellFormat>(), A.Dummy <IHoverOver>(), A.Dummy <ILink>()); return(result); }); // OperationOutputCell<Version> AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new OperationCell <Version>( A.Dummy <IReturningOperation <Version> >(), A.Dummy <string>(), GetRandomColumnsSpannedByCell(), A.Dummy <string>(), A.Dummy <Validation>(), Some.ReadOnlyDummies <CellValidationEventBase>().ToList(), A.Dummy <Availability>(), A.Dummy <AvailabilityCheck>(), Some.ReadOnlyDummies <CellAvailabilityCheckEventBase>().ToList(), Some.ReadOnlyDummies <CellOpExecutionEventBase>().ToList(), A.Dummy <ICellValueFormat <Version> >(), A.Dummy <CellFormat>(), A.Dummy <IHoverOver>(), A.Dummy <ILink>()); return(result); }); // DateTimeFormat AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var localize = A.Dummy <bool>(); var result = new DateTimeFormat(A.Dummy <DateTimeFormatKind>(), A.Dummy <CultureKind>(), localize, localize ? A.Dummy <StandardTimeZone>() : (StandardTimeZone?)null); return(result); }); // ReportFormat AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var displayTimestamp = A.Dummy <bool>(); var result = new ReportFormat(displayTimestamp, displayTimestamp ? A.Dummy <DateTimeFormat>() : null, A.Dummy <ReportFormatOptions>()); return(result); }); // Color AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = Color.FromArgb(A.Dummy <byte>(), A.Dummy <byte>(), A.Dummy <byte>()); return(result); }); // Events AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellAvailabilityCheckClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellAvailabilityCheckDeterminedCellDisabledEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellAvailabilityCheckDeterminedCellEnabledEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellAvailabilityCheckFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellInputAppliedEvent <Version>(A.Dummy <UtcDateTime>(), A.Dummy <Version>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellInputClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellOpExecutionAbortedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellOpExecutionClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellOpExecutionCompletedEvent <Version>(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <Version>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellOpExecutionDeemedNotApplicableEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellOpExecutionFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationAbortedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationClearedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationDeemedNotApplicableEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationDeterminedCellInvalidEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationDeterminedCellValidEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>(), A.Dummy <string>()); return(result); }); AutoFixtureBackedDummyFactory.AddDummyCreator(() => { var result = new CellValidationFailedEvent(A.Dummy <UtcDateTime>(), A.Dummy <string>()); return(result); }); }