public async void UserCanAddStore() { var mapper = Helper.CreateMapperWithProfile <StoreProfile>(); var request = new Fixture().Create <StoreRequest>(); var mock = new Mock <IStoreService>(); mock.Setup(x => x.AddAsync(request)).ReturnsAsync(mapper.Map <Store>(request)); var controller = new StoresController(mock.Object); var response = await controller.Add(request); Assert.IsType <CreatedAtActionResult>(response.Result); }
public async void AddingExistingStoreWillReturnBadRequest() { var mapper = Helper.CreateMapperWithProfile <StoreProfile>(); var request = new Fixture().Create <StoreRequest>(); var mock = new Mock <IStoreRepository>(); mock.Setup(x => x.Find(request.StoreName, request.Address)).ReturnsAsync(mapper.Map <Store>(request)); var service = new StoreService(mock.Object, mapper); var controller = new StoresController(service); var response = await controller.Add(request); Assert.IsType <BadRequestObjectResult>(response.Result); }