public void Initialize()
        {
            _uow = A.Fake<IUnitOfWork>();
            _mapper = A.Fake<IMappingEngine>();
            _service = new HouseService(_uow, _mapper);

            // Initializing HouseDTO's
            _nonExistingHouseDTO = new HouseDTO();
            _existingHouseDTO = new HouseDTO();
            _houseWithBookingsDTO = new HouseDTO();
            _houseWithNoBookingsDTO = new HouseDTO();

            // Initializing Houses
            _nonExistingHouse = new House();
            _existingHouse = new House();
            _houseWithBookings = new House();
            _houseWithNoBookings = new House();

            // Controlling mapper behaviour
            A.CallTo(() => _mapper.Map<House>(_nonExistingHouseDTO)).Returns(_nonExistingHouse);
            A.CallTo(() => _mapper.Map<House>(_existingHouseDTO)).Returns(_existingHouse);
            A.CallTo(() => _mapper.Map<House>(_houseWithBookingsDTO)).Returns(_houseWithBookings);
            A.CallTo(() => _mapper.Map<House>(_houseWithNoBookingsDTO)).Returns(_houseWithNoBookings);

            // Controlling service behaviour
            A.CallTo(() => _uow.HouseRepository.IsDuplicate(_nonExistingHouse)).Returns(false);
            A.CallTo(() => _uow.HouseRepository.IsDuplicate(_existingHouse)).Returns(true);
            A.CallTo(() => _uow.HouseRepository.HasBookings(_houseWithBookings)).Returns(true);
            A.CallTo(() => _uow.HouseRepository.HasBookings(_houseWithNoBookings)).Returns(false);
        }
        public void Add(HouseDTO entity)
        {
            House house = _mapper.Map<House>(entity);

            if (isDuplicate(house)) {
                throw new HouseAlreadyExistsException(Properties.Resources.HouseAlreadyExistsExceptionText);
            }

            _unitOfWork.HouseRepository.Add(house);
            _unitOfWork.Commit();
        }
        public void Delete(HouseDTO entity)
        {
            House house = _mapper.Map<House>(entity);

            if (hasBookings(house)) {
                throw new HouseHasBookingException(Properties.Resources.HouseHasBookingsExceptionText);
            }

            _unitOfWork.HouseImageRepository.DeleteAllHouseRelatedImages(house.Id);
            _unitOfWork.HouseRepository.Delete(house);
            _unitOfWork.Commit();
        }