public void Cleanup()
 {
     _repositoryMock = null;
     _filterHelperMock = null;
     _controllerHelperMock = null;
     sut = null;
 }
 public void SpeakersController_Ctor_throws_exception_if_speakers_filter_is_null()
 {
     sut = new SpeakersController(_repositoryMock.Object, null, _controllerHelperMock.Object);
 }
        public void StartUp()
        {
            _repositoryMock = new Mock<IGenericRepository>();
            _filterHelperMock = new Mock<IFilterSpeakerHelper>();
            _controllerHelperMock = new Mock<IControllerHelper>();
            requestMock = new Mock<HttpRequestBase>();

            speakers = new[]
            {
                new Speaker
                {
                    User = new Attendee()
                },
                new Speaker
                {
                    User = new Attendee()
                }
            };

            _repositoryMock.Setup(e => e.GetAll<Speaker>())
                .Returns(speakers);

            _filterHelperMock.Setup(e => e.Speakers)
                .Returns(speakers);

            sut = new SpeakersController(_repositoryMock.Object, _filterHelperMock.Object,
                _controllerHelperMock.Object);

            _controllerHelperMock.Setup(e => e.GetPageSize(0, It.IsAny<int>(), 2)).Returns(2);

            requestMock.SetupGet(x => x.Headers).Returns(
                new WebHeaderCollection
                {
                    {"X-Requested-With", "XMLHttpRequest"}
                });
            requestMock.Setup(e => e.IsAuthenticated).Returns(true);
            var context = new Mock<HttpContextBase>();
            context.SetupGet(x => x.Request).Returns(requestMock.Object);
            sut.ControllerContext = new ControllerContext(context.Object, new RouteData(), sut);

            _repositoryMock.Setup(e => e.GetById<Speaker>(1, null)).Returns((Speaker) null);
            _repositoryMock.Setup(e => e.GetById<Speaker>(2, null)).Returns(new Speaker());
        }