public void CanMapFromDTO() { var dto = new HotelDTO { Id = 1, Name = "Test", SingleRoomPrice = 100, DoubleRoomPrice = 200, TripleRoomPrice = 300, GroupRoomPrice = 400, ExtraBedPrice = 500, IsActive = true }; var result = _subject.FromDTO(dto); Assert.That(result.Id, Is.EqualTo(1)); Assert.That(result.Name, Is.EqualTo("Test")); Assert.That(result.SingleRoomPrice, Is.EqualTo(100)); Assert.That(result.DoubleRoomPrice, Is.EqualTo(200)); Assert.That(result.TripleRoomPrice, Is.EqualTo(300)); Assert.That(result.GroupRoomPrice, Is.EqualTo(400)); Assert.That(result.ExtraBedPrice, Is.EqualTo(500)); Assert.That(result.IsActive, Is.EqualTo(true)); }
public void UpdateOne(HotelDTO dto) { try { using (ISession session = NHibernateHelper.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Update(dto); transaction.Commit(); } } catch (Exception) { throw new HibernateException("Error when updating " + dto.Name); } }
public Hotel FromDTO(HotelDTO dto) { try { return new Hotel { Id = dto.Id, Name = dto.Name, SingleRoomPrice = dto.SingleRoomPrice, DoubleRoomPrice = dto.DoubleRoomPrice, TripleRoomPrice = dto.TripleRoomPrice, GroupRoomPrice = dto.GroupRoomPrice, ExtraBedPrice = dto.ExtraBedPrice, IsActive = dto.IsActive }; } catch (Exception) { throw new Exception("Error occured when mapping DTO to hotel service model: " + dto.Name); } }
public void SetUp() { _repositoryMock = new Mock<IHotelRepository>(); _mapperMock = new Mock<IHotelModelMapper>(); _subject = new HotelService(_mapperMock.Object, _repositoryMock.Object); _dto1 = new HotelDTO {Id = 1, Name = "Testhotell 1", SingleRoomPrice = 11, DoubleRoomPrice = 12, TripleRoomPrice = 13, GroupRoomPrice = 14, ExtraBedPrice = 15, IsActive = true }; _dto2 = new HotelDTO { Id = 2, Name = "Testhotell 2", SingleRoomPrice = 21, DoubleRoomPrice = 22, TripleRoomPrice = 23, GroupRoomPrice = 24, ExtraBedPrice = 25, IsActive = true }; _dto3 = new HotelDTO { Id = 3, Name = "Testhotell 3", SingleRoomPrice = 31, DoubleRoomPrice = 32, TripleRoomPrice = 33, GroupRoomPrice = 34, ExtraBedPrice = 35, IsActive = true }; _model1 = new Hotel {Id = 1, Name = "Testhotell 1", SingleRoomPrice = 11, DoubleRoomPrice = 12, TripleRoomPrice = 13, GroupRoomPrice = 14, ExtraBedPrice = 15, IsActive = true }; _model2 = new Hotel { Id = 2, Name = "Testhotell 2", SingleRoomPrice = 21, DoubleRoomPrice = 22, TripleRoomPrice = 23, GroupRoomPrice = 24, ExtraBedPrice = 25, IsActive = true }; _model3 = new Hotel { Id = 3, Name = "Testhotell 3", SingleRoomPrice = 31, DoubleRoomPrice = 32, TripleRoomPrice = 33, GroupRoomPrice = 34, ExtraBedPrice = 35, IsActive = true }; }