public void GetProductsSuccessTest()
        {
            var repository     = new Mock <IProductRepository>();
            var errorCollector = new ErrorCollector();
            var exportService  = new Mock <IExportService>().Object;

            repository.Setup(r => r.GetProducts(It.IsAny <string>())).Returns(new[]
            {
                new Product
                {
                    Id    = 1,
                    Code  = "T1",
                    Name  = "Test 1",
                    Price = 10
                }
            });

            var service = new ProductService(repository.Object, errorCollector, exportService);

            var inputModel = new GetProductsInputModel
            {
                CodeOrName = "T1"
            };

            var outputModel = service.GetProducts(inputModel);

            Assert.IsNotNull(outputModel);
            Assert.IsFalse(errorCollector.Errors.Any());
            Assert.IsNotNull(outputModel.Products);
        }
        public void GetProductsButProductDoesNotExistTest()
        {
            var repository     = new Mock <IProductRepository>().Object;
            var errorCollector = new ErrorCollector();
            var exportService  = new Mock <IExportService>().Object;
            var service        = new ProductService(repository, errorCollector, exportService);

            var inputModel = new GetProductsInputModel
            {
                CodeOrName = "T1"
            };

            var outputModel = service.GetProducts(inputModel);

            Assert.IsNotNull(outputModel);
            Assert.IsFalse(errorCollector.Errors.Any());
            Assert.IsNotNull(outputModel.Products);
            Assert.IsFalse(outputModel.Products.Any());
        }
        public GenericResponse <GetProductsOutputModel> GetProducts(GetProductsInputModel input)
        {
            var requestUrl = $"Products/?codeOrName={input.CodeOrName}";

            return(CallWebClient <GetProductsInputModel, GetProductsOutputModel>(CreateServiceCallParameter(input, (request) => _webClient.Get(request).Result, requestUrl, ServiceUrl)));
        }