Esempio n. 1
0
        public void TestDeleteNotFoundObject()
        {
            TouristSpot touristSpot = new TouristSpot()
            {
                Name = "Virgen del verdún",
                Id   = 3
            };
            TouristSpotModelIn touristSpotModel = new TouristSpotModelIn(touristSpot);
            var mock = new Mock <ITouristSpotLogic>(MockBehavior.Strict);

            mock.Setup(ts => ts.Delete(3)).Throws(new ObjectNotFoundInDatabaseException());
            var controller = new TouristSpotController(mock.Object);

            var result         = controller.Delete(touristSpotModel.Id) as NotFoundObjectResult;
            var expectedResult = new NotFoundObjectResult("There is no tourist spot with such id.");

            mock.VerifyAll();
            Assert.AreEqual(expectedResult.Value, result.Value);
        }
Esempio n. 2
0
        public void TestSuccessfulDelete()
        {
            TouristSpot touristSpot = new TouristSpot()
            {
                Name = "Virgen del verdún",
                Id   = 3
            };
            TouristSpotModelIn touristSpotModel = new TouristSpotModelIn(touristSpot);
            var mock = new Mock <ITouristSpotLogic>(MockBehavior.Strict);

            mock.Setup(ts => ts.Delete(3));
            var controller = new TouristSpotController(mock.Object);

            var result         = controller.Delete(touristSpotModel.Id) as OkObjectResult;
            var expectedResult = new OkObjectResult("Success.");

            mock.VerifyAll();
            Assert.AreEqual(expectedResult.Value, result.Value);
        }