public void GetAll_Shops_ShouldResponseWithOK() { //Arrange is done in the constuctor //Act var actionResult = _shopController.Get(); var result = actionResult.Result as OkObjectResult; var dataResult = result.Value as IEnumerable <ShopViewModel>; // Assert Assert.NotNull(result); Assert.NotNull(dataResult); Assert.IsAssignableFrom <IEnumerable <ShopViewModel> >(dataResult); Assert.Equal(FakeShopList.Count, dataResult.Count()); }
public void GetAllShops_ShouldReturnAllShops() { var testShops = GetTestShops(); var controller = new ShopController(GetRepository()); var result = controller.Get() as List <Shop>; Assert.AreEqual(testShops.Count, result.Count); }
public void Get_ReturnsAssociatedShops() { var unitOfWork = GetUnitOfWork(); var controller = new ShopController(unitOfWork); var result = controller.Get(1); Assert.IsNotNull(result); Assert.AreEqual(2, result.ToList().Count); }
public async Task User_OkObject_Get() { var client = Convert(Model1()); var mockRepository = new Mock <IShopRepository>(); mockRepository.Setup(x => x.Get(client.Id)) .Returns(Task.FromResult(client)); var controller = new ShopController(mockRepository.Object); var result = await controller.Get(client.Id); var model = Assert.IsType <OkObjectResult>(result.Result); }
public async Task Shop_OkObject_GetAll() { var shopModel = Model(); IEnumerable <ShopModel> shops = new[] { shopModel }; var mockShop = new Mock <IShopService>(); mockShop.Setup(x => x.GetAll(1, 10)) .Returns(Task.FromResult(shops)); var controller = new ShopController(mockShop.Object, null, null); var result = await controller.Get(1, 10); var actionResult = Assert.IsType <OkObjectResult>(result); }
public async Task User_OkObject_GetAll() { IEnumerable <Shop> clients = new[] { Convert(Model1()), Convert(Model2()) }; IEnumerable <ShopModel> clientsModel = new[] { Model1(), Model2() }; var mockRepository = new Mock <IShopRepository>(); mockRepository.Setup(x => x.GetAll()) .Returns(Task.FromResult(clients)); var controller = new ShopController(mockRepository.Object); var result = await controller.Get(1, 1); var model = Assert.IsType <OkObjectResult>(result.Result); Assert.Equal(1, (model.Value as IEnumerable <ShopModel>)?.Count()); }