예제 #1
0
        public void GetAutomobile_ShouldCallRepository_GetAutomobileWithCorrectVIN()
        {
            var _mockRepo  = new Mock <IGasAutomobileRepository>();
            var controller = new GasAutomobileController(_mockRepo.Object);
            var VIN        = "123";

            controller.GetAutomobile(VIN);

            _mockRepo.Verify(m => m.GetAutomobile(VIN));
        }
예제 #2
0
        public void GetAutomobile_ShouldReturnNotFound_GivenNoAutoReturnedFromRepo()
        {
            var controller = new GasAutomobileController(_mockRepo.Object);
            var vin        = "1";

            _mockRepo.Setup(m => m.GetAutomobile(vin)).Returns((GasAutomobile)null);

            IHttpActionResult result = controller.GetAutomobile(vin);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
예제 #3
0
        public void GetAutomobile_ShouldReturnAuto_GivenAutoReturnedFromRepo()
        {
            var vin  = "1";
            var auto = new GasAutomobile()
            {
                VIN = vin
            };
            var controller = new GasAutomobileController(_mockRepo.Object);

            _mockRepo.Setup(m => m.GetAutomobile(vin)).Returns(auto);

            IHttpActionResult actionResult = controller.GetAutomobile(vin);
            var result = actionResult as OkNegotiatedContentResult <GasAutomobile>;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(auto, result.Content);
        }