public void ReturnsAnInstanceWhenParameterIsNotNull() { // Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); // Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); // Assert Assert.IsNotNull(adminController); }
public void ReturnView() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); //Assert adminController .WithCallTo(c => c.Index()) .ShouldRenderDefaultView(); }
public void RedirectToActionCheckOrders() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); //Assert adminController .WithCallTo(c => c.ProceedOrderById(1)) .ShouldRedirectTo(x => x.CheckOrders); }
public void CallOrderServiceProceedOrderByIdMethodWithPassedId() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); adminController.ProceedOrderById(1); //Assert orderServiceMock.Verify(x => x.ProceedOrderById(1), Times.Once); }
public void RedirectToIndexActionResultWhenModelStateIsValid() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); Creature creature = new Creature(); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); //Assert adminController .WithCallTo(c => c.AddCreature(creature)) .ShouldRedirectTo(x => x.Index); }
public void ReturnDefaultViewWhenModelStateIsNotValid() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); Creature creature = new Creature(); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); adminController.ModelState.AddModelError("testError", "error detected"); //Assert adminController .WithCallTo(c => c.AddCreature(creature)) .ShouldRenderDefaultView(); }
public void ReturnView() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); Creature creature = new Creature() { Id = 1 }; creatureServiceMock.Setup(x => x.GetCreatureById(1)).Returns(creature); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); //Assert adminController .WithCallTo(c => c.EditCreature(1)) .ShouldRenderDefaultView(); }
public void ReturnView() { //Arrange var creatureServiceMock = new Mock <ICreatureService>(); var orderServiceMock = new Mock <IOrderService>(); Order order = new Order(); var ordersList = new List <Order>() { order }; orderServiceMock.Setup(x => x.GetAllOrders()).Returns(ordersList.AsQueryable); //Act var adminController = new AquaWorld.Web.Areas.Admin.AdminController( creatureServiceMock.Object, orderServiceMock.Object); //Assert adminController .WithCallTo(c => c.CheckOrders()) .ShouldRenderDefaultView(); }