public OffersManager initOffersManager(
            IOfferRepository IOfferRepository,
            IOfferAttributeRepository IOfferAttributeRepository,
            IProviderRepository IProviderRepository,
            IAttributeRepository IAttributeRepository, 
            ILiveMatch ILiveMatch,
            IRespondentCatalog IRespondentCatalog,
            IQuotaExpressionRepository IQuotaExpressionRepository,
            IQuotaMappingRepository IQuotaMappingRepository,
            ISampleMappingRepository ISampleMappingRepository,
            IGMIStudy IGMIStudy,
            ISteamStudy ISteamStudy,
            IQuotaLiveMatch IQuotaLiveMatch
            )
        {
            OffersManager OffersManager = new OffersManager(
            IOfferRepository,
            IOfferAttributeRepository,
            IProviderRepository,
            IAttributeRepository,
            ILiveMatch,
            IRespondentCatalog,
            IQuotaExpressionRepository,
            IQuotaMappingRepository,
            ISampleMappingRepository,
            IGMIStudy,
            ISteamStudy,
            IQuotaLiveMatch);

            return OffersManager;
        }
        public void GetActiveLiveOfferAttributesFailureTest()
        {
            Request = new InitClass().initRequest("liveoffers");
            IOfferRepository.Setup(i => i.SelectByID(new Guid())).Returns(new InitObject().OfferObject(1, false));
            IOfferAttributeRepository.Setup(i => i.GetOfferAttributes(new Guid())).Returns(new InitObject().ListOfferUnpublishedAttributeApiObject());
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOfferAttributes(Request, It.IsAny<string>(), new Guid().ToString());

            Assert.Null(result.Attributes);
            Assert.NotNull(result.Errors);
            Assert.True(result.Errors.Exists(i => i.Code == 2017));
        }
        public void GetTestOfferQuotaExpressionTest()
        {
            Request = new InitClass().initRequest("testoffers");
            QuotaCellSetup(true, true, true);
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOfferQuotaExpression(Request, It.IsAny<string>(), new Guid().ToString());

            Assert.NotNull(result.QuotaCells);
            Assert.Null(result.Errors);
        }
        public void GetTestOfferAttributesTest()
        {
            Request = new InitClass().initRequest("testoffers");
            IOfferRepository.Setup(i => i.SelectByID(new Guid())).Returns(new InitObject().OfferObject(1, true));
            IOfferAttributeRepository.Setup(i => i.GetOfferAttributes(new Guid())).Returns(new InitObject().ListOfferAttributeApiObject());
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOfferAttributes(Request, It.IsAny<string>(), new Guid().ToString());

            Assert.NotNull(result.Attributes);
            Assert.NotEmpty(result.Attributes);
            Assert.Equal(2, result.Attributes.Count);
            Assert.Empty(result.Errors);
        }
        public void GetAllTestOffersWithPIDWithoutRequiredAttributesFailureTest()
        {
            PIDSetup(true, false);
            Request = new InitClass().initRequest("testoffers");
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOffersByPid(Request, It.IsAny<string>(), It.IsAny<string>());

            Assert.Null(result.Offers);
            Assert.NotNull(result.Errors);
            Assert.True(result.Errors.Exists(i => i.Code == 2008));
        }
        public void GetAllTestOffersWithPIDTest()
        {
            PIDSetup(true, true);
            Request = new InitClass().initRequest("testoffers", "COREcontact_country=165&CORElanguage=14");
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOffersByPid(Request, It.IsAny<string>(), It.IsAny<string>());

            Assert.NotNull(result.Offers);
            Assert.Equal(1, result.Offers.Count);
            Assert.Equal("Xunit Offer", result.Offers[0].Title);
            Assert.Empty(result.Errors);
        }
        public void GetAllTestOffersTest()
        {
            List<OfferApiObject> offersData = new List<OfferApiObject>()
            {
                new OfferApiObject()
            };

            IOfferRepository.Setup(i => i.GetActiveOffersHavingValidTerm(true)).Returns(offersData);
            IOfferAttributeRepository.Setup(i => i.GetOfferAttributes(new Guid())).Returns(new List<OfferAttributeApiObject>());
            IProviderRepository.Setup(i => i.SelectByProviderId(It.IsAny<string>())).Returns(new ProviderObject());
            Request = new InitClass().initRequest("testoffers");
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOffers(Request, It.IsAny<string>());

            Assert.NotEmpty(result.Offers);
            Assert.Empty(result.Errors);
        }
        public void GetAllTestOffersFailureTest()
        {
            List<OfferApiObject> offersData = new List<OfferApiObject>();

            IOfferRepository.Setup(i => i.GetActiveOffersHavingValidTerm(true)).Returns(offersData);
            Request = new InitClass().initRequest("liveoffers");
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOffers(Request, It.IsAny<string>());

            Assert.Null(result.Offers);
            Assert.NotNull(result.Errors);
            Assert.True(result.Errors.Exists(i => i.Code == 2011));
        }
        public void GetAllLiveOffersWithPIDNoLiveOffersFailureTest()
        {
            PIDSetup(false, false);
            Request = new InitClass().initRequest("liveoffers", "COREcontact_country=165&CORElanguage=14");
            OffersManager = new InitClass().initOffersManager(IOfferRepository.Object, IOfferAttributeRepository.Object, IProviderRepository.Object, IAttributeRepository.Object, ILiveMatch.Object, IRespondentCatalog.Object, IQuotaExpressionRepository.Object, IQuotaMappingRepository.Object, ISampleMappingRepository.Object, IGMIStudy.Object, ISteamStudy.Object, IQuotaLiveMatch.Object);

            var result = OffersManager.GetOffersByPid(Request, It.IsAny<string>(), It.IsAny<string>());

            Assert.Null(result.Offers);
            Assert.NotNull(result.Errors);
            Assert.True(result.Errors.Exists(i => i.Code == 2012));
        }