Esempio n. 1
0
        public void Init()
        {
            _mockAnalysisGroupRepository = new Mock <IAnalysisGroupRepository>();
            _mockCampaignRepository      = new Mock <ICampaignRepository>();
            _mockClashRepository         = new Mock <IClashRepository>();
            _mockProductRepository       = new Mock <IProductRepository>();
            _mockUsersRepository         = new Mock <IUsersRepository>();
            _mapper  = AutoMapperInitializer.Initialize(AutoMapperConfig.SetupAutoMapper);
            _fixture = new Fixture();

            _validator = new CreateAnalysisGroupModelValidator(new CreateAnalysisGroupModelValidation(_mockAnalysisGroupRepository.Object,
                                                                                                      _mockCampaignRepository.Object,
                                                                                                      _mockClashRepository.Object, _mockProductRepository.Object, _mapper));

            var request = new HttpRequestMessage();

            request.SetConfiguration(new HttpConfiguration());

            _controller = new AnalysisGroupsController(_mockAnalysisGroupRepository.Object,
                                                       _mockCampaignRepository.Object,
                                                       _mockClashRepository.Object,
                                                       _mockProductRepository.Object,
                                                       _mockUsersRepository.Object,
                                                       _validator,
                                                       null,
                                                       _mapper)
            {
                ControllerContext = new HttpControllerContext {
                    Request = request
                }
            };

            HttpContext.Current = new HttpContext(
                new HttpRequest("", "http://test.com", ""),
                new HttpResponse(new StringWriter())
                );
            HttpContext.Current.SetCurrentUser(_fixture.Create <User>());

            _ = _mockProductRepository
                .Setup(x => x.GetAdvertisers(It.IsAny <ICollection <string> >()))
                .Returns(new List <ProductAdvertiserModel> {
                new ProductAdvertiserModel
                {
                    AdvertiserIdentifier = TestAdvertiserId,
                    AdvertiserName       = "some advertiser"
                }
            });
        }
Esempio n. 2
0
 public void Dispose()
 {
     _controller = null;
     _mapper     = null;
 }
Esempio n. 3
0
 public void Cleanup()
 {
     _controller = null;
     _mapper     = null;
 }