コード例 #1
0
        public void FilmsWithDifferentIdsShouldBeUnequalAndShouldHaveUnequalHashCodes()
        {
            Film film1 = new FilmBuilder().Build();
            Film film2 = new FilmBuilder().WithId(2L).WithTitle("Star Wars: The Empire Strikes Back").ReleasedOn(new DateTime(1987, 1, 21)).WithStockOf(5).WithGenre(Genre.Science_Fiction).Build();

            Assert.That(film1, Is.Not.EqualTo(film2));
            Assert.That(film1.GetHashCode(), Is.Not.EqualTo(film2.GetHashCode()));
        }
コード例 #2
0
        public void ConstructorShouldSetProperties()
        {
            Film film = new FilmBuilder().Build();

            film.Title.Should().Be("Aliens");
            film.Released.Should().Be(new DateTime(1984, 1, 20));
            film.Stock.Should().Be(5);
            film.Genre.Should().Be(Genre.Science_Fiction);
        }
コード例 #3
0
        public void InsertAddsFilmToCollection()
        {
            int collectionCountAtTimeOfCall = 0;

            serializer.Setup(s => s.Write(It.IsAny <ICollection <Film> >())).Callback((ICollection <Film> collection) => collectionCountAtTimeOfCall = collection.Count());

            CollectionFilmRepository sut = new CollectionFilmRepository(serializer.Object);

            Film film3 = new FilmBuilder().WithId(3L).WithTitle("Blade Runner").ReleasedOn(new DateTime(1982, 12, 25)).WithStockOf(5).WithGenre(Genre.Science_Fiction).Build();
            long id    = sut.Insert(film3);

            Assert.That(collectionCountAtTimeOfCall, Is.EqualTo(3));
            serializer.Verify(s => s.Write(films), Times.Once);
        }