public void ShouldConvertValidStringIntoGuid()
        {
            PrimitiveMapper mapper = new PrimitiveMapper();
            Guid            guid   = Guid.NewGuid();
            Guid            actual = mapper.ToGuid(mapper.ToString(guid));

            Assert.AreEqual(guid, actual, "The GUID was not parsed correctly.");
        }
Exemplo n.º 2
0
        public void RemoveAddressItem(string settingId)
        {
            PrimitiveMapper mapper = new PrimitiveMapper();
            AddressItem     item   = itemRepository.GetAddressItem(mapper.ToGuid(settingId));

            if (item == null)
            {
                throw new AdapterException(HttpStatusCode.NotFound, "An address item with the given ID was not found.");
            }
            itemRepository.Remove(item);
        }
Exemplo n.º 3
0
        public IEnumerable <AddressItemData> GetAddressItems(string customerId)
        {
            PrimitiveMapper mapper   = new PrimitiveMapper();
            Customer        customer = customerRepository.GetCustomer(mapper.ToGuid(customerId));

            if (customer == null)
            {
                throw new AdapterException(HttpStatusCode.NotFound, "A customer with the given ID was not found.");
            }
            return(itemRepository.GetAddressItems(customer).Select(s => AddressItemMapper.Convert(s)).ToArray());
        }
        private Customer getCustomer(string customerId)
        {
            PrimitiveMapper mapper       = new PrimitiveMapper();
            Guid            customerGuid = mapper.ToGuid(customerId);
            Customer        customer     = customerRepository.GetCustomer(customerGuid);

            if (customer == null)
            {
                throw new AdapterException(HttpStatusCode.NotFound, "A customer with the given ID was not found.");
            }
            return(customer);
        }
 public void ShouldThrowAdapterExceptionForInvalidGuid()
 {
     try
     {
         PrimitiveMapper mapper = new PrimitiveMapper();
         mapper.ToGuid("123");
         Assert.Fail("The invalid GUID should have caused an exception to be thrown.");
     }
     catch (AdapterException exception)
     {
         Assert.AreEqual(HttpStatusCode.BadRequest, exception.StatusCode, "The wrong status code was sent.");
     }
 }