public async Task LotsController_Details_WithNotExistingLotReturnsNotFound() { var mockLotService = new Mock <ILotService>(); mockLotService .Setup(m => m.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync((LotModel)null); var lotsController = new LotsController(mockLotService.Object); var result = await lotsController.Details(0); Assert.IsNotNull(result); Assert.IsInstanceOf(typeof(RedirectToRouteResult), result); Assert.AreEqual("Errors", ((RedirectToRouteResult)result).RouteValues["controller"]); Assert.AreEqual("NotFound", ((RedirectToRouteResult)result).RouteValues["action"]); }
public async Task LotsController_Details_ReturnsViewProperLot() { var lot = GetTestLotsModels().First(); var mockLotService = new Mock <ILotService>(); mockLotService .Setup(m => m.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync(lot); var lotsController = new LotsController(mockLotService.Object); var result = (ViewResult)(await lotsController.Details(lot.Id)); Assert.IsNotNull(result); Assert.IsInstanceOf(typeof(LotModel), result.Model); var model = (LotModel)result.Model; Assert.AreEqual(lot.Id, model.Id); Assert.AreEqual(lot.StartPrice, model.StartPrice); Assert.AreEqual(lot.SellerId, model.SellerId); }