示例#1
0
 public LibraryManager(MetadataAccessor accessor, IEnumerable<DataManager> dataManagers)
 {
     m_libraryPaths = new List<string>();
     m_movies = new MovieLibrary();
     m_accessor = accessor;
     m_dataManagers = new List<DataManager>(dataManagers);
 }
示例#2
0
        public void Before_Each_Test()
        {
            _critic = MockRepository.GenerateMock<IMovieCritic>();

            // By default a dynamic mock returns false
            _movie1 = MockRepository.GenerateMock<IMovie>();
            _movie2 = MockRepository.GenerateMock<IMovie>();
            _movie3 = MockRepository.GenerateMock<IMovie>();

            _sut = new MovieLibrary(_critic);
        }
        /// <summary>
        /// Setup the movie
        /// </summary>
        protected override void GivenThat()
        {
            base.GivenThat();

            // Create all the dependencies
            this._critic = new MockMovieCritic();

            this._notifier = new MockSocialMediaNotifier();

            // Initialize the SUT
            this.Sut = new MovieLibrary(this._critic, this._notifier);

            this._movie = new MockMovie();
        }
示例#4
0
        public void When_ListingNV_Should_Throw_Exception_If_Missing_Critic()
        {
            // Create the library without critic
            _sut = new MovieLibrary(null);

            Assert.Throws<MissingCriticException>(() => _sut.ListNonViolent(), "Critic Exception");
        }
示例#5
0
        public void WhenListingNonViolentMoviesTheCriticShouldBeAsked()
        {
            this._library = new MovieLibrary(_critic);

            var movie1 = _mockery.StrictMock<IMovie>();
            var movie2 = _mockery.StrictMock<IMovie>();
            var movie3 = _mockery.StrictMock<IMovie>();

            using (_mockery.Record())
            {
                SetupResult.For(_critic.IsViolent(movie1)).Return(true);
                SetupResult.For(_critic.IsViolent(movie2)).Return(false);
                SetupResult.For(_critic.IsViolent(movie3)).Return(false);
            }

            using (_mockery.Playback())
            {
                _library.Add(movie1);
                _library.Add(movie2);
                _library.Add(movie3);
                var actual = _library.ListNonViolent();

                Assert.AreEqual(2, actual.Count());
                Assert.DoesNotContain(actual, movie1);
                Assert.Contains(actual, movie2);
                Assert.Contains(actual, movie3);
            }
        }
示例#6
0
 public void BeforeEachTest()
 {
     this._mockery = new MockRepository();
     this._critic = _mockery.StrictMock<IMovieCritic>();
     this._library = new MovieLibrary(this._critic);
 }
示例#7
0
        public void WhenListingNonViolentWeShouldNotGetACriticException()
        {
            this._library = new MovieLibrary(_critic);

            var movie = _mockery.StrictMock<IMovie>();

            using( _mockery.Record() )
            {
                SetupResult.For(_critic.IsViolent(null))
                    .IgnoreArguments()
                    .Throw(new NotImplementedException("Critic Exception"));
            }

            using( _mockery.Playback())
            {
                _library.Add(movie);

                var actual = _library.ListNonViolent();

                Assert.IsTrue(actual.Count( ) > 0, "The collection should be empty");
            }
        }