public void GetImage_Id_Negative() { int roomId = 10; Image image = new Image() { ImageId = 10, RoomId = 12, RoomImage = new byte[1] { Convert.ToByte(12) } }; var returnType = new Acknowledgement <Image> { code = 2, Set = null, Message = "No Images Found" }; var MockRoomBusiness = new Mock <RoomManager>(); MockRoomBusiness.Setup(p => p.GetImagesId(roomId)).Throws <System.Exception>(); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.GetImage(roomId); Assert.ReferenceEquals(returnType, actualReturnType.Value); }
public void GetImage_Positive() { int roomId = 10; Image image = new Image() { ImageId = 10, RoomId = 12, RoomImage = new Byte[1] { Convert.ToByte(12) } }; var imageList = new List <Image>(); imageList.Add(image); var MockRoomBusiness = new Mock <RoomManager>(); MockRoomBusiness.Setup(p => p.GetImages(image.RoomId)).Returns(imageList); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.GetImage(roomId); //Assert.ReferenceEquals(actualReturnType, actualReturnType.Value); Assert.ReferenceEquals(imageList, actualReturnType.Value); }