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);
        }
Ejemplo n.º 2
0
 private bool isDuplicate(House entity)
 {
     bool isDuplicate = _unitOfWork.HouseRepository.IsDuplicate(entity);
     return isDuplicate;
 }
Ejemplo n.º 3
0
 private bool hasBookings(House entity)
 {
     bool hasBookings = _unitOfWork.HouseRepository.HasBookings(entity);
     return hasBookings;
 }