コード例 #1
0
        public void UploadImage_Negative()
        {
            Image image = new Image()
            {
                ImageId   = 20,
                RoomId    = 10,
                RoomImage = new Byte[1] {
                    Convert.ToByte(12)
                }
            };
            var MockRoomBusiness = new Mock <RoomManager>();
            var returnType       = new Acknowledgement <Image>
            {
                code    = 2,
                Set     = null,
                Message = "Failed to Upload Images",
            };


            List <byte[]> list = new List <byte[]>();

            list.Add(image.RoomImage);
            MockRoomBusiness.Setup(p => p.AddImage(list)).Throws <System.Exception>();
            RoomsController roomsController  = new RoomsController(MockRoomBusiness.Object);
            var             actualReturnType = roomsController.Upload() as OkObjectResult;

            Assert.ReferenceEquals(returnType, actualReturnType.Value);
        }