public NewestGoodMoviesForKidsValidation() { var less1YearSpec = new LessThanOneYearSpecification(); var forKidsSpec = new MovieForKidsSpecification(); var bestRatedSpec = new BestRatedFilmsSpecification(); base.Add("less1YearSpec", new Rule <Movie>(less1YearSpec, "This movie was released over a year ago.")); base.Add("forKidsSpec", new Rule <Movie>(forKidsSpec, "This film is not for children.")); base.Add("bestRatedSpec", new Rule <Movie>(bestRatedSpec, "This film is not well rated.")); }
public void Specification_NotSpecification_ShouldFilterMovies() { // Arrange var movieCount = MovieFactory.GetMixedMovies().Count(m => m.MpaaRating > MpaaRating.PG && m.Rating >= 4); var kidSpec = new MovieForKidsSpecification(); var dirBest = new BestRatedFilmsSpecification(); var movieSpec = dirBest.And(kidSpec.Not()); // Act var result = MovieFactory.GetMixedMovies().Where(movieSpec.IsSatisfiedBy); // Assert Assert.Equal(movieCount, result.Count()); }
public void Specification_OrSpecification_ShouldFilterMovies() { // Arrange var movieCount = MovieFactory.GetMixedMovies().Count(m => m.MpaaRating <= MpaaRating.PG || // For kids OR m.Rating >= 4); // Best Rates var kidSpec = new MovieForKidsSpecification(); var dirBest = new BestRatedFilmsSpecification(); var movieSpec = kidSpec.Or(dirBest); // Act var result = MovieFactory.GetMixedMovies().Where(movieSpec.IsSatisfiedBy); // Assert Assert.Equal(movieCount, result.Count()); }