Esempio n. 1
0
        public Schedule From(Month periodStart)
        {
            if (periodStart == null) throw new ArgumentNullException("periodStart");

            if(PeriodStart != null)
                throw new InvalidOperationException("The starting month has already been set");

            PeriodStart = periodStart;

            return this;
        }
Esempio n. 2
0
		public void MonthNumberShouldBeExposedCorrectly(Generator<int> generator)
		{
			// Arrange

			// Ensure the month number is between 1 and 12 inclusive
			var expected = generator.First(x => x >= 1 && x <= 12);

			var sut = new Month(expected);

			// Act
			var result = sut.Number;

			// Assert
			result.Should().Be(expected);
		}
		public void ItShouldReturnTrueIfDateMonthIsEqualToEndMonth()
		{
			// Arrange
			var startMonth = new Month(1);
			var endMonth = new Month(12);

			var dateToTest = new DateTime(DUMMY_YEAR, endMonth.Number, DUMMY_DAY);

			var sut = new PeriodInYear(startMonth, endMonth);

			// Act
			var result = sut.IsSatisfiedBy(dateToTest);

			// Assert
			result.Should().BeTrue();
		}
Esempio n. 4
0
        public Schedule Until(Month periodEnd)
        {
            if (periodEnd == null) throw new ArgumentNullException("periodEnd");

            if(PeriodStart == null)
                throw new InvalidOperationException("The starting period must be set first");

            var periodInYearSpec = new PeriodInYear(PeriodStart, periodEnd);

            Content = Content.And(periodInYearSpec);

            return this;
        }
Esempio n. 5
0
		public void ItShouldReturnTheSutToContinueTheFluentChain(IFixture fixture, Month startMonth, Month endMonth)
		{
			// Arrange
			var sut = fixture.Create<Schedule>();

			sut.From(startMonth);

			// Act
			var result = sut.Until(endMonth);

			// Assert
			result.Should().BeSameAs(sut);
		} 
Esempio n. 6
0
		public void ItShouldReturnAnAndCompositeSpecificationWithTheCorrectRHS(IFixture fixture, Month startMonth, Month endMonth)
		{
			// Arrange
			var rhsSpec = fixture.Create<ISpecification<DateTime>>();
			A.CallTo(() => rhsSpec.ToString()).Returns("RHS Spec");

			var expectedSpec = new PeriodInYear(startMonth, endMonth);

			var sut = fixture.Create<Schedule>();

			sut.From(startMonth);

			var likness = expectedSpec.AsSource()
			                      .OfLikeness<PeriodInYear>();

			// Act
			var result = sut.Until(endMonth);

			// Assert
			result.Should().NotBeNull();
			result.Content.Should().NotBeNull();
			result.Content.Should().BeOfType<AndSpecification<DateTime>>();

			var compositeSpec = result.Content.As<AndSpecification<DateTime>>();

			compositeSpec.RHS.Should().BeOfType<PeriodInYear>();

			var periodInYearSpec = compositeSpec.RHS.As<PeriodInYear>();

			likness.ShouldEqual(periodInYearSpec);
		}
Esempio n. 7
0
		public void ItShouldReturnAnAndCompositeSpecificationWithTheCorrectLHS(IFixture fixture, Month startMonth, Month endMonth)
		{
			// Arrange
			var lhsSpec = fixture.Create<ISpecification<DateTime>>();
			A.CallTo(() => lhsSpec.ToString()).Returns("LHS Spec");

			var sut = new Schedule(lhsSpec);

			sut.From(startMonth);

			// Act
			var result = sut.Until(endMonth);

			// Assert
			result.Should().NotBeNull();
			result.Content.Should().NotBeNull();
			result.Content.Should().BeOfType<AndSpecification<DateTime>>();

			var compositeSpec = result.Content.As<AndSpecification<DateTime>>();

			compositeSpec.LHS.Should().BeSameAs(lhsSpec);
		}
Esempio n. 8
0
		public void ItShouldSetTheStartingMonthProperty(IFixture fixture, Month month)
		{
			// Arrange
			var sut = fixture.Create<Schedule>();

			// Act
			var result = sut.From(month);

			// Assert
			result.Should().NotBeNull();
			result.PeriodStart.Should().BeSameAs(month);
		}
		public void ItShouldReturnFalseIfDateMonthIsAfterEndMonth()
		{
			// Arrange
			var startMonth = new Month(1);
			var endMonth = new Month(11);
			var monthAfterEnd = new Month(12);

			var dateToTest = new DateTime(DUMMY_YEAR, monthAfterEnd.Number, DUMMY_DAY);

			var sut = new PeriodInYear(startMonth, endMonth);

			// Act
			var result = sut.IsSatisfiedBy(dateToTest);

			// Assert
			result.Should().BeFalse();
		}