public void Cleanup()
 {
     _repositoryMock = null;
     sut = null;
 }
        public void StartUp()
        {
            _repositoryMock = new Mock<IGenericRepository>();
            _filterHelperMock = new Mock<IFilterConferenceHelper>();
            _controllerHelperMock = new Mock<IControllerHelper>();
            requestMock = new Mock<HttpRequestBase>();

            var city1 = new City { Name = "Asd", CityID = 1, Country = new Country { Name = "Asd" } };
            country1 = new Country { Name = "Asd", CountryID = 1, Cities = new[] { city1 } };
            var city2 = new City { Name = "Test", CityID = 2, Country = new Country { Name = "Test" } };
            var country2 = new Country { Name = "Test", CountryID = 2, Cities = new[] { city2 } };
            var tag1 = new Tag { TagID = 1, Name = "testTag1" };
            var tag2 = new Tag { TagID = 2, Name = "testTag2" };
            var tag3 = new Tag { TagID = 3, Name = "testTag3" };
            conferences = new[]
            {
                new Conference
                {
                    ConferenceID = 0,
                    Name = "asd",
                    TargetCity = city2,
                    TargetCountry = country2,
                    Tags = new List<Tag> {tag1, tag2}
                },
                new Conference
                {
                    ConferenceID = 1,
                    Name = "test",
                    TargetCity = city1,
                    TargetCountry = country1,
                    Tags = new List<Tag> {tag3}
                }
            };

            _repositoryMock.Setup(e => e.GetAll<Conference>())
                .Returns(conferences);

            _filterHelperMock.Setup(e => e.Conferences)
                .Returns(conferences);

            _repositoryMock.Setup(e => e.GetAll<Country>())
                .Returns(new[]
                {country1, country2});

            _repositoryMock.Setup(e => e.GetAll<City>())
                .Returns(new[]
                {city1, city2});

            _repositoryMock.Setup(e => e.GetAll<Tag>()).Returns(new[] { tag1, tag2, tag3 });

            sut = new ConferencesController(_filterHelperMock.Object,
                _repositoryMock.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<Conference>(1, null)).Returns((Conference)null);
            _repositoryMock.Setup(e => e.GetById<Conference>(2, null)).Returns(new Conference());
        }
 public void ConferencesController_Ctor_throws_exception_if_repository_is_null()
 {
     sut = new ConferencesController(_filterHelperMock.Object, null, _controllerHelperMock.Object);
 }