public async void UpdateStoreWithExistingNameWillReturnBadRequest() { var store = CreateRandomStore(); var request = new Fixture().Create <StoreRequest>(); var mock = new Mock <IStoreService>(); mock.Setup(x => x.UpdateAsync(store, request)).Throws <ApiException>(); var controller = new StoresController(mock.Object); var response = await controller.UpdateById(store.StoreId, request); Assert.IsType <NotFoundResult>(response.Result); }
public async void UpdateStoreWithIncorrectIdWillReturnNotFound() { 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 request = new Fixture().Create <StoreRequest>(); var response = await controller.UpdateById(store.StoreId, request); Assert.IsType <NotFoundResult>(response.Result); }
public async void UserCanUpdateStoreById() { var store = CreateRandomStore(); var request = new Fixture().Create <StoreRequest>(); var mock = new Mock <IStoreService>(); mock.Setup(x => x.UpdateAsync(store, request)).ReturnsAsync(store); mock.Setup(x => x.FindByIdAsync(store.StoreId)).ReturnsAsync(store); var controller = new StoresController(mock.Object); var response = await controller.UpdateById(store.StoreId, request); Assert.IsType <OkObjectResult>(response.Result); }