static UnitOfTimeTest()
        {
            var referenceUnitOfTime = A.Dummy <FiscalYear>();

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <UnitOfTime>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceUnitOfTime,
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    new FiscalYear(referenceUnitOfTime.Year - 1),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    new FiscalYear(referenceUnitOfTime.Year + 1),
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceUnitOfTime.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                },
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject =
                    TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(FiscalYear)).ToList(),
            });
        }
        static GenericUnboundedTest()
        {
            var referenceGenericUnbounded = A.Dummy <GenericUnbounded>();

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <GenericUnbounded>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceGenericUnbounded,
                ObjectsThatAreLessThanReferenceObject = new GenericUnbounded[]
                {
                },
                ObjectsThatAreGreaterThanReferenceObject = new GenericUnbounded[]
                {
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceGenericUnbounded.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                }
                .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(GenericUnbounded)))
                .ToList(),
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new GenericUnbounded[]
                {
                },
            });

            StringRepresentationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new StringRepresentationTestScenario <GenericUnbounded>
            {
                Name = "String Representation - case 1",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <GenericUnbounded>
                {
                    SystemUnderTest = new GenericUnbounded(),
                    ExpectedStringRepresentation = "generic unbounded",
                },
            });
        }
        static CalendarUnitOfTimeTest()
        {
            var referenceCalendarUnitOfTime = A.Dummy <CalendarYear>();

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <CalendarUnitOfTime>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceCalendarUnitOfTime,
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    new CalendarYear(referenceCalendarUnitOfTime.Year - 1),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    new CalendarYear(referenceCalendarUnitOfTime.Year + 1),
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceCalendarUnitOfTime.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                }
                .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.UnitOfTimeKind != UnitOfTimeKind.Calendar))
                .ToList(),
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new CalendarUnitOfTime[]
                {
                    A.Dummy <CalendarDay>(),
                    A.Dummy <CalendarMonth>(),
                    A.Dummy <CalendarQuarter>(),
                    A.Dummy <CalendarUnbounded>(),
                },
            });
        }
        static GenericQuarterTest()
        {
            var referenceGenericQuarter = A.Dummy <GenericQuarter>();

            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GenericQuarter>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' is < 0",
                ConstructionFunc = () => new GenericQuarter(A.Dummy <NegativeInteger>(), referenceGenericQuarter.QuarterNumber),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GenericQuarter>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 0",
                ConstructionFunc = () => new GenericQuarter(0, referenceGenericQuarter.QuarterNumber),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GenericQuarter>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 10000",
                ConstructionFunc = () => new GenericQuarter(10000, referenceGenericQuarter.QuarterNumber),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GenericQuarter>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' > 9999",
                ConstructionFunc = () => new GenericQuarter(A.Dummy <PositiveInteger>().ThatIs(_ => _ > 9999, -1), referenceGenericQuarter.QuarterNumber),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GenericQuarter>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'quarterNumber' is QuarterNumber.Invalid",
                ConstructionFunc = () => new GenericQuarter(referenceGenericQuarter.Year, QuarterNumber.Invalid),
                ExpectedExceptionMessageContains = new[] { "quarterNumber", "Invalid" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            });

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <GenericQuarter>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceGenericQuarter,
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    referenceGenericQuarter.TweakBy(-1, GenericQuarterComponent.Quarter),
                    referenceGenericQuarter.TweakBy(-1, GenericQuarterComponent.Year),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    referenceGenericQuarter.TweakBy(1, GenericQuarterComponent.Quarter),
                    referenceGenericQuarter.TweakBy(1, GenericQuarterComponent.Year),
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceGenericQuarter.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                }
                .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(GenericQuarter)))
                .ToList(),
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new GenericQuarter[]
                {
                },
            });

            StringRepresentationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new StringRepresentationTestScenario <GenericQuarter>
            {
                Name = "String Representation - case 1",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <GenericQuarter>
                {
                    SystemUnderTest = new GenericQuarter(2017, QuarterNumber.Q1),
                    ExpectedStringRepresentation = "1Q2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <GenericQuarter>
            {
                Name = "String Representation - case 2",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <GenericQuarter>
                {
                    SystemUnderTest = new GenericQuarter(2020, QuarterNumber.Q4),
                    ExpectedStringRepresentation = "4Q2020",
                },
            });
        }
