Exemple #1
0
        public void Addressee_Service_GetAll_Sucessfully()
        {
            //Arrange
            var addressee           = ObjectMother.AddresseeValidWithIdWithAddress();
            var mockValueRepository = new List <Addressee>()
            {
                addressee
            }.AsQueryable();

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

            //Action
            var addressees = _addresseeService.GetAll();

            //Assert
            _mockAddresseeRepository.Verify(er => er.GetAll(), Times.Once);
            addressees.Should().NotBeNull();
            addressees.First().Should().Be(addressee);
            addressees.Count().Should().Be(mockValueRepository.Count());
        }
        public IHttpActionResult GetAll(ODataQueryOptions <Addressee> queryOptions)
        {
            var queryString = Request.GetQueryNameValuePairs()
                              .Where(x => x.Key.Equals("size"))
                              .FirstOrDefault();

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

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

            return(HandleQueryable <Addressee, AddresseeViewModel>(query, queryOptions));
        }