public async void GetStoreWithIncorrectIdWillReturnNotFound() { var mapper = Helper.CreateMapperWithProfile <StoreProfile>(); var store = CreateRandomStore(); var mock = new Mock <IStoreRepository>(); var service = new StoreService(mock.Object, mapper); var controller = new StoresController(service); var response = await controller.GetById(store.StoreId); Assert.IsType <NotFoundResult>(response.Result); }
public async void UserCanGetStoreById(int storesCount) { var stores = CreateRandomStoresList(storesCount); var mapper = Helper.CreateMapperWithProfile <StoreProfile>(); var store = stores.FirstOrDefault(); var mock = new Mock <IStoreRepository>(); mock.Setup(x => x.Find(store.StoreId)) .ReturnsAsync(stores.FirstOrDefault(x => x.StoreId == store?.StoreId)); var service = new StoreService(mock.Object, mapper); var controller = new StoresController(service); var response = await controller.GetById(store?.StoreId ?? -1); Assert.IsType <OkObjectResult>(response.Result); }