public async void UserCanViewAllStore(int storesCount) { var stores = CreateRandomStoresList(storesCount); var repository = new Mock <IStoreRepository>(); repository.Setup(x => x.All()).ReturnsAsync(stores); var service = new StoreService(repository.Object, Helper.CreateMapperWithProfile <StoreProfile>()); var controller = new StoresController(service); var response = await controller.All(); if (storesCount > 0) { Assert.IsType <OkObjectResult>(response.Result); Assert.Equal(stores, ((OkObjectResult)response.Result).Value); } else { Assert.IsType <NoContentResult>(response.Result); } }