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 TreeTableTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentNullException when parameter 'tableColumns' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <TreeTable>(); var result = new TreeTable( null, referenceObject.TableRows, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "tableColumns", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when parameter 'tableRows' contains a header row that does not span all of the columns in tableColumns", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList()); var rows = new[] { new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).ToList()), }; var headerRows = new HeaderRows(rows, null); var tableRows = new TableRows(headerRows, null); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when parameter 'tableRows' contains a data row that does not span all of the columns in tableColumns", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList()); var rows = new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new Row( Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows: new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3)), new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }), new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }; var dataRows = new DataRows(rows, null); var tableRows = new TableRows(null, dataRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when parameter 'footerRows' contains a footer row that does not span all of the columns in tableColumns", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(2).ToList()); var rows = new[] { new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(2).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).ToList()), }; var footerRows = new FooterRows(rows, null); var tableRows = new TableRows(footerRows: footerRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "tableRows contains a row or descendant row that does not span all 2 of the defined columns", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when two columns have the same identifier", ConstructionFunc = () => { var tableColumns = new TableColumns(new[] { new Column("column-1"), new Column("column-2"), new Column("column-1"), }); var headerRows = new HeaderRows( new[] { new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }, null); var dataRows = new DataRows( new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new Row( Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows: new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }), }); var tableRows = new TableRows(headerRows, dataRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when two rows have the same identifier", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList()); var headerRows = new HeaderRows( new[] { new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-1"), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-2"), }, null); var dataRows = new DataRows( new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-3"), new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows: new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), "row-1"), }), }); var tableRows = new TableRows(headerRows, dataRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when two cells have the same identifier", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList()); var headerRows = new HeaderRows( new[] { new FlatRow( new ICell[] { A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null), A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId("cell-1"), A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null), }), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }, null); var dataRows = new DataRows( new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new Row( Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows: new[] { new Row( new ICell[] { A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null), A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null), A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId("cell-1"), }), }), }); var tableRows = new TableRows(headerRows, dataRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "Two or more elements (i.e. columns, rows, cells) have the same identifier.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <TreeTable> { Name = "constructor should throw ArgumentException when a cell object is used multiple times", ConstructionFunc = () => { var tableColumns = new TableColumns(Some.ReadOnlyDummies <Column>(3).ToList()); var cell = A.Dummy <CellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null); var headerRows = new HeaderRows( new[] { new FlatRow( new ICell[] { A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null), cell, A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(1).DeepCloneWithId(null), }), new FlatRow(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), }, null); var dataRows = new DataRows( new[] { new Row(Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList()), new Row( Some.ReadOnlyDummies <NotSlottedCellBase>(3).Select(_ => _.DeepCloneWithColumnsSpanned(1)).ToList(), childRows: new[] { new Row( new ICell[] { A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null), A.Dummy <NotSlottedCellBase>().DeepCloneWithColumnsSpanned(null).DeepCloneWithId(null), cell, }), }), }); var tableRows = new TableRows(headerRows, dataRows); var result = new TreeTable( tableColumns, tableRows); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "One or more ICell objects are used multiple times in the tree table.", }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <TreeTable> { Name = "DeepCloneWithTableColumns should deep clone object and replace TableColumns with the provided tableColumns", WithPropertyName = "TableColumns", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <TreeTable>(); var referenceObject = A.Dummy <TreeTable>().ThatIs(_ => !systemUnderTest.TableColumns.IsEqualTo(_.TableColumns) && (_.TableColumns.Columns.Count == systemUnderTest.TableColumns.Columns.Count)); var result = new SystemUnderTestDeepCloneWithValue <TreeTable> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.TableColumns, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <TreeTable> { Name = "DeepCloneWithTableRows should deep clone object and replace TableRows with the provided tableRows", WithPropertyName = "TableRows", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <TreeTable>(); var referenceObject = A.Dummy <TreeTable>().ThatIs(_ => !systemUnderTest.TableRows.IsEqualTo(_.TableRows) && ((!_.TableRows.GetAllRowsInOrder().Any()) || (_.TableRows.GetAllRowsInOrder().First().GetNumberOfColumnsSpanned() == systemUnderTest.TableColumns.Columns.Count))); var result = new SystemUnderTestDeepCloneWithValue <TreeTable> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.TableRows, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <TreeTable> { Name = "DeepCloneWithFormat should deep clone object and replace Format with the provided format", WithPropertyName = "Format", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <TreeTable>(); var referenceObject = A.Dummy <TreeTable>().ThatIs(_ => !systemUnderTest.Format.IsEqualTo(_.Format)); var result = new SystemUnderTestDeepCloneWithValue <TreeTable> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Format, }; return(result); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <TreeTable> { Name = "Default Code Generated Scenario", ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new TreeTable[] { new TreeTable( ReferenceObjectForEquatableTestScenarios.TableColumns, ReferenceObjectForEquatableTestScenarios.TableRows, ReferenceObjectForEquatableTestScenarios.Format), }, ObjectsThatAreNotEqualToReferenceObject = new TreeTable[] { new TreeTable( A.Dummy <TreeTable>().Whose(_ => !_.TableColumns.IsEqualTo(ReferenceObjectForEquatableTestScenarios.TableColumns) && (_.TableColumns.Columns.Count == ReferenceObjectForEquatableTestScenarios.TableColumns.Columns.Count)).TableColumns, ReferenceObjectForEquatableTestScenarios.TableRows, ReferenceObjectForEquatableTestScenarios.Format), new TreeTable( ReferenceObjectForEquatableTestScenarios.TableColumns, A.Dummy <TreeTable>().Whose(_ => (!_.TableRows.IsEqualTo(ReferenceObjectForEquatableTestScenarios.TableRows) && ((!_.TableRows.GetAllRowsInOrder().Any()) || (_.TableRows.GetAllRowsInOrder().First().GetNumberOfColumnsSpanned() == ReferenceObjectForEquatableTestScenarios.TableColumns.Columns.Count)))).TableRows, ReferenceObjectForEquatableTestScenarios.Format), new TreeTable( ReferenceObjectForEquatableTestScenarios.TableColumns, ReferenceObjectForEquatableTestScenarios.TableRows, A.Dummy <TreeTable>().Whose(_ => !_.Format.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Format)).Format), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); }
static SendEmailResponseTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <SendEmailResponse> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'sendEmailResult' is SendEmailResult.Unknown scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SendEmailResponse>(); var result = new SendEmailResponse( SendEmailResult.Unknown, referenceObject.ExceptionToString, referenceObject.CommunicationLog); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "sendEmailResult", "Unknown" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SendEmailResponse> { Name = "constructor should throw ArgumentException when parameter 'sendEmailResult' is SendEmailResult.Success and 'exceptionToString' is not null", ConstructionFunc = () => { var referenceObject = A.Dummy <SendEmailResponse>(); var result = new SendEmailResponse( SendEmailResult.Success, " \r\n ", referenceObject.CommunicationLog); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "When sendEmailResult indicates success, exceptionToString must be null", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SendEmailResponse> { Name = "constructor should throw ArgumentNullException when parameter 'sendEmailResult' is not SendEmailResult.Success and 'exceptionToString' is null", ConstructionFunc = () => { var referenceObject = A.Dummy <SendEmailResponse>(); var result = new SendEmailResponse( A.Dummy <SendEmailResult>().ThatIsNot(SendEmailResult.Success), null, referenceObject.CommunicationLog); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "When sendEmailResult indicates a failure, exceptionToString must not be null nor white space.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SendEmailResponse> { Name = "constructor should throw ArgumentException when parameter 'sendEmailResult' is not SendEmailResult.Success and 'exceptionToString' is white space", ConstructionFunc = () => { var referenceObject = A.Dummy <SendEmailResponse>(); var result = new SendEmailResponse( A.Dummy <SendEmailResult>().ThatIsNot(SendEmailResult.Success), Invariant($" {Environment.NewLine} "), referenceObject.CommunicationLog); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "When sendEmailResult indicates a failure, exceptionToString must not be null nor white space.", }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <SendEmailResponse> { Name = "DeepCloneWithSendEmailResult should deep clone object and replace SendEmailResult with the provided sendEmailResult", WithPropertyName = "SendEmailResult", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SendEmailResponse>(); var sendEmailResult = systemUnderTest.SendEmailResult == SendEmailResult.Success ? SendEmailResult.Success : A.Dummy <SendEmailResult>().ThatIs(_ => (_ != SendEmailResult.Success) && (_ != systemUnderTest.SendEmailResult)); var result = new SystemUnderTestDeepCloneWithValue <SendEmailResponse> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = sendEmailResult, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SendEmailResponse> { Name = "DeepCloneWithExceptionToString should deep clone object and replace ExceptionToString with the provided exceptionToString", WithPropertyName = "ExceptionToString", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SendEmailResponse>(); var exceptionToString = systemUnderTest.SendEmailResult == SendEmailResult.Success ? null : A.Dummy <string>().ThatIsNot(systemUnderTest.ExceptionToString); var result = new SystemUnderTestDeepCloneWithValue <SendEmailResponse> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = exceptionToString, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SendEmailResponse> { Name = "DeepCloneWithCommunicationLog should deep clone object and replace CommunicationLog with the provided communicationLog", WithPropertyName = "CommunicationLog", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SendEmailResponse>(); var referenceObject = A.Dummy <SendEmailResponse>().ThatIs(_ => !systemUnderTest.CommunicationLog.IsEqualTo(_.CommunicationLog)); var result = new SystemUnderTestDeepCloneWithValue <SendEmailResponse> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.CommunicationLog, }; return(result); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <SendEmailResponse> { Name = "Equatable Scenario", ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new SendEmailResponse[] { new SendEmailResponse( ReferenceObjectForEquatableTestScenarios.SendEmailResult, ReferenceObjectForEquatableTestScenarios.ExceptionToString, ReferenceObjectForEquatableTestScenarios.CommunicationLog), }, ObjectsThatAreNotEqualToReferenceObject = new SendEmailResponse[] { // If SendEmailResult == Success, we can just tweak that parameter // because the constructor will throw when it finds a null ExceptionToString, // so we'll just tweak CommunicationLog. Setting to null breaks the test. ReferenceObjectForEquatableTestScenarios.SendEmailResult == SendEmailResult.Success ? new SendEmailResponse(SendEmailResult.Success, null, A.Dummy <string>()) : new SendEmailResponse( A.Dummy <SendEmailResponse>().Whose(_ => !_.SendEmailResult.IsEqualTo(ReferenceObjectForEquatableTestScenarios.SendEmailResult) && (_.SendEmailResult != SendEmailResult.Success)).SendEmailResult, ReferenceObjectForEquatableTestScenarios.ExceptionToString, ReferenceObjectForEquatableTestScenarios.CommunicationLog), // If SendEmailResult == Success, we can just tweak that parameter // because the constructor will throw when it finds a null ExceptionToString // so we'll just tweak CommunicationLog. Setting to null breaks the test. ReferenceObjectForEquatableTestScenarios.SendEmailResult == SendEmailResult.Success ? new SendEmailResponse(SendEmailResult.Success, null, A.Dummy <string>()) : new SendEmailResponse( ReferenceObjectForEquatableTestScenarios.SendEmailResult, A.Dummy <SendEmailResponse>().Whose(_ => !_.ExceptionToString.IsEqualTo(ReferenceObjectForEquatableTestScenarios.ExceptionToString) && (_.SendEmailResult != SendEmailResult.Success)).ExceptionToString, ReferenceObjectForEquatableTestScenarios.CommunicationLog), new SendEmailResponse( ReferenceObjectForEquatableTestScenarios.SendEmailResult, ReferenceObjectForEquatableTestScenarios.ExceptionToString, A.Dummy <SendEmailResponse>().Whose(_ => !_.CommunicationLog.IsEqualTo(ReferenceObjectForEquatableTestScenarios.CommunicationLog)).CommunicationLog), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); }
static ReportingPeriodTest() { DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithStart)} should deep clone object and replace {nameof(ReportingPeriod.Start)} with the provided start when {nameof(ReportingPeriod.End)} is {nameof(UnitOfTimeGranularity.Unbounded)} and provided start has the same {nameof(UnitOfTimeKind)} as {nameof(ReportingPeriod.End)}"), WithPropertyName = nameof(ReportingPeriod.Start), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.End.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => _.GetUnitOfTimeKind() == systemUnderTest.GetUnitOfTimeKind()); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Start, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithStart)} should deep clone object and replace {nameof(ReportingPeriod.Start)} with the provided start when {nameof(ReportingPeriod.End)} is bounded and provided start is {nameof(UnitOfTimeGranularity.Unbounded)} having the same {nameof(UnitOfTimeKind)}"), WithPropertyName = nameof(ReportingPeriod.Start), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.End.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => (_.Start.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded) && (_.Start.UnitOfTimeKind == systemUnderTest.End.UnitOfTimeKind)); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Start, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithStart)} should deep clone object and replace {nameof(ReportingPeriod.Start)} with the provided start when {nameof(ReportingPeriod.End)} is bounded and provided start is of the same type as and <= {nameof(ReportingPeriod.End)}"), WithPropertyName = nameof(ReportingPeriod.Start), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.End.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => (_.Start.GetType() == systemUnderTest.End.GetType()) && (_.Start <= systemUnderTest.End)); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Start, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithEnd)} should deep clone object and replace {nameof(ReportingPeriod.End)} with the provided end when {nameof(ReportingPeriod.Start)} is {nameof(UnitOfTimeGranularity.Unbounded)} and provided end has the same {nameof(UnitOfTimeKind)} as {nameof(ReportingPeriod.Start)}"), WithPropertyName = nameof(ReportingPeriod.End), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.Start.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => _.GetUnitOfTimeKind() == systemUnderTest.GetUnitOfTimeKind()); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.End, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithEnd)} should deep clone object and replace {nameof(ReportingPeriod.End)} with the provided end when {nameof(ReportingPeriod.Start)} is bounded and provided end is {nameof(UnitOfTimeGranularity.Unbounded)} having the same {nameof(UnitOfTimeKind)}"), WithPropertyName = nameof(ReportingPeriod.End), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.Start.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => (_.End.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded) && (_.End.UnitOfTimeKind == systemUnderTest.Start.UnitOfTimeKind)); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.End, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <ReportingPeriod> { Name = Invariant($"{nameof(ReportingPeriod.DeepCloneWithEnd)} should deep clone object and replace {nameof(ReportingPeriod.End)} with the provided end when {nameof(ReportingPeriod.Start)} is bounded and provided end is of the same type as and >= {nameof(ReportingPeriod.Start)}"), WithPropertyName = nameof(ReportingPeriod.End), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <ReportingPeriod>().Whose(_ => _.Start.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); var referenceObject = A.Dummy <ReportingPeriod>().Whose(_ => (_.End.GetType() == systemUnderTest.Start.GetType()) && (_.End >= systemUnderTest.Start)); var result = new SystemUnderTestDeepCloneWithValue <ReportingPeriod> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.End, }; return(result); }, }); var unboundedStartReportingPeriod = A.Dummy <ReportingPeriod>().Whose(_ => _.Start.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded); var boundedStartReportingPeriod = A.Dummy <ReportingPeriod>().Whose(_ => _.Start.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); var unboundedEndReportingPeriod = A.Dummy <ReportingPeriod>().Whose(_ => _.End.UnitOfTimeGranularity == UnitOfTimeGranularity.Unbounded); var boundedEndReportingPeriod = A.Dummy <ReportingPeriod>().Whose(_ => _.End.UnitOfTimeGranularity != UnitOfTimeGranularity.Unbounded); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <ReportingPeriod> { Name = "Reference object has unbounded Start. Create an End of the same UnitOfTimeKind that != reference object's End", ReferenceObject = unboundedStartReportingPeriod, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { unboundedStartReportingPeriod.DeepClone(), }, ObjectsThatAreNotEqualToReferenceObject = new[] { new ReportingPeriod(unboundedStartReportingPeriod.Start, A.Dummy <UnitOfTime>().Whose(_ => (_.UnitOfTimeKind == unboundedStartReportingPeriod.GetUnitOfTimeKind()) && (_ != unboundedStartReportingPeriod.End))), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), } .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind()) .ToArray(), }) .AddScenario(() => new EquatableTestScenario <ReportingPeriod> { Name = "Reference object has bounded Start. Create an End that is of the same type as reference object's Start (so it will be bounded), that is > but != reference object's Start", ReferenceObject = boundedStartReportingPeriod, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { boundedStartReportingPeriod.DeepClone(), }, ObjectsThatAreNotEqualToReferenceObject = new[] { new ReportingPeriod(boundedStartReportingPeriod.Start, A.Dummy <UnitOfTime>().Whose(_ => (_.GetType() == boundedStartReportingPeriod.Start.GetType()) && (_ > boundedStartReportingPeriod.Start) && (_ != boundedStartReportingPeriod.End))), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), } .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind()) .ToArray(), }) .AddScenario(() => new EquatableTestScenario <ReportingPeriod> { Name = "Reference object has unbounded End. Create an Start of the same UnitOfTimeKind that != reference object's Start", ReferenceObject = unboundedEndReportingPeriod, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { unboundedEndReportingPeriod.DeepClone(), }, ObjectsThatAreNotEqualToReferenceObject = new[] { new ReportingPeriod(A.Dummy <UnitOfTime>().Whose(_ => (_.UnitOfTimeKind == unboundedEndReportingPeriod.GetUnitOfTimeKind()) && (_ != unboundedEndReportingPeriod.Start)), unboundedEndReportingPeriod.End), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), } .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind()) .ToArray(), }) .AddScenario(() => new EquatableTestScenario <ReportingPeriod> { Name = "Reference object has bounded End. Create a Start that is of the same type as reference object's End (so it will be bounded), that is < but != reference object's End", ReferenceObject = boundedEndReportingPeriod, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { boundedEndReportingPeriod.DeepClone(), }, ObjectsThatAreNotEqualToReferenceObject = new[] { new ReportingPeriod(A.Dummy <UnitOfTime>().Whose(_ => (_.GetType() == boundedEndReportingPeriod.End.GetType()) && (_ < boundedEndReportingPeriod.End) && (_ != boundedEndReportingPeriod.Start)), boundedEndReportingPeriod.End), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), } .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind()) .ToArray(), }); StringRepresentationTestScenarios .RemoveAllScenarios() .AddScenario(() => new StringRepresentationTestScenario <ReportingPeriod> { Name = "String Representation - case 1", SystemUnderTestExpectedStringRepresentationFunc = () => new SystemUnderTestExpectedStringRepresentation <ReportingPeriod> { SystemUnderTest = new ReportingPeriod( new CalendarDay(2017, MonthOfYear.November, DayOfMonth.Thirty), new CalendarDay(2018, MonthOfYear.March, DayOfMonth.TwentyFour)), ExpectedStringRepresentation = "2017-11-30 to 2018-03-24", }, }); }
static CalendarDayTest() { var referenceCalendarDay = A.Dummy <CalendarDay>(); ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' is < 0", ConstructionFunc = () => new CalendarDay(A.Dummy <NegativeInteger>(), referenceCalendarDay.MonthOfYear, referenceCalendarDay.DayOfMonth), ExpectedExceptionMessageContains = new[] { "'year' < '1'" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 0", ConstructionFunc = () => new CalendarDay(0, referenceCalendarDay.MonthOfYear, referenceCalendarDay.DayOfMonth), ExpectedExceptionMessageContains = new[] { "'year' < '1'" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 10000", ConstructionFunc = () => new CalendarDay(10000, referenceCalendarDay.MonthOfYear, referenceCalendarDay.DayOfMonth), ExpectedExceptionMessageContains = new[] { "'year' > '9999'" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' > 9999", ConstructionFunc = () => new CalendarDay(A.Dummy <PositiveInteger>().ThatIs(_ => _ > 9999, -1), referenceCalendarDay.MonthOfYear, referenceCalendarDay.DayOfMonth), ExpectedExceptionMessageContains = new[] { "'year' > '9999'" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'monthOfYear' is MonthOfYear.Invalid", ConstructionFunc = () => new CalendarDay(referenceCalendarDay.Year, MonthOfYear.Invalid, referenceCalendarDay.DayOfMonth), ExpectedExceptionMessageContains = new[] { "monthOfYear", "Invalid" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentOutOfRangeException when parameter 'dayOfMonth' is DayOfMonth.Invalid", ConstructionFunc = () => new CalendarDay(referenceCalendarDay.Year, referenceCalendarDay.MonthOfYear, DayOfMonth.Invalid), ExpectedExceptionMessageContains = new[] { "dayOfMonth", "Invalid" }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 1", ConstructionFunc = () => new CalendarDay(2016, MonthOfYear.February, (DayOfMonth)30), ExpectedExceptionMessageContains = new[] { "day (Thirty) is not a valid day in the specified month (February) and year (2016)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 2", ConstructionFunc = () => new CalendarDay(2016, MonthOfYear.February, (DayOfMonth)31), ExpectedExceptionMessageContains = new[] { "day (ThirtyOne) is not a valid day in the specified month (February) and year (2016)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 3", ConstructionFunc = () => new CalendarDay(2015, MonthOfYear.February, (DayOfMonth)29), ExpectedExceptionMessageContains = new[] { "day (TwentyNine) is not a valid day in the specified month (February) and year (2015)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 4", ConstructionFunc = () => new CalendarDay(2015, MonthOfYear.February, (DayOfMonth)30), ExpectedExceptionMessageContains = new[] { "day (Thirty) is not a valid day in the specified month (February) and year (2015)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 5", ConstructionFunc = () => new CalendarDay(2015, MonthOfYear.February, (DayOfMonth)31), ExpectedExceptionMessageContains = new[] { "day (ThirtyOne) is not a valid day in the specified month (February) and year (2015)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 6", ConstructionFunc = () => new CalendarDay(2016, MonthOfYear.November, (DayOfMonth)31), ExpectedExceptionMessageContains = new[] { "day (ThirtyOne) is not a valid day in the specified month (November) and year (2016)" }, ExpectedExceptionType = typeof(ArgumentException), }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <CalendarDay> { Name = "Constructor should throw ArgumentException when parameter 'dayOfMonth' is not a valid day in the specified 'year' and 'monthOfYear' - case 7", ConstructionFunc = () => new CalendarDay(2017, MonthOfYear.April, (DayOfMonth)31), ExpectedExceptionMessageContains = new[] { "day (ThirtyOne) is not a valid day in the specified month (April) and year (2017)" }, ExpectedExceptionType = typeof(ArgumentException), }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <CalendarDay> { Name = Invariant($"{nameof(CalendarDay.DeepCloneWithYear)} should deep clone object and replace {nameof(CalendarDay.Year)} with the provided year"), WithPropertyName = nameof(CalendarDay.Year), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <CalendarDay>(); var referenceObject = A.Dummy <CalendarDay>().ThatIs(_ => !systemUnderTest.Year.IsEqualTo(_.Year)); var result = new SystemUnderTestDeepCloneWithValue <CalendarDay> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Year, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <CalendarDay> { Name = Invariant($"{nameof(CalendarDay.DeepCloneWithMonthOfYear)} should deep clone object and replace {nameof(CalendarDay.MonthOfYear)} with the provided monthOfYear"), WithPropertyName = nameof(CalendarDay.MonthOfYear), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <CalendarDay>().ThatIs(_ => _.DayOfMonth <= DayOfMonth.TwentyEight); var referenceObject = A.Dummy <CalendarDay>().ThatIs(_ => !systemUnderTest.MonthOfYear.IsEqualTo(_.MonthOfYear)); var result = new SystemUnderTestDeepCloneWithValue <CalendarDay> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.MonthOfYear, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <CalendarDay> { Name = Invariant($"{nameof(CalendarDay.DeepCloneWithDayOfMonth)} should deep clone object and replace {nameof(CalendarDay.DayOfMonth)} with the provided dayOfMonth"), WithPropertyName = nameof(CalendarDay.DayOfMonth), SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <CalendarDay>().Whose(_ => new[] { MonthOfYear.January, MonthOfYear.March, MonthOfYear.March, MonthOfYear.July, MonthOfYear.August, MonthOfYear.October, MonthOfYear.December }.Contains(_.MonthOfYear)); var referenceObject = A.Dummy <CalendarDay>().ThatIs(_ => !systemUnderTest.DayOfMonth.IsEqualTo(_.DayOfMonth)); var result = new SystemUnderTestDeepCloneWithValue <CalendarDay> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.DayOfMonth, }; return(result); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <CalendarDay> { Name = "Equatable Test Scenario", ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { new CalendarDay( ReferenceObjectForEquatableTestScenarios.Year, ReferenceObjectForEquatableTestScenarios.MonthOfYear, ReferenceObjectForEquatableTestScenarios.DayOfMonth), }, ObjectsThatAreNotEqualToReferenceObject = new[] { ReferenceObjectForEquatableTestScenarios.Tweak(CalendarDayComponent.Day), ReferenceObjectForEquatableTestScenarios.Tweak(CalendarDayComponent.Month), ReferenceObjectForEquatableTestScenarios.Tweak(CalendarDayComponent.Year), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), } .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(CalendarDay))) .ToList(), }); ComparableTestScenarios .RemoveAllScenarios() .AddScenario(() => new ComparableTestScenario <CalendarDay> { Name = "Comparable Test Scenario", ReferenceObject = referenceCalendarDay, ObjectsThatAreLessThanReferenceObject = new[] { referenceCalendarDay.TweakBy(-1, CalendarDayComponent.Day), referenceCalendarDay.TweakBy(-1, CalendarDayComponent.Month), referenceCalendarDay.TweakBy(-1, CalendarDayComponent.Year), }, ObjectsThatAreGreaterThanReferenceObject = new[] { referenceCalendarDay.TweakBy(1, CalendarDayComponent.Day), referenceCalendarDay.TweakBy(1, CalendarDayComponent.Month), referenceCalendarDay.TweakBy(1, CalendarDayComponent.Year), }, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[] { referenceCalendarDay.DeepClone(), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), A.Dummy <CalendarMonth>(), A.Dummy <CalendarQuarter>(), A.Dummy <CalendarUnbounded>(), A.Dummy <CalendarYear>(), A.Dummy <FiscalMonth>(), A.Dummy <FiscalQuarter>(), A.Dummy <FiscalUnbounded>(), A.Dummy <FiscalYear>(), A.Dummy <GenericMonth>(), A.Dummy <GenericQuarter>(), A.Dummy <GenericUnbounded>(), A.Dummy <GenericYear>(), }, ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new CalendarDay[] { }, }); StringRepresentationTestScenarios .RemoveAllScenarios() .AddScenario(() => new StringRepresentationTestScenario <CalendarDay> { Name = "String Representation - case 1", SystemUnderTestExpectedStringRepresentationFunc = () => new SystemUnderTestExpectedStringRepresentation <CalendarDay> { SystemUnderTest = new CalendarDay(2017, MonthOfYear.November, DayOfMonth.Thirty), ExpectedStringRepresentation = "2017-11-30", }, }) .AddScenario(() => new StringRepresentationTestScenario <CalendarDay> { Name = "String Representation - case 2", SystemUnderTestExpectedStringRepresentationFunc = () => new SystemUnderTestExpectedStringRepresentation <CalendarDay> { SystemUnderTest = new CalendarDay(2017, MonthOfYear.February, DayOfMonth.Three), ExpectedStringRepresentation = "2017-02-03", }, }); }
static UnitTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <Unit> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'kind' is UnitOfTimeKind.Invalid", ConstructionFunc = () => { var referenceObject = A.Dummy <Unit>(); var result = new Unit( UnitOfTimeKind.Invalid, referenceObject.Granularity); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "kind is UnitOfTimeKind.Invalid" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Unit> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'granularity' is UnitOfTimeGranularity.Invalid", ConstructionFunc = () => { var referenceObject = A.Dummy <Unit>(); var result = new Unit( referenceObject.Kind, UnitOfTimeGranularity.Invalid); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "granularity is UnitOfTimeGranularity.Invalid" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Unit> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'granularity' is UnitOfTimeGranularity.Unbounded", ConstructionFunc = () => { var referenceObject = A.Dummy <Unit>(); var result = new Unit( referenceObject.Kind, UnitOfTimeGranularity.Unbounded); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "granularity is UnitOfTimeGranularity.Unbounded" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Unit> { Name = "constructor should throw ArgumentException when parameter 'granularity' is UnitOfTimeGranularity.Day and parameter 'kind' is not UnitOfTimeKind.Calendar", ConstructionFunc = () => { var result = new Unit( A.Dummy <UnitOfTimeKind>().ThatIsNot(UnitOfTimeKind.Calendar), UnitOfTimeGranularity.Day); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "granularity of UnitOfTimeGranularity.Day is only applicable when kind is UnitOfTimeKind.Calendar" }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <Unit> { Name = "DeepCloneWithKind should deep clone object and replace Kind with the provided kind", WithPropertyName = "Kind", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Unit>().Whose(_ => _.Granularity != UnitOfTimeGranularity.Day); var referenceObject = A.Dummy <Unit>().ThatIs(_ => !systemUnderTest.Kind.IsEqualTo(_.Kind)); var result = new SystemUnderTestDeepCloneWithValue <Unit> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Kind, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Unit> { Name = "DeepCloneWithGranularity should deep clone object and replace Granularity with the provided granularity", WithPropertyName = "Granularity", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Unit>(); var referenceObject = A.Dummy <Unit>().ThatIs(_ => (!systemUnderTest.Granularity.IsEqualTo(_.Granularity)) && (_.Granularity != UnitOfTimeGranularity.Day)); var result = new SystemUnderTestDeepCloneWithValue <Unit> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Granularity, }; return(result); }, }); var referenceObjectForEquatableTestScenarios = A.Dummy <Unit>().Whose(_ => _.Granularity != UnitOfTimeGranularity.Day); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <Unit> { Name = "Equatable Test Scenario", ReferenceObject = referenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new Unit[] { new Unit( referenceObjectForEquatableTestScenarios.Kind, referenceObjectForEquatableTestScenarios.Granularity), }, ObjectsThatAreNotEqualToReferenceObject = new Unit[] { new Unit( A.Dummy <Unit>().Whose(_ => (_.Granularity != UnitOfTimeGranularity.Day) && (!_.Kind.IsEqualTo(referenceObjectForEquatableTestScenarios.Kind))).Kind, referenceObjectForEquatableTestScenarios.Granularity), new Unit( referenceObjectForEquatableTestScenarios.Kind, A.Dummy <Unit>().Whose(_ => (_.Granularity != UnitOfTimeGranularity.Day) && (!_.Granularity.IsEqualTo(referenceObjectForEquatableTestScenarios.Granularity))).Granularity), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); }
static PrepareToSendNotificationResultTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentNullException when parameter 'channelToPrepareToSendOnChannelResultMap' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var result = new PrepareToSendNotificationResult( null, referenceObject.CannotPrepareToSendOnChannelAction, referenceObject.ChannelsToSendOn); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "channelToPrepareToSendOnChannelResultMap", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentException when parameter 'channelToPrepareToSendOnChannelResultMap' contains a key-value pair with a null value scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>().Whose(_ => _.ChannelToPrepareToSendOnChannelResultMap.Any()); var dictionaryWithNullValue = referenceObject.ChannelToPrepareToSendOnChannelResultMap.ToDictionary(_ => _.Key, _ => _.Value); var randomKey = dictionaryWithNullValue.Keys.ElementAt(ThreadSafeRandom.Next(0, dictionaryWithNullValue.Count)); dictionaryWithNullValue[randomKey] = null; var result = new PrepareToSendNotificationResult( dictionaryWithNullValue, referenceObject.CannotPrepareToSendOnChannelAction, referenceObject.ChannelsToSendOn); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "channelToPrepareToSendOnChannelResultMap", "contains at least one key-value pair with a null value", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentException when parameter 'channelToPrepareToSendOnChannelResultMap' values are not distinct", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var prepareToSendOnChannelResult = A.Dummy <PrepareToSendOnChannelResult>(); var channelToPrepareToSendOnChannelResultMap = new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult> { { new SlackDeliveryChannel(), prepareToSendOnChannelResult }, { new EmailDeliveryChannel(), prepareToSendOnChannelResult }, }; var result = new PrepareToSendNotificationResult( channelToPrepareToSendOnChannelResultMap, referenceObject.CannotPrepareToSendOnChannelAction, null); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "prepareToSendOnChannelResult", "contains two or more elements that are equal" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'cannotPrepareToSendOnChannelAction' is CannotPrepareToSendOnChannelAction.Unknown.", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var result = new PrepareToSendNotificationResult( referenceObject.ChannelToPrepareToSendOnChannelResultMap, CannotPrepareToSendOnChannelAction.Unknown, referenceObject.ChannelsToSendOn); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "cannotPrepareToSendOnChannelAction", "Unknown" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentNullException when parameter 'channelsToSendOn' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var result = new PrepareToSendNotificationResult( referenceObject.ChannelToPrepareToSendOnChannelResultMap, referenceObject.CannotPrepareToSendOnChannelAction, null); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "channelsToSendOn", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentException when parameter 'channelsToSendOn' contains a null element scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var result = new PrepareToSendNotificationResult( referenceObject.ChannelToPrepareToSendOnChannelResultMap, referenceObject.CannotPrepareToSendOnChannelAction, new IDeliveryChannel[0].Concat(referenceObject.ChannelsToSendOn).Concat(new IDeliveryChannel[] { null }).Concat(referenceObject.ChannelsToSendOn).ToList()); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "channelsToSendOn", "contains at least one null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <PrepareToSendNotificationResult> { Name = "constructor should throw ArgumentException when parameter 'channelsToSendOn' has a channel that's not a key in 'channelToPrepareToSendOnChannelResultMap'", ConstructionFunc = () => { var referenceObject = A.Dummy <PrepareToSendNotificationResult>(); var result = new PrepareToSendNotificationResult( new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult> { { new SlackDeliveryChannel(), A.Dummy <PrepareToSendOnChannelResult>() }, }, referenceObject.CannotPrepareToSendOnChannelAction, new[] { new EmailDeliveryChannel() }); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "channelToPrepareToSendOnChannelResultMap", "does not contain the key to search for", }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <PrepareToSendNotificationResult> { Name = "DeepCloneWithChannelToPrepareToSendOnChannelResultMap should deep clone object and replace ChannelToPrepareToSendOnChannelResultMap with the provided channelToPrepareToSendOnChannelResultMap", WithPropertyName = "ChannelToPrepareToSendOnChannelResultMap", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <PrepareToSendNotificationResult>(); var referenceObject = A.Dummy <PrepareToSendNotificationResult>().ThatIs(_ => (!systemUnderTest.ChannelToPrepareToSendOnChannelResultMap.IsEqualTo(_.ChannelToPrepareToSendOnChannelResultMap)) && systemUnderTest.ChannelsToSendOn.IsEqualTo(_.ChannelsToSendOn)); var result = new SystemUnderTestDeepCloneWithValue <PrepareToSendNotificationResult> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.ChannelToPrepareToSendOnChannelResultMap, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <PrepareToSendNotificationResult> { Name = "DeepCloneWithCannotPrepareToSendOnChannelAction should deep clone object and replace CannotPrepareToSendOnChannelAction with the provided cannotPrepareToSendOnChannelAction", WithPropertyName = "CannotPrepareToSendOnChannelAction", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <PrepareToSendNotificationResult>(); var referenceObject = A.Dummy <PrepareToSendNotificationResult>().ThatIs(_ => !systemUnderTest.CannotPrepareToSendOnChannelAction.IsEqualTo(_.CannotPrepareToSendOnChannelAction)); var result = new SystemUnderTestDeepCloneWithValue <PrepareToSendNotificationResult> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.CannotPrepareToSendOnChannelAction, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <PrepareToSendNotificationResult> { Name = "DeepCloneWithChannelsToSendOn should deep clone object and replace ChannelsToSendOn with the provided channelsToSendOn", WithPropertyName = "ChannelsToSendOn", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <PrepareToSendNotificationResult>().Whose(_ => _.ChannelToPrepareToSendOnChannelResultMap.Any()); var referenceObject = A.Dummy <PrepareToSendNotificationResult>().ThatIs(_ => (!systemUnderTest.ChannelsToSendOn.IsEqualTo(_.ChannelsToSendOn)) && _.ChannelsToSendOn.All(c => systemUnderTest.ChannelToPrepareToSendOnChannelResultMap.ContainsKey(c))); var result = new SystemUnderTestDeepCloneWithValue <PrepareToSendNotificationResult> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.ChannelsToSendOn, }; return(result); }, }); var referenceObjectForEquatableTestScenarios = A.Dummy <PrepareToSendNotificationResult>().Whose(_ => _.ChannelToPrepareToSendOnChannelResultMap.Any()); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <PrepareToSendNotificationResult> { Name = "Default Code Generated Scenario", ReferenceObject = referenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new PrepareToSendNotificationResult[] { new PrepareToSendNotificationResult( referenceObjectForEquatableTestScenarios.ChannelToPrepareToSendOnChannelResultMap, referenceObjectForEquatableTestScenarios.CannotPrepareToSendOnChannelAction, referenceObjectForEquatableTestScenarios.ChannelsToSendOn), }, ObjectsThatAreNotEqualToReferenceObject = new PrepareToSendNotificationResult[] { new PrepareToSendNotificationResult( A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (!_.ChannelToPrepareToSendOnChannelResultMap.IsEqualTo(referenceObjectForEquatableTestScenarios.ChannelToPrepareToSendOnChannelResultMap)) && referenceObjectForEquatableTestScenarios.ChannelsToSendOn.All(c => _.ChannelToPrepareToSendOnChannelResultMap.ContainsKey(c))).ChannelToPrepareToSendOnChannelResultMap, referenceObjectForEquatableTestScenarios.CannotPrepareToSendOnChannelAction, referenceObjectForEquatableTestScenarios.ChannelsToSendOn), new PrepareToSendNotificationResult( referenceObjectForEquatableTestScenarios.ChannelToPrepareToSendOnChannelResultMap, A.Dummy <PrepareToSendNotificationResult>().Whose(_ => !_.CannotPrepareToSendOnChannelAction.IsEqualTo(referenceObjectForEquatableTestScenarios.CannotPrepareToSendOnChannelAction)).CannotPrepareToSendOnChannelAction, referenceObjectForEquatableTestScenarios.ChannelsToSendOn), new PrepareToSendNotificationResult( referenceObjectForEquatableTestScenarios.ChannelToPrepareToSendOnChannelResultMap, referenceObjectForEquatableTestScenarios.CannotPrepareToSendOnChannelAction, A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (!_.ChannelsToSendOn.IsEqualTo(referenceObjectForEquatableTestScenarios.ChannelsToSendOn)) && _.ChannelsToSendOn.All(c => referenceObjectForEquatableTestScenarios.ChannelToPrepareToSendOnChannelResultMap.ContainsKey(c))).ChannelsToSendOn), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); }
static SectionTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <Section> { Name = "constructor should throw ArgumentNullException when parameter 'id' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Section>(); var result = new Section( null, referenceObject.TreeTable, referenceObject.Name, referenceObject.Title, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "id", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Section> { Name = "constructor should throw ArgumentException when parameter 'id' is white space scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Section>(); var result = new Section( Invariant($" {Environment.NewLine} "), referenceObject.TreeTable, referenceObject.Name, referenceObject.Title, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "id", "white space", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Section> { Name = "constructor should throw ArgumentNullException when parameter 'treeTable' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Section>(); var result = new Section( referenceObject.Id, null, referenceObject.Name, referenceObject.Title, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "treeTable", }, }); // Need to do this because SectionFormat is currently empty and so there isn't a way to create // two sections having all the same properties except different formats. DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <Section> { Name = "DeepCloneWithId should deep clone object and replace Id with the provided id", WithPropertyName = "Id", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Section>(); var referenceObject = A.Dummy <Section>().ThatIs(_ => !systemUnderTest.Id.IsEqualTo(_.Id)); var result = new SystemUnderTestDeepCloneWithValue <Section> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Id, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Section> { Name = "DeepCloneWithTreeTable should deep clone object and replace TreeTable with the provided treeTable", WithPropertyName = "TreeTable", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Section>(); var referenceObject = A.Dummy <Section>().ThatIs(_ => !systemUnderTest.TreeTable.IsEqualTo(_.TreeTable)); var result = new SystemUnderTestDeepCloneWithValue <Section> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.TreeTable, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Section> { Name = "DeepCloneWithTitle should deep clone object and replace Title with the provided title", WithPropertyName = "Title", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Section>(); var referenceObject = A.Dummy <Section>().ThatIs(_ => !systemUnderTest.Title.IsEqualTo(_.Title)); var result = new SystemUnderTestDeepCloneWithValue <Section> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Title, }; return(result); }, }); // Need to do this because SectionFormat is currently empty and so there isn't a way to create // two sections having all the same properties except different formats. EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <Section> { Name = "Default Code Generated Scenario", ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new Section[] { new Section( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.TreeTable, ReferenceObjectForEquatableTestScenarios.Name, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.Format), }, ObjectsThatAreNotEqualToReferenceObject = new Section[] { new Section( A.Dummy <Section>().Whose(_ => !_.Id.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Id)).Id, ReferenceObjectForEquatableTestScenarios.TreeTable, ReferenceObjectForEquatableTestScenarios.Name, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.Format), new Section( ReferenceObjectForEquatableTestScenarios.Id, A.Dummy <Section>().Whose(_ => !_.TreeTable.IsEqualTo(ReferenceObjectForEquatableTestScenarios.TreeTable)).TreeTable, ReferenceObjectForEquatableTestScenarios.Name, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.Format), new Section( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.TreeTable, ReferenceObjectForEquatableTestScenarios.Name, A.Dummy <Section>().Whose(_ => !_.Title.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Title)).Title, ReferenceObjectForEquatableTestScenarios.Format), new Section( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.TreeTable, A.Dummy <Section>().Whose(_ => !_.Name.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Name)).Name, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.Format), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); }
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 ReportTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentNullException when parameter 'id' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( null, referenceObject.Sections, referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "id", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'id' is white space scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( Invariant($" {Environment.NewLine} "), referenceObject.Sections, referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "id", "white space", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentNullException when parameter 'sections' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, null, referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "sections", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'sections' is an empty enumerable scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, new List <Section>(), referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "sections", "is an empty enumerable", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'sections' contains a null element scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, new Section[0].Concat(referenceObject.Sections).Concat(new Section[] { null }).Concat(referenceObject.Sections).ToList(), referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "sections", "contains at least one null element", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'sections' contains two or more elements with the same Id", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, new[] { new Section("duplicate", A.Dummy <TreeTable>()), new Section("unique-1", A.Dummy <TreeTable>()), new Section("unique-2", A.Dummy <TreeTable>()), new Section("duplicate", A.Dummy <TreeTable>()), }, referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "sections", "contains two or more elements with the same Id", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when the same cell object is used multiple times", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var treeTable = A.Dummy <TreeTable>(); var result = new Report( referenceObject.Id, new[] { new Section("id1", treeTable), new Section("id2", A.Dummy <TreeTable>()), new Section("id3", treeTable), }, referenceObject.Title, referenceObject.TimestampUtc, referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "One or more ICell objects are used multiple times in the report", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'timestampUtc' is a UTC DateTime", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, referenceObject.Sections, referenceObject.Title, A.Dummy <DateTime>().Whose(_ => _.Kind != DateTimeKind.Utc), referenceObject.DownloadLinks, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "timestampUtc is not in UTC" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <Report> { Name = "constructor should throw ArgumentException when parameter 'downloadLinks' contains a null element scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <Report>(); var result = new Report( referenceObject.Id, referenceObject.Sections, referenceObject.Title, referenceObject.TimestampUtc, new[] { A.Dummy <SimpleLink>(), null, A.Dummy <SimpleLink>() }, referenceObject.AdditionalInfo, referenceObject.Format); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "downloadLinks contains a null element" }, }); // Need to do this because ReportFormat is currently empty and so there isn't a way to create // two reports having all the same properties except different report formats. EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => new EquatableTestScenario <Report> { Name = "Default Code Generated Scenario", ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new Report[] { new Report( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.Sections, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.TimestampUtc, ReferenceObjectForEquatableTestScenarios.DownloadLinks, ReferenceObjectForEquatableTestScenarios.AdditionalInfo, ReferenceObjectForEquatableTestScenarios.Format), }, ObjectsThatAreNotEqualToReferenceObject = new Report[] { new Report( A.Dummy <Report>().Whose(_ => !_.Id.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Id)).Id, ReferenceObjectForEquatableTestScenarios.Sections, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.TimestampUtc, ReferenceObjectForEquatableTestScenarios.DownloadLinks, ReferenceObjectForEquatableTestScenarios.AdditionalInfo, ReferenceObjectForEquatableTestScenarios.Format), new Report( ReferenceObjectForEquatableTestScenarios.Id, A.Dummy <Report>().Whose(_ => !_.Sections.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Sections)).Sections, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.TimestampUtc, ReferenceObjectForEquatableTestScenarios.DownloadLinks, ReferenceObjectForEquatableTestScenarios.AdditionalInfo, ReferenceObjectForEquatableTestScenarios.Format), new Report( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.Sections, A.Dummy <Report>().Whose(_ => !_.Title.IsEqualTo(ReferenceObjectForEquatableTestScenarios.Title)).Title, ReferenceObjectForEquatableTestScenarios.TimestampUtc, ReferenceObjectForEquatableTestScenarios.DownloadLinks, ReferenceObjectForEquatableTestScenarios.AdditionalInfo, ReferenceObjectForEquatableTestScenarios.Format), new Report( ReferenceObjectForEquatableTestScenarios.Id, ReferenceObjectForEquatableTestScenarios.Sections, ReferenceObjectForEquatableTestScenarios.Title, ReferenceObjectForEquatableTestScenarios.TimestampUtc, A.Dummy <Report>().Whose(_ => !_.DownloadLinks.IsEqualTo(ReferenceObjectForEquatableTestScenarios.DownloadLinks)).DownloadLinks, ReferenceObjectForEquatableTestScenarios.AdditionalInfo, ReferenceObjectForEquatableTestScenarios.Format), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); // Need to do this because ReportFormat is currently empty and so there isn't a way to create // two reports having all the same properties except different report formats. DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <Report> { Name = "DeepCloneWithId should deep clone object and replace Id with the provided id", WithPropertyName = "Id", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Report>(); var referenceObject = A.Dummy <Report>().ThatIs(_ => !systemUnderTest.Id.IsEqualTo(_.Id)); var result = new SystemUnderTestDeepCloneWithValue <Report> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Id, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Report> { Name = "DeepCloneWithSections should deep clone object and replace Sections with the provided sections", WithPropertyName = "Sections", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Report>(); var referenceObject = A.Dummy <Report>().ThatIs(_ => !systemUnderTest.Sections.IsEqualTo(_.Sections)); var result = new SystemUnderTestDeepCloneWithValue <Report> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Sections, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <Report> { Name = "DeepCloneWithTitle should deep clone object and replace Title with the provided title", WithPropertyName = "Title", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <Report>(); var referenceObject = A.Dummy <Report>().ThatIs(_ => !systemUnderTest.Title.IsEqualTo(_.Title)); var result = new SystemUnderTestDeepCloneWithValue <Report> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Title, }; return(result); }, }); }
static UtcDateTimeRangeInclusiveTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario( new ConstructorArgumentValidationTestScenario <UtcDateTimeRangeInclusive> { Name = "constructor should throw ArgumentException when 'startDateTimeInUtc' is DateTimeKind.Local", ConstructionFunc = () => { var startDateTime = new DateTime(1, DateTimeKind.Local); return(new UtcDateTimeRangeInclusive(startDateTime, DateTime.UtcNow)); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "startDateTimeInUtc DateTimeKind is not Utc" }, }) .AddScenario( new ConstructorArgumentValidationTestScenario <UtcDateTimeRangeInclusive> { Name = "constructor should throw ArgumentException when 'startDateTimeInUtc' is DateTimeKind.Unspecified", ConstructionFunc = () => { var startDateTime = new DateTime(1, DateTimeKind.Unspecified); return(new UtcDateTimeRangeInclusive(startDateTime, DateTime.UtcNow)); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "startDateTimeInUtc DateTimeKind is not Utc" }, }) .AddScenario( new ConstructorArgumentValidationTestScenario <UtcDateTimeRangeInclusive> { Name = "constructor should throw ArgumentException when 'endDateTimeInUtc' is DateTimeKind.Local", ConstructionFunc = () => { var endDateTime = new DateTime(1, DateTimeKind.Local); return(new UtcDateTimeRangeInclusive(DateTime.UtcNow, endDateTime)); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "endDateTimeInUtc DateTimeKind is not Utc" }, }) .AddScenario( new ConstructorArgumentValidationTestScenario <UtcDateTimeRangeInclusive> { Name = "constructor should throw ArgumentException when 'endDateTimeInUtc' is DateTimeKind.Unspecified", ConstructionFunc = () => { var endDateTime = new DateTime(1, DateTimeKind.Unspecified); return(new UtcDateTimeRangeInclusive(DateTime.UtcNow, endDateTime)); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "endDateTimeInUtc DateTimeKind is not Utc" }, }) .AddScenario( new ConstructorArgumentValidationTestScenario <UtcDateTimeRangeInclusive> { Name = "constructor should throw ArgumentOutOfRangeException when 'startDateTimeInUtc' > 'endDateTimeInUtc'", ConstructionFunc = () => { var startDateTimeInUtc = DateTime.UtcNow; var endDateTimeInUtc = startDateTimeInUtc.AddMilliseconds(-1); return(new UtcDateTimeRangeInclusive(startDateTimeInUtc, endDateTimeInUtc)); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "startDateTimeInUtc is > endDateTimeInUtc" }, }); StringRepresentationTestScenarios .RemoveAllScenarios() .AddScenario( new StringRepresentationTestScenario <UtcDateTimeRangeInclusive> { Name = "ToString() should return string representation of date time range", SystemUnderTestExpectedStringRepresentationFunc = () => { var startDateTime = new DateTime(2019, 3, 10, 14, 4, 59, DateTimeKind.Utc); var endDateTime = new DateTime(2020, 11, 22, 9, 43, 4, DateTimeKind.Utc); return(new SystemUnderTestExpectedStringRepresentation <UtcDateTimeRangeInclusive> { SystemUnderTest = new UtcDateTimeRangeInclusive(startDateTime, endDateTime), ExpectedStringRepresentation = "03/10/2019 14:04:59 to 11/22/2020 09:43:04", }); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario( new EquatableTestScenario <UtcDateTimeRangeInclusive> { ReferenceObject = ReferenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new UtcDateTimeRangeInclusive[] { new UtcDateTimeRangeInclusive( ReferenceObjectForEquatableTestScenarios.StartDateTimeInUtc, ReferenceObjectForEquatableTestScenarios.EndDateTimeInUtc), }, ObjectsThatAreNotEqualToReferenceObject = new UtcDateTimeRangeInclusive[] { new UtcDateTimeRangeInclusive( A.Dummy <UtcDateTimeRangeInclusive>().Whose(_ => (!_.StartDateTimeInUtc.IsEqualTo(ReferenceObjectForEquatableTestScenarios.StartDateTimeInUtc)) && (_.StartDateTimeInUtc <= ReferenceObjectForEquatableTestScenarios.EndDateTimeInUtc)).StartDateTimeInUtc, ReferenceObjectForEquatableTestScenarios.EndDateTimeInUtc), new UtcDateTimeRangeInclusive( ReferenceObjectForEquatableTestScenarios.StartDateTimeInUtc, A.Dummy <UtcDateTimeRangeInclusive>().Whose(_ => (!_.EndDateTimeInUtc.IsEqualTo(ReferenceObjectForEquatableTestScenarios.EndDateTimeInUtc)) && (_.EndDateTimeInUtc >= ReferenceObjectForEquatableTestScenarios.StartDateTimeInUtc)).EndDateTimeInUtc), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <UtcDateTimeRangeInclusive> { Name = "DeepCloneWithStartDateTimeInUtc should deep clone object and replace ParentBoolProperty with the provided parentBoolProperty", WithPropertyName = "StartDateTimeInUtc", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <UtcDateTimeRangeInclusive>(); var referenceObject = A.Dummy <UtcDateTimeRangeInclusive>().ThatIs(_ => (!systemUnderTest.StartDateTimeInUtc.IsEqualTo(_.StartDateTimeInUtc)) && (_.StartDateTimeInUtc <= systemUnderTest.StartDateTimeInUtc)); var result = new SystemUnderTestDeepCloneWithValue <UtcDateTimeRangeInclusive> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.StartDateTimeInUtc, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <UtcDateTimeRangeInclusive> { Name = "DeepCloneWithEndDateTimeInUtc should deep clone object and replace ParentBoolProperty with the provided parentBoolProperty", WithPropertyName = "EndDateTimeInUtc", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <UtcDateTimeRangeInclusive>(); var referenceObject = A.Dummy <UtcDateTimeRangeInclusive>().ThatIs(_ => (!systemUnderTest.EndDateTimeInUtc.IsEqualTo(_.EndDateTimeInUtc)) && (_.EndDateTimeInUtc >= systemUnderTest.EndDateTimeInUtc)); var result = new SystemUnderTestDeepCloneWithValue <UtcDateTimeRangeInclusive> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.EndDateTimeInUtc, }; return(result); }, }); }
static SlottedCellTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentNullException when parameter 'slotIdToCellMap' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( null, referenceObject.DefaultSlotId, referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'slotIdToCellMap' is an empty dictionary scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( new Dictionary <string, INotSlottedCell>(), referenceObject.DefaultSlotId, referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap", "is an empty dictionary", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'slotIdToCellMap' contains a key-value pair with a null value scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var dictionaryWithNullValue = referenceObject.SlotIdToCellMap.ToDictionary(_ => _.Key, _ => _.Value); var randomKey = dictionaryWithNullValue.Keys.ElementAt(ThreadSafeRandom.Next(0, dictionaryWithNullValue.Count)); dictionaryWithNullValue[randomKey] = null; var result = new SlottedCell( dictionaryWithNullValue, referenceObject.DefaultSlotId, referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap", "contains at least one key-value pair with a null value", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'slotIdToCellMap' contains a white space key", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var slotIdToCellMap = referenceObject.SlotIdToCellMap.ToDictionary(_ => _.Key, _ => _.Value); slotIdToCellMap.Add(" \r\n ", A.Dummy <INotSlottedCell>()); var result = new SlottedCell( slotIdToCellMap, referenceObject.DefaultSlotId, referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap", "contains at least one key-value pair with a white space key" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentNullException when parameter 'defaultSlotId' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, null, referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "defaultSlotId", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'defaultSlotId' is white space scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, Invariant($" {Environment.NewLine} "), referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "defaultSlotId", "white space", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'slotIdToCellMap' does not contain the specified defaultSlotId", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, A.Dummy <string>(), referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap does not contain the specified defaultSlotId" }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is 0", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, referenceObject.DefaultSlotId, referenceObject.Id, 0, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "columnsSpanned is 0; must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is -1", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, referenceObject.DefaultSlotId, referenceObject.Id, -1, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "columnsSpanned is -1; must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'columnsSpanned' is negative", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var result = new SlottedCell( referenceObject.SlotIdToCellMap, referenceObject.DefaultSlotId, referenceObject.Id, A.Dummy <NegativeInteger>(), referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "must be null or >= 1.", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <SlottedCell> { Name = "constructor should throw ArgumentException when parameter 'slotIdToCellMap' contains a value whose ColumnsSpanned does not equal columnsSpanned (with null imputed to 1)", ConstructionFunc = () => { var referenceObject = A.Dummy <SlottedCell>(); var slotIdToCellMap = new Dictionary <string, INotSlottedCell> { { A.Dummy <string>(), new NullCell(columnsSpanned: referenceObject.ColumnsSpanned) }, { A.Dummy <string>(), new NullCell(columnsSpanned: referenceObject.ColumnsSpanned == null ? 2 : referenceObject.ColumnsSpanned + 1) }, { A.Dummy <string>(), new NullCell(columnsSpanned: referenceObject.ColumnsSpanned) }, }; var result = new SlottedCell( slotIdToCellMap, slotIdToCellMap.Keys.First(), referenceObject.Id, referenceObject.ColumnsSpanned, referenceObject.Details); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "slotIdToCellMap contains a cell that does not span the same number of columns as this cell." }, }); DeepCloneWithTestScenarios .RemoveAllScenarios() .AddScenario(() => new DeepCloneWithTestScenario <SlottedCell> { Name = "DeepCloneWithId should deep clone object and replace Id with the provided id", WithPropertyName = "Id", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SlottedCell>(); var referenceObject = A.Dummy <SlottedCell>().ThatIs(_ => !systemUnderTest.Id.IsEqualTo(_.Id)); var result = new SystemUnderTestDeepCloneWithValue <SlottedCell> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Id, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SlottedCell> { Name = "DeepCloneWithColumnsSpanned should deep clone object and replace ColumnsSpanned with the provided columnsSpanned", WithPropertyName = "ColumnsSpanned", SystemUnderTestDeepCloneWithValueFunc = () => { var slotIdToCellMap = new Dictionary <string, INotSlottedCell> { { A.Dummy <string>(), new NullCell() }, { A.Dummy <string>(), new NullCell() }, { A.Dummy <string>(), new NullCell() }, }; var systemUnderTest = new SlottedCell( slotIdToCellMap, slotIdToCellMap.Keys.First()); var result = new SystemUnderTestDeepCloneWithValue <SlottedCell> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = 1, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SlottedCell> { Name = "DeepCloneWithDetails should deep clone object and replace Details with the provided details", WithPropertyName = "Details", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SlottedCell>(); var referenceObject = A.Dummy <SlottedCell>().ThatIs(_ => !systemUnderTest.Details.IsEqualTo(_.Details)); var result = new SystemUnderTestDeepCloneWithValue <SlottedCell> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = referenceObject.Details, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SlottedCell> { Name = "DeepCloneWithSlotIdToCellMap should deep clone object and replace SlotIdToCellMap with the provided slotIdToCellMap", WithPropertyName = "SlotIdToCellMap", SystemUnderTestDeepCloneWithValueFunc = () => { var slotIdToCellMap = new Dictionary <string, INotSlottedCell> { { "abc", new NullCell() }, { A.Dummy <string>(), new NullCell() }, { A.Dummy <string>(), new NullCell() }, }; var systemUnderTest = new SlottedCell( slotIdToCellMap, slotIdToCellMap.Keys.First()); var result = new SystemUnderTestDeepCloneWithValue <SlottedCell> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = new Dictionary <string, INotSlottedCell> { { A.Dummy <string>(), new NullCell() }, { "abc", new NullCell() }, { A.Dummy <string>(), new NullCell() }, }, }; return(result); }, }) .AddScenario(() => new DeepCloneWithTestScenario <SlottedCell> { Name = "DeepCloneWithDefaultSlotId should deep clone object and replace DefaultSlotId with the provided defaultSlotId", WithPropertyName = "DefaultSlotId", SystemUnderTestDeepCloneWithValueFunc = () => { var systemUnderTest = A.Dummy <SlottedCell>().Whose(_ => _.SlotIdToCellMap.Count() > 1); var defaultSlotId = systemUnderTest.SlotIdToCellMap.Keys.First(_ => _ != systemUnderTest.DefaultSlotId); var result = new SystemUnderTestDeepCloneWithValue <SlottedCell> { SystemUnderTest = systemUnderTest, DeepCloneWithValue = defaultSlotId, }; return(result); }, }); EquatableTestScenarios .RemoveAllScenarios() .AddScenario(() => { var referenceObjectForEquatableTestScenarios = new SlottedCell( new Dictionary <string, INotSlottedCell> { { "abc", new NullCell(columnsSpanned: 1) }, { "def", new NullCell(columnsSpanned: 1) }, { "ghi", new NullCell(columnsSpanned: 1) }, }, "def", A.Dummy <string>(), 1, A.Dummy <string>()); return(new EquatableTestScenario <SlottedCell> { Name = "Default Code Generated Scenario", ReferenceObject = referenceObjectForEquatableTestScenarios, ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new SlottedCell[] { new SlottedCell( referenceObjectForEquatableTestScenarios.SlotIdToCellMap, referenceObjectForEquatableTestScenarios.DefaultSlotId, referenceObjectForEquatableTestScenarios.Id, referenceObjectForEquatableTestScenarios.ColumnsSpanned, referenceObjectForEquatableTestScenarios.Details), }, ObjectsThatAreNotEqualToReferenceObject = new SlottedCell[] { new SlottedCell( referenceObjectForEquatableTestScenarios.SlotIdToCellMap, referenceObjectForEquatableTestScenarios.DefaultSlotId, A.Dummy <SlottedCell>().Whose(_ => !_.Id.IsEqualTo(referenceObjectForEquatableTestScenarios.Id)).Id, referenceObjectForEquatableTestScenarios.ColumnsSpanned, referenceObjectForEquatableTestScenarios.Details), new SlottedCell( referenceObjectForEquatableTestScenarios.SlotIdToCellMap, referenceObjectForEquatableTestScenarios.DefaultSlotId, referenceObjectForEquatableTestScenarios.Id, referenceObjectForEquatableTestScenarios.ColumnsSpanned, A.Dummy <SlottedCell>().Whose(_ => !_.Details.IsEqualTo(referenceObjectForEquatableTestScenarios.Details)).Details), new SlottedCell( referenceObjectForEquatableTestScenarios.SlotIdToCellMap, referenceObjectForEquatableTestScenarios.DefaultSlotId, referenceObjectForEquatableTestScenarios.Id, null, referenceObjectForEquatableTestScenarios.Details), new SlottedCell( new Dictionary <string, INotSlottedCell> { { "abc", new NullCell(columnsSpanned: 1) }, { "def", new NullCell(columnsSpanned: 1) }, }, referenceObjectForEquatableTestScenarios.DefaultSlotId, referenceObjectForEquatableTestScenarios.Id, referenceObjectForEquatableTestScenarios.ColumnsSpanned, referenceObjectForEquatableTestScenarios.Details), new SlottedCell( referenceObjectForEquatableTestScenarios.SlotIdToCellMap, "abc", referenceObjectForEquatableTestScenarios.Id, referenceObjectForEquatableTestScenarios.ColumnsSpanned, referenceObjectForEquatableTestScenarios.Details), }, ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[] { A.Dummy <object>(), A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int?>(), A.Dummy <Guid>(), A.Dummy <ConstCell <Version> >(), A.Dummy <InputCell <Version> >(), A.Dummy <NullCell>(), A.Dummy <OperationCell <Version> >(), }, }); }); }
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); }, }); }