static RowTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentNullException when parameter 'cells' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( null, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "cells", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'cells' is an empty enumerable scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( new List <ICell>(), referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "cells", "is an empty enumerable", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'cells' contains a null element scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( new ICell[0].Concat(referenceObject.Cells).Concat(new ICell[] { null }).Concat(referenceObject.Cells).ToList(), referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "cells", "contains at least one null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'id' is white space scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, Invariant($" {Environment.NewLine} "), referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "id", "white space", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'childRows' contains a null element scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, new Row[0].Concat(referenceObject.ChildRows).Concat(new Row[] { null }).Concat(referenceObject.ChildRows).ToList(), referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "childRows", "contains at least one null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'expandedSummaryRows' contains a null element.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, new[] { A.Dummy <FlatRow>(), null, A.Dummy <FlatRow>() }, null); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "expandedSummaryRows contains a null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'expandedSummaryRows' contains rows, but childRows is null.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, null, new[] { A.Dummy <FlatRow>() }, null); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "expandedSummaryRows is specified when there are no rows in childRows", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'expandedSummaryRows' contains rows, but childRows is empty.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, new Row[0], new[] { A.Dummy <FlatRow>() }, null); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "expandedSummaryRows is specified when there are no rows in childRows", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'collapsedSummaryRows' contains a null element.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, null, null, new[] { A.Dummy <FlatRow>(), null, A.Dummy <FlatRow>() }); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "collapsedSummaryRows contains a null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'collapsedSummaryRows' contains rows, but childRows is null.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, null, null, new[] { A.Dummy <FlatRow>() }); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "collapsedSummaryRows is specified when there are no rows in childRows", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Row> { Name = "constructor should throw ArgumentException when parameter 'collapsedSummaryRow' is not null, but childRows is empty.", ConstructionFunc = () => { var referenceObject = A.Dummy <Row>(); var result = new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, new Row[0], null, new[] { A.Dummy <FlatRow>() }); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "collapsedSummaryRows is specified when there are no rows in childRows", }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithId should deep clone object and replace Id with the provided id", WithPropertyName = "Id", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>(); var referenceObject = A.Dummy <Row>().ThatIs(_ => !systemUnderTest.Id.IsEqualTo(_.Id)); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Id, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithCells should deep clone object and replace Cells with the provided cells", WithPropertyName = "Cells", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>(); var referenceObject = A.Dummy <Row>().ThatIs(_ => !systemUnderTest.Cells.IsEqualTo(_.Cells)); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Cells, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithFormat should deep clone object and replace Format with the provided format", WithPropertyName = "Format", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>(); var referenceObject = A.Dummy <Row>().ThatIs(_ => !systemUnderTest.Format.IsEqualTo(_.Format)); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Format, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithChildRows should deep clone object and replace ChildRows with the provided childRows", WithPropertyName = "ChildRows", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>().Whose(_ => _.ChildRows.Any()); var referenceObject = A.Dummy <Row>().Whose(_ => _.ChildRows.Any() && (!_.ChildRows.IsEqualTo(systemUnderTest.ChildRows))); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.ChildRows, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithExpandedSummaryRows should deep clone object and replace ExpandedSummaryRows with the provided expandedSummaryRows", WithPropertyName = "ExpandedSummaryRows", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>().Whose(_ => _.ChildRows.Any()); var referenceObject = A.Dummy <Row>().Whose(_ => _.ChildRows.Any() && (!_.ExpandedSummaryRows.IsEqualTo(systemUnderTest.ExpandedSummaryRows))); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.ExpandedSummaryRows, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Row> { Name = "DeepCloneWithCollapsedSummaryRows should deep clone object and replace CollapsedSummaryRows with the provided collapsedSummaryRows", WithPropertyName = "CollapsedSummaryRows", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Row>().Whose(_ => _.ChildRows.Any()); var referenceObject = A.Dummy <Row>().Whose(_ => _.ChildRows.Any() && (!_.CollapsedSummaryRows.IsEqualTo(systemUnderTest.CollapsedSummaryRows))); var result = new SystemUnderTestDeepCloneWithValue <Row> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.CollapsedSummaryRows, }; return(result); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => { var referenceObject = A.Dummy <Row>().Whose(_ => _.ChildRows.Any()); var result = new EquatableTestScenario <Row> { Name = "Default Code Generated Scenario", ReferenceObject = referenceObject, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new Row[] { new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), }, ObjectsThatAreNotEqualToReferenceObject = new Row[] { new Row( referenceObject.Cells, A.Dummy <Row>().Whose(_ => !_.Id.IsEqualTo(referenceObject.Id)).Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), new Row( A.Dummy <Row>().Whose(_ => !_.Cells.IsEqualTo(referenceObject.Cells)).Cells, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), new Row( referenceObject.Cells, referenceObject.Id, A.Dummy <Row>().Whose(_ => !_.Format.IsEqualTo(referenceObject.Format)).Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, A.Dummy <Row>().Whose(_ => (!_.ChildRows.IsEqualTo(referenceObject.ChildRows)) && _.ChildRows.Any()).ChildRows, referenceObject.ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, A.Dummy <Row>().Whose(_ => (!_.ExpandedSummaryRows.IsEqualTo(referenceObject.ExpandedSummaryRows)) && _.ChildRows.Any()).ExpandedSummaryRows, referenceObject.CollapsedSummaryRows), new Row( referenceObject.Cells, referenceObject.Id, referenceObject.Format, referenceObject.ChildRows, referenceObject.ExpandedSummaryRows, A.Dummy <Row>().Whose(_ => (!_.CollapsedSummaryRows.IsEqualTo(ReferenceObjectForEquatableTestScenarios.CollapsedSummaryRows)) && _.ChildRows.Any()).CollapsedSummaryRows), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), A.Dummy <FlatRow>(), }, }; return(result); }); }
static DateTimeFormatTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <DateTimeFormat> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'formatKind' is DateTimeFormatKind.Unknown scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <DateTimeFormat>(); var result = new DateTimeFormat( DateTimeFormatKind.Unknown, referenceObject.CultureKind, referenceObject.LocalizeTimeZone, referenceObject.LocalTimeZone); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "formatKind is Unknown", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <DateTimeFormat> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'cultureKind' is CultureKind.Unknown scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <DateTimeFormat>(); var result = new DateTimeFormat( referenceObject.FormatKind, CultureKind.Unknown, referenceObject.LocalizeTimeZone, referenceObject.LocalTimeZone); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "cultureKind is Unknown", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <DateTimeFormat> { Name = "constructor should throw ArgumentException when parameter 'localizeTimeZone' is false and parameter 'localTimeZone' is not null", ConstructionFunc = () => { var referenceObject = A.Dummy <DateTimeFormat>(); var result = new DateTimeFormat( referenceObject.FormatKind, referenceObject.CultureKind, false, A.Dummy <StandardTimeZone>()); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "localizeTimeZone is false, but localTimeZone is not null", }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => { var referenceObjectForEquatableTestScenarios = A.Dummy <DateTimeFormat>().Whose(_ => _.LocalizeTimeZone == true); var result = new EquatableTestScenario <DateTimeFormat> { Name = "Default Code Generated Scenario", ReferenceObject = referenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new DateTimeFormat[] { new DateTimeFormat( referenceObjectForEquatableTestScenarios.FormatKind, referenceObjectForEquatableTestScenarios.CultureKind, referenceObjectForEquatableTestScenarios.LocalizeTimeZone, referenceObjectForEquatableTestScenarios.LocalTimeZone), }, ObjectsThatAreNotEqualToReferenceObject = new DateTimeFormat[] { new DateTimeFormat( A.Dummy <DateTimeFormat>().Whose(_ => !_.FormatKind.IsEqualTo(referenceObjectForEquatableTestScenarios.FormatKind)).FormatKind, referenceObjectForEquatableTestScenarios.CultureKind, referenceObjectForEquatableTestScenarios.LocalizeTimeZone, referenceObjectForEquatableTestScenarios.LocalTimeZone), new DateTimeFormat( referenceObjectForEquatableTestScenarios.FormatKind, A.Dummy <DateTimeFormat>().Whose(_ => !_.CultureKind.IsEqualTo(referenceObjectForEquatableTestScenarios.CultureKind)).CultureKind, referenceObjectForEquatableTestScenarios.LocalizeTimeZone, referenceObjectForEquatableTestScenarios.LocalTimeZone), new DateTimeFormat( referenceObjectForEquatableTestScenarios.FormatKind, referenceObjectForEquatableTestScenarios.CultureKind, A.Dummy <DateTimeFormat>().Whose(_ => !_.LocalizeTimeZone.IsEqualTo(referenceObjectForEquatableTestScenarios.LocalizeTimeZone)).LocalizeTimeZone, null), new DateTimeFormat( referenceObjectForEquatableTestScenarios.FormatKind, referenceObjectForEquatableTestScenarios.CultureKind, referenceObjectForEquatableTestScenarios.LocalizeTimeZone, A.Dummy <DateTimeFormat>().Whose(_ => !_.LocalTimeZone.IsEqualTo(referenceObjectForEquatableTestScenarios.LocalTimeZone)).LocalTimeZone), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }; return(result); }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <DateTimeFormat> { Name = "DeepCloneWithFormatKind should deep clone object and replace FormatKind with the provided formatKind", WithPropertyName = "FormatKind", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <DateTimeFormat>(); var referenceObject = A.Dummy <DateTimeFormat>().ThatIs(_ => !systemUnderTest.FormatKind.IsEqualTo(_.FormatKind)); var result = new SystemUnderTestDeepCloneWithValue <DateTimeFormat> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.FormatKind, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <DateTimeFormat> { Name = "DeepCloneWithCultureKind should deep clone object and replace CultureKind with the provided cultureKind", WithPropertyName = "CultureKind", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <DateTimeFormat>(); var referenceObject = A.Dummy <DateTimeFormat>().ThatIs(_ => !systemUnderTest.CultureKind.IsEqualTo(_.CultureKind)); var result = new SystemUnderTestDeepCloneWithValue <DateTimeFormat> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.CultureKind, }; return(result); }, }); }
static ReportFormatTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <ReportFormat> { Name = "constructor should throw ArgumentException when parameter 'displayTimestamp' is false and parameter 'timestampFormat' is not null", ConstructionFunc = () => { var result = new ReportFormat( false, A.Dummy <DateTimeFormat>()); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "displayTimestamp is false, but timestampFormat is not null", }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => { var referenceObjectForEquatableTestScenarios = A.Dummy <ReportFormat>().Whose(_ => _.DisplayTimestamp == true); var result = new EquatableTestScenario <ReportFormat> { Name = "Default Code Generated Scenario", ReferenceObject = referenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new ReportFormat[] { new ReportFormat( referenceObjectForEquatableTestScenarios.DisplayTimestamp, referenceObjectForEquatableTestScenarios.TimestampFormat, referenceObjectForEquatableTestScenarios.Options), }, ObjectsThatAreNotEqualToReferenceObject = new ReportFormat[] { new ReportFormat( A.Dummy <ReportFormat>().Whose(_ => !_.DisplayTimestamp.IsEqualTo(referenceObjectForEquatableTestScenarios.DisplayTimestamp)).DisplayTimestamp, null), new ReportFormat( referenceObjectForEquatableTestScenarios.DisplayTimestamp, A.Dummy <ReportFormat>().Whose(_ => !_.TimestampFormat.IsEqualTo(referenceObjectForEquatableTestScenarios.TimestampFormat)).TimestampFormat), new ReportFormat( referenceObjectForEquatableTestScenarios.DisplayTimestamp, referenceObjectForEquatableTestScenarios.TimestampFormat, A.Dummy <ReportFormat>().Whose(_ => !_.Options.IsEqualTo(referenceObjectForEquatableTestScenarios.Options)).Options), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }; return(result); }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <ReportFormat> { Name = "DeepCloneWithTimestampFormat should deep clone object and replace TimestampFormat with the provided timestampFormat", WithPropertyName = "TimestampFormat", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportFormat>().Whose(_ => _.DisplayTimestamp == true); var referenceObject = A.Dummy <ReportFormat>().ThatIs(_ => !systemUnderTest.TimestampFormat.IsEqualTo(_.TimestampFormat)); var result = new SystemUnderTestDeepCloneWithValue <ReportFormat> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.TimestampFormat, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportFormat> { Name = "DeepCloneWithOptions should deep clone object and replace Options with the provided options", WithPropertyName = "Options", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportFormat>(); var referenceObject = A.Dummy <ReportFormat>().ThatIs(_ => !systemUnderTest.Options.IsEqualTo(_.Options)); var result = new SystemUnderTestDeepCloneWithValue <ReportFormat> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Options, }; return(result); }, }); }