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); }
public static void createTestData(TestContext context) { #region Product List and User List Creation - check valid list item for usage List<ProductRecommendation> testPR = new List<ProductRecommendation>(); 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; ProductRecommendation pr1 = new ProductRecommendation(); pr1.Rank = 1; pr1.Product = product1; ProductRecommendation pr2 = new ProductRecommendation(); pr2.Rank = 2; pr2.Product = product2; ProductRecommendation pr3 = new ProductRecommendation(); pr3.Rank = 3; pr3.Product = product3; testPR.Add(pr1); testPR.Add(pr2); testPR.Add(pr3); foreach (ProductRecommendation item in testPR) { string commandText = getCommand(true, item, PARAM_SOURCE_ID, PARAM_PRODUCT_KEY); executeCommand(commandText); } 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); foreach (UserRecommendation item in testUR) { string commandText = getCommand(true, item, PARAM_SOURCE_ID, PARAM_USER_KEY); executeCommand(commandText); } #endregion Product List and User List Creation - check valid list item for usage }