public LiveOffersController initLiveOffersController(IOffersManager IOffersManager) { LiveOffersController controller = new LiveOffersController(IOffersManager); controller.Request = this.request; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = this.config; controller.Request.Properties["requestId"] = new Guid().ToString(); controller.RequestContext.RouteData = this.routeData; return controller; }
public void GetLiveOfferAttributesFailureTest() { var IOffersManager = new Mock<IOffersManager>(); OkNegotiatedContentResult<OfferAttributesResponse> response; OfferAttributesDataObject OfferAttributesData = new OfferAttributesDataObject() { Errors = new List<ErrorObject>() { new ErrorObject(ErrorKey.ERR_INTERNAL_FATAL) }, Attributes = null }; IOffersManager.Setup(i => i.GetOfferAttributes(It.IsAny<HttpRequestMessage>(), It.IsAny<string>(), new Guid().ToString())).Returns(OfferAttributesData); controller = new InitController("Liveoffers").initLiveOffersController(IOffersManager.Object); response = controller.GetAttributes(new Guid().ToString()) as OkNegotiatedContentResult<OfferAttributesResponse>; Assert.Null(response.Content.Data.Attributes); Assert.NotNull(response.Content.Data.Errors); Assert.True(response.Content.Data.Errors.Exists(i => i.Code == 3000)); }
public void GetLiveOfferAttributesTest() { var IOffersManager = new Mock<IOffersManager>(); OkNegotiatedContentResult<OfferAttributesResponse> response; OfferAttributesDataObject OfferAttributesData = new OfferAttributesDataObject() { Errors = new List<ErrorObject>(), Attributes = new List<OfferAttributeApiObject>() { new OfferAttributeApiObject() } }; IOffersManager.Setup(i => i.GetOfferAttributes(It.IsAny<HttpRequestMessage>(), It.IsAny<string>(), new Guid().ToString())).Returns(OfferAttributesData); controller = new InitController("Liveoffers").initLiveOffersController(IOffersManager.Object); response = controller.GetAttributes(new Guid().ToString()) as OkNegotiatedContentResult<OfferAttributesResponse>; Assert.NotNull(response.Content.Data.Attributes); Assert.NotEmpty(response.Content.Data.Attributes); Assert.Null(response.Content.Data.Errors); }
public void GetLiveOffersWithPIDTest() { var IOffersManager = new Mock<IOffersManager>(); OkNegotiatedContentResult<OffersResponse> response; OffersDataObject OffersData = new OffersDataObject() { Errors = new List<ErrorObject>(), Offers = new List<OfferApiObject>() { new OfferApiObject() } }; IOffersManager.Setup(i => i.GetOffersByPid(It.IsAny<HttpRequestMessage>(), It.IsAny<string>(),It.IsAny<string>())).Returns(OffersData); controller = new InitController("Liveoffers").initLiveOffersController(IOffersManager.Object); response = controller.Get(It.IsAny<string>()) as OkNegotiatedContentResult<OffersResponse>; Assert.NotNull(response.Content.Data.Offers); Assert.Null(response.Content.Data.Errors); }
public void GetLiveOfferQuotaExpressionTest() { var IOffersManager = new Mock<IOffersManager>(); OkNegotiatedContentResult<OfferQuotaCellsResponse> response; QuotaExpressionsObjectResponse OfferQuotaCellData = new QuotaExpressionsObjectResponse() { Errors = new List<ErrorObject>(), QuotaCells = "UnitTest" }; IOffersManager.Setup(i => i.GetOfferQuotaExpression(It.IsAny<HttpRequestMessage>(), It.IsAny<string>(), new Guid().ToString())).Returns(OfferQuotaCellData); controller = new InitController("Liveoffers").initLiveOffersController(IOffersManager.Object); response = controller.GetQuotaExpressions(new Guid().ToString()) as OkNegotiatedContentResult<OfferQuotaCellsResponse>; Assert.NotNull(response.Content.Data.QuotaCells); Assert.NotEmpty((string)response.Content.Data.QuotaCells); Assert.Null(response.Content.Data.Errors); }