public void DisplayWishList_Negative()
        {
            int renterId = 2;

            Acknowledgement <Room> roomsAcknowledgement = new Acknowledgement <Room>();

            roomsAcknowledgement.code    = 0;
            roomsAcknowledgement.Set     = null;
            roomsAcknowledgement.Message = "fail";


            //Arrange
            var _mockDataService = new Mock <BookingService>();

            _mockDataService.Setup(p => p.DisplayWishList(renterId)).Throws <System.Exception>();

            var _bookingManager = new BookingManager(_mockDataService.Object);

            try
            {
                var responseReturned = _bookingManager.DisplayWishList(renterId);
                Assert.IsTrue(false);
            }
            catch
            {
                Assert.IsTrue(true);
            }
        }
Пример #2
0
        public IActionResult GetWishListByHisId(int renterIdReceived)
        {
            // List<Room> DisplayWishListRooms;
            Acknowledgement <Room> returnData = new Acknowledgement <Room>();
            Acknowledgement <WishListDuplicate> returnFailData = new Acknowledgement <WishListDuplicate>();//actually we don't use WishListDuplicate in this method but

            //as we are calling a method that is returning  "ReturningData<WishListDuplicate>" we r using this.

            //BookingManager bookingManager = new BookingManager();


            if (!ModelState.IsValid)
            {
                return(Ok(returnFailData));
            }
            try
            {
                returnData = search.DisplayWishList(renterIdReceived);
            }
            catch (Exception)
            {
                returnFailData = search.WhenErrorOccurs("", type: "get");
                return(Ok(returnFailData));
            }
            return(Ok(returnData));
        }
        public void DisplayWishList_Positive()
        {
            int renterId = 2;

            Room room1 = new Room
            {
                RoomId      = 1,
                Cost        = 3000,
                NoOfBeds    = 3,
                City        = "hyderabad",
                Area        = "tg",
                Address     = "tg",
                Pincode     = 50072,
                Furniture   = "no",
                Description = "good",
                Status      = "not available"
            };

            Room room2 = new Room
            {
                RoomId      = 2,
                Cost        = 4000,
                NoOfBeds    = 2,
                City        = "hyderabad",
                Area        = "tg",
                Address     = "tg",
                Pincode     = 50073,
                Furniture   = "yes",
                Description = "good",
                Status      = "available"
            };



            List <Room> roomList = new List <Room>();

            roomList.Add(room1);
            roomList.Add(room2);


            Acknowledgement <Room> roomsAcknowledgement = new Acknowledgement <Room>();

            roomsAcknowledgement.code    = 1;
            roomsAcknowledgement.Set     = roomList;
            roomsAcknowledgement.Message = "success";


            //Arrange
            var _mockDataService = new Mock <BookingService>();

            _mockDataService.Setup(p => p.DisplayWishList(renterId)).Returns(roomList);

            var _bookingManager = new BookingManager(_mockDataService.Object);

            try
            {
                var responseReturned = _bookingManager.DisplayWishList(renterId);
                Assert.IsTrue(false);
            }
            catch
            {
                Assert.IsTrue(true);
            }
        }