public void ShippingCompany_Service_GetAll_Sucessfully()
        {
            //Arrange
            var shippingCompany     = ObjectMother.ShippingCompanyValidWithIdWithAddress();
            var mockValueRepository = new List <ShippingCompany>()
            {
                shippingCompany
            }.AsQueryable();

            _mockShippingCompanyRepository.Setup(er => er.GetAll()).Returns(mockValueRepository);

            //Action
            var shippingCompanysResultado = _shippingCompanyService.GetAll();

            //Verificar
            _mockShippingCompanyRepository.Verify(er => er.GetAll(), Times.Once);
            shippingCompanysResultado.Should().NotBeNull();
            shippingCompanysResultado.First().Should().Be(shippingCompany);
            shippingCompanysResultado.Count().Should().Be(mockValueRepository.Count());
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetAll(ODataQueryOptions <ShippingCompany> queryOptions)
        {
            var queryString = Request.GetQueryNameValuePairs()
                              .Where(x => x.Key.Equals("size"))
                              .FirstOrDefault();

            var query = default(IQueryable <ShippingCompany>);
            int size  = 0;

            if (queryString.Key != null && int.TryParse(queryString.Value, out size))
            {
                query = _service.GetAll(new ShippingCompanyQuery(size));
            }
            else
            {
                query = _service.GetAll();
            }

            return(HandleQueryable <ShippingCompany, ShippingCompanyViewModel>(query, queryOptions));
        }