public void ReturnsAnInstanceWhenParameterIsNotNull() { // Arrange var orderServiceMock = new Mock <IOrderService>(); // Act var orderController = new ComicShop.Web.Controllers.OrderController(orderServiceMock.Object); // Assert Assert.IsNotNull(orderController); }
public void ReturnView() { // Arrange var orderServiceMock = new Mock <IOrderService>(); // Act var comicController = new ComicShop.Web.Controllers.OrderController(orderServiceMock.Object); //Assert comicController .WithCallTo(c => c.Index()) .ShouldRenderDefaultView(); }
public void ReturnViewWithCurrentUserOrdersList() { // Arrange var orderServiceMock = new Mock <IOrderService>(); var currentUser = new User() { Id = "id" }; var firstOrder = new Order() { UserId = "id" }; var secondOrder = new Order() { UserId = "notMachedId" }; var listOfOrders = new List <Order>() { firstOrder, secondOrder }; orderServiceMock.Setup(x => x.GetOrdersByUserId("id")).Returns(listOfOrders.AsQueryable); // Act var orderController = new ComicShop.Web.Controllers.OrderController(orderServiceMock.Object); //Assert orderController .WithCallTo(c => c.MyOrders("id")) .ShouldRenderDefaultView() .WithModel <List <OrderViewModel> >(model => { Assert.AreEqual(model.First().UserId, currentUser.Id); }); }