예제 #1
0
        public void productToProductRecommendationTest_ParamError()
        {
            Result actual;

            Mock <IWebOperationContext> mockContext = new Mock <IWebOperationContext> {
                DefaultValue = DefaultValue.Mock
            };

            using (new MockedWebOperationContext(mockContext.Object))
            {
                APIPrototypeService target = new APIPrototypeService();
                string tenantId            = PARAM_TENANT_ID;
                string sourceId            = PARAM_INCORRECT_FORMAT_SOURCE_ID;
                string productKey          = PARAM_PRODUCT_KEY;

                actual = target.productToProductRecommendation(tenantId, sourceId, productKey);
            }

            Assert.IsNull(actual.resultSet);
            Assert.AreEqual(actual.tenantId, long.Parse(PARAM_TENANT_ID));
            Assert.IsNotNull(actual.error);
            Assert.AreEqual(actual.error.code, APIPrototype.Constants.ERR_ARGUMENT_EXCEPTION);
        }
예제 #2
0
        public void userToProductRecommendationTest_NullItem()
        {
            Result actual;

            Mock <IWebOperationContext> mockContext = new Mock <IWebOperationContext> {
                DefaultValue = DefaultValue.Mock
            };

            using (new MockedWebOperationContext(mockContext.Object))
            {
                APIPrototypeService target = new APIPrototypeService();
                string tenantId            = PARAM_TENANT_ID;
                string sourceId            = PARAM_SOURCE_ID;
                string userKey             = PARAM_NULL_USER_KEY;


                actual = target.userToProductRecommendation(tenantId, sourceId, userKey);
            }

            Assert.IsNull(actual.resultSet);
            Assert.AreEqual(actual.tenantId, long.Parse(PARAM_TENANT_ID));
            Assert.IsNotNull(actual.error);
            Assert.AreEqual(actual.error.code, APIPrototype.Constants.ERR_ITEM_NOT_FOUND);
        }
예제 #3
0
        public void userToProductRecommendationTest()
        {
            bool actual = false;

            Result actualResult;
            Result expectedResult;

            Mock <IWebOperationContext> mockContext = new Mock <IWebOperationContext> {
                DefaultValue = DefaultValue.Mock
            };

            using (new MockedWebOperationContext(mockContext.Object))
            {
                #region Same User List and params from Initialization

                APIPrototypeService target = new APIPrototypeService();
                string tenantId            = PARAM_TENANT_ID;
                string sourceId            = PARAM_SOURCE_ID;
                string userKey             = PARAM_USER_KEY;

                List <UserRecommendation> testUR = new List <UserRecommendation>();

                Product product1 = new Product();
                product1.ProductId          = "1";
                product1.ProductName        = "Product1";
                product1.ProductDescription = string.Empty;
                product1.ProductImageurl    = string.Empty;

                Product product2 = new Product();
                product2.ProductId          = "2";
                product2.ProductName        = "Product2";
                product2.ProductDescription = string.Empty;
                product2.ProductImageurl    = string.Empty;

                Product product3 = new Product();
                product3.ProductId          = "3";
                product3.ProductName        = "Product3";
                product3.ProductDescription = string.Empty;
                product3.ProductImageurl    = string.Empty;

                UserRecommendation ur1 = new UserRecommendation();
                ur1.Rank    = 1;
                ur1.Product = product1;


                UserRecommendation ur2 = new UserRecommendation();
                ur2.Rank    = 2;
                ur2.Product = product2;


                UserRecommendation ur3 = new UserRecommendation();
                ur3.Rank    = 3;
                ur3.Product = product3;

                testUR.Add(ur1);
                testUR.Add(ur2);
                testUR.Add(ur3);

                expectedResult           = new Result();
                expectedResult.tenantId  = long.Parse(tenantId);
                expectedResult.resultSet = testUR;

                #endregion Same User List and params from Initialization

                actualResult = target.userToProductRecommendation(tenantId, sourceId, userKey);
                //Compare values of object expected and actual from service by Value!
                actual = APIPrototype.Utils.ObjectHelper.AreObjectsEqual(actualResult, expectedResult);
            }

            Assert.IsTrue(actual);
        }