Commit b1c7c45
Changed files (2)
domain
test
domain/movie_library.go
@@ -53,6 +53,12 @@ func (self *MovieLibrary) FindAllMoviesPublishedAfter2004() []Movie {
})
}
+func (self *MovieLibrary) FindAllMoviesPublishedBetween1982And2003() []Movie {
+ return self.FindAll(func(x Movie) bool {
+ return x.Year > 1982 && x.Year < 2003
+ })
+}
+
func (self *MovieLibrary) Add(movie Movie) {
found := self.Find(func(x Movie) bool {
return x.Equals(movie)
test/unit/movie_library_test.go
@@ -95,5 +95,12 @@ func TestMovieLibrary(t *testing.T) {
assert.ElementsMatch(t, expected, movies)
})
+
+ t.Run("returns all movies released between 1982 and 2003 - inclusive", func(t *testing.T) {
+ movies := subject.FindAllMoviesPublishedBetween1982And2003()
+ expected := [...]domain.Movie{shawshank_redemption, chasing_amy, toy_story, monsters_inc}
+
+ assert.ElementsMatch(t, expected, movies)
+ })
})
}