Exemple #1
0
        public Schedule And(Schedule input)
        {
            if (input == null) throw new ArgumentNullException("input");

            // Note: use Or here instead of And
            Content = Content.Or(input.Content);

            return this;
        }
		public void ItShouldInitializeTheContentPropertyFromTheConstructor([Frozen] ISpecification<DateTime> content)
		{
			// Arrange
			var sut = new Schedule(content);

			// Act
			var result = sut.Content;

			// Assert
			result.Should().BeSameAs(content);
		}
		public void ItShouldReturnTheSutToContinueTheFluentChain(IFixture fixture, Schedule additional)
		{
			// Arrange
			var sut = fixture.Create<Schedule>();

			// Act
			var result = sut.And(additional);

			// Assert
			result.Should().BeSameAs(sut);
		} 
		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);
		}
		public void ItShouldReturnTheCorrectCompositeSpecification(IFixture fixture)
		{
			// Arrange
			var lhsSpec = fixture.Create<ISpecification<DateTime>>();
			A.CallTo(() => lhsSpec.ToString()).Returns("LHS Spec");

			var rhsSpec = fixture.Create<ISpecification<DateTime>>();
			A.CallTo(() => rhsSpec.ToString()).Returns("RHS Spec");

			var additional = new Schedule(rhsSpec);
			var sut = new Schedule(lhsSpec);

			var likness = lhsSpec.AsSource()
								.OfLikeness<OrSpecification<DateTime>>()
								.With(x => x.LHS).EqualsWhen((single, composite) => composite.LHS == lhsSpec)
								.With(x => x.RHS).EqualsWhen((single, composite) => composite.RHS == rhsSpec);

			// Act
			var result = sut.And(additional);

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

			likness.ShouldEqual(result.Content.As<OrSpecification<DateTime>>());
		}