Exemple #5
0
        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 FiscalMonthTest()
        {
            var referenceFiscalMonth = A.Dummy <FiscalMonth>();

            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <FiscalMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' is < 0",
                ConstructionFunc = () => new FiscalMonth(A.Dummy <NegativeInteger>(), referenceFiscalMonth.MonthNumber),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <FiscalMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 0",
                ConstructionFunc = () => new FiscalMonth(0, referenceFiscalMonth.MonthNumber),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <FiscalMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 10000",
                ConstructionFunc = () => new FiscalMonth(10000, referenceFiscalMonth.MonthNumber),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <FiscalMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' > 9999",
                ConstructionFunc = () => new FiscalMonth(A.Dummy <PositiveInteger>().ThatIs(_ => _ > 9999, -1), referenceFiscalMonth.MonthNumber),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <FiscalMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'monthNumber' is MonthNumber.Invalid",
                ConstructionFunc = () => new FiscalMonth(referenceFiscalMonth.Year, MonthNumber.Invalid),
                ExpectedExceptionMessageContains = new[] { "monthNumber", "Invalid" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            });

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <FiscalMonth>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceFiscalMonth,
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    referenceFiscalMonth.TweakBy(-1, FiscalMonthComponent.Month),
                    referenceFiscalMonth.TweakBy(-1, FiscalMonthComponent.Year),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    referenceFiscalMonth.TweakBy(1, FiscalMonthComponent.Month),
                    referenceFiscalMonth.TweakBy(1, FiscalMonthComponent.Year),
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceFiscalMonth.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                }
                .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(FiscalMonth)))
                .ToList(),
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new FiscalMonth[]
                {
                },
            });

            StringRepresentationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 1",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.One),
                    ExpectedStringRepresentation = "1st month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 2",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Two),
                    ExpectedStringRepresentation = "2nd month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 3",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Three),
                    ExpectedStringRepresentation = "3rd month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 4",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Four),
                    ExpectedStringRepresentation = "4th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 5",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Five),
                    ExpectedStringRepresentation = "5th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 6",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Six),
                    ExpectedStringRepresentation = "6th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 7",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Seven),
                    ExpectedStringRepresentation = "7th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 8",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Eight),
                    ExpectedStringRepresentation = "8th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 9",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Nine),
                    ExpectedStringRepresentation = "9th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 10",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Ten),
                    ExpectedStringRepresentation = "10th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 11",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Eleven),
                    ExpectedStringRepresentation = "11th month of FY2017",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <FiscalMonth>
            {
                Name = "String Representation - case 12",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <FiscalMonth>
                {
                    SystemUnderTest = new FiscalMonth(2017, MonthNumber.Twelve),
                    ExpectedStringRepresentation = "12th month of FY2017",
                },
            });
        }
Exemple #7
0
        static CalendarMonthTest()
        {
            var referenceCalendarMonth = A.Dummy <CalendarMonth>();

            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CalendarMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' is < 0",
                ConstructionFunc = () => new CalendarMonth(A.Dummy <NegativeInteger>(), referenceCalendarMonth.MonthOfYear),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CalendarMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 0",
                ConstructionFunc = () => new CalendarMonth(0, referenceCalendarMonth.MonthOfYear),
                ExpectedExceptionMessageContains = new[] { "'year' < '1'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CalendarMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' = 10000",
                ConstructionFunc = () => new CalendarMonth(10000, referenceCalendarMonth.MonthOfYear),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CalendarMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'year' > 9999",
                ConstructionFunc = () => new CalendarMonth(A.Dummy <PositiveInteger>().ThatIs(_ => _ > 9999, -1), referenceCalendarMonth.MonthOfYear),
                ExpectedExceptionMessageContains = new[] { "'year' > '9999'" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CalendarMonth>
            {
                Name             = "Constructor should throw ArgumentOutOfRangeException when parameter 'monthOfYear' is MonthOfYear.Invalid",
                ConstructionFunc = () => new CalendarMonth(referenceCalendarMonth.Year, MonthOfYear.Invalid),
                ExpectedExceptionMessageContains = new[] { "monthOfYear", "Invalid" },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
            });

            ComparableTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ComparableTestScenario <CalendarMonth>
            {
                Name            = "Comparable Test Scenario",
                ReferenceObject = referenceCalendarMonth,
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    referenceCalendarMonth.TweakBy(-1, CalendarMonthComponent.Month),
                    referenceCalendarMonth.TweakBy(-1, CalendarMonthComponent.Year),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    referenceCalendarMonth.TweakBy(1, CalendarMonthComponent.Month),
                    referenceCalendarMonth.TweakBy(1, CalendarMonthComponent.Year),
                },
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    referenceCalendarMonth.DeepClone(),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new[]
                {
                    A.Dummy <object>(),
                    A.Dummy <string>(),
                    A.Dummy <int>(),
                    A.Dummy <int?>(),
                    A.Dummy <Guid>(),
                }
                .Concat(TestCommon.GetDummyOfEachUnitOfTimeKind().Where(_ => _.GetType() != typeof(CalendarMonth)))
                .ToList(),
                ObjectsThatDeriveFromScenarioTypeButAreNotOfTheSameTypeAsReferenceObject = new CalendarMonth[]
                {
                },
            });

            StringRepresentationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new StringRepresentationTestScenario <CalendarMonth>
            {
                Name = "String Representation - case 1",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <CalendarMonth>
                {
                    SystemUnderTest = new CalendarMonth(2017, MonthOfYear.November),
                    ExpectedStringRepresentation = "2017-11",
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <CalendarMonth>
            {
                Name = "String Representation - case 2",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                                                                  new SystemUnderTestExpectedStringRepresentation <CalendarMonth>
                {
                    SystemUnderTest = new CalendarMonth(2017, MonthOfYear.February),
                    ExpectedStringRepresentation = "2017-02",
                },
            });
        }