public void TestDeleteRoomBedRelationById_Failed_Error() { //Arrange int id = 1; string userName = "******"; var room = new RoomBedRelation() { ID = id, IsDeleted = false, HotelId = id }; var baseResult = new BaseResult <List <RoomBedRelation> >() { Result = new List <RoomBedRelation>() { room } }; var pred = new Func <RoomBedRelation, bool>(x => x.ID == id && x.IsDeleted == false); iRoomBedRelationLibrary.Setup(a => a.GetListByPredicate(It.Is <Func <RoomBedRelation, bool> >(x => x.GetType() == pred.GetType()))).Returns(Task.FromResult(baseResult)).Verifiable(); iRoomBedRelationLibrary.Setup(a => a.UpdateEntityByDapper(It.IsAny <RoomBedRelation>())).Returns(Task.FromResult(new BaseResult <bool> { IsError = true, ExceptionMessage = Helper.Common.GetMockException() })).Verifiable(); //Act var result = roomRepository.DeleteRoomBedRelationById(id, userName); //Assert iRoomLibrary.Verify(); Assert.IsTrue(result.Result is BaseResult <bool>); Assert.IsTrue(result.Result.IsError == true); Assert.IsTrue(result.Result.ExceptionMessage != null); }
/// <summary> /// Resolve remaining parameters of room bed relation /// </summary> /// <param name="destination"></param> /// <param name="source"></param> public static void ResolveRemainingParamters(RoomBedRelation destination, RoomBedRelation source, string userName) { destination.CreatedBy = source.CreatedBy; destination.UpdatedBy = userName; destination.IsDeleted = source.IsDeleted; destination.HotelId = source.HotelId; destination.LanguageID = source.LanguageID; destination.HotelRoomId = source.HotelRoomId; destination.UpdatedDate = Common.JakartaOffset(DateTime.Now); destination.CreatedDate = source.CreatedDate; }
/// <summary> /// maps the model to RoomBedRelation Entity /// </summary> /// <param name = "request" ></ param > /// < param name="hotelRoomId"></param> /// <returns></returns> public static BaseResult <RoomBedRelation> MapRoomBedRelationEntity(HotelRoomTypeViewModel request, RoomBedListViewModel item, int hotelRoomId, string userName) { BaseResult <RoomBedRelation> responseModel = new BaseResult <RoomBedRelation>(); RoomBedRelation roomBedRelation = new RoomBedRelation() { HotelId = (int)request.HotelId, BedId = (int)item.BedId, NoOfBeds = (int)item.NoOfBeds, HotelRoomId = hotelRoomId, IsDeleted = false, UpdatedBy = userName, CreatedBy = userName }; responseModel.Result = roomBedRelation; return(responseModel); }
/// <summary> /// maps the model to RoomBedRelation Entity /// </summary> /// <param name="request"></param> /// <param name="hotelRoomId"></param> /// <returns></returns> public static BaseResult <List <RoomBedRelation> > CreateRoomBedRelation(HotelRoomTypeViewModel request, int hotelRoomId, string userName) { BaseResult <List <RoomBedRelation> > responseModel = new BaseResult <List <RoomBedRelation> >(); var list = new List <RoomBedRelation>(); foreach (var item in request.RoomBedOptions.RoomBedList) { RoomBedRelation roomBedRelation = new RoomBedRelation() { HotelId = (int)request.HotelId, BedId = (int)item.BedId, NoOfBeds = (int)item.NoOfBeds, HotelRoomId = hotelRoomId, IsDeleted = false, UpdatedBy = userName, CreatedBy = userName }; list.Add(roomBedRelation); } responseModel.Result = list; return(responseModel); }
/// <summary> /// Maps thr RoomBedlistViewModel to RoomBedRelation /// </summary> /// <param name="request"></param> /// <param name="roomFromDb"></param> /// <param name="userName"></param> /// <returns></returns> public static RoomBedRelation AutoMapperRoomBedRelation(RoomBedListViewModel request, RoomBedRelation roomFromDb, string userName) { var roomBedMapped = AutoMapper.Mapper.Map <RoomBedRelation>(request); ResolveRemainingParamters(roomBedMapped, roomFromDb, userName); return(roomBedMapped); }
public void TestSaveAndUpdateRoomBedRelation_EditRoom_Failed() { //Arrange var userName = "******"; var id = 1; var roombedObject = new RoomBedListViewModel() { ID = 1, BedId = id, NoOfBeds = 2, ObjectState = ObjectState.Modified }; var roomBedOptionObject = new RoomBedOptionViewModel() { OccupancyId = id, ObjectState = ObjectState.Modified }; roomBedOptionObject.RoomBedList.Add(roombedObject); var hotelRoomObject = new HotelRoomTypeViewModel() { RoomId = id, IsActive = true, HotelId = 1, IsFreeSale = true, IsSmoking = true, NoOfRooms = 2, Description = "Description", Name = "Name", Size = 5, RoomTypeId = id, SizeMeasureId = id, ObjectState = ObjectState.Unchanged }; hotelRoomObject.RoomBedOptions = roomBedOptionObject; var room = new RoomBedRelation() { ID = id, IsDeleted = false, HotelId = id }; var baseResult = new BaseResult <List <RoomBedRelation> >() { Result = new List <RoomBedRelation>() { room } }; var pred = new Func <RoomBedRelation, bool>(x => x.ID == id && x.IsDeleted == false); iRoomBedRelationLibrary.Setup(a => a.GetListByPredicate(It.Is <Func <RoomBedRelation, bool> >(x => x.GetType() == pred.GetType()))).Returns(Task.FromResult(baseResult)).Verifiable(); iRoomBedRelationLibrary.Setup(a => a.UpdateEntityByDapper(It.IsAny <RoomBedRelation>())).Returns(Task.FromResult(new BaseResult <bool> { IsError = true, ExceptionMessage = Helper.Common.GetMockException() })).Verifiable(); //Act var result = roomRepository.SaveAndUpdateRoomBedRelation(hotelRoomObject, id, userName); //Assert iRoomLibrary.Verify(); Assert.IsTrue(result.Result.IsError); Assert.IsTrue(result.Result.ExceptionMessage != null); }