Пример #1
0
        public async Task StorageLocation_AddAsync()
        {
            var storageLocation            = _fixture.Create <StorageLocation>();
            var storageLocationCreateModel = _fixture.Create <StorageLocationCreateViewModel>();

            _mockIMapper.Setup(m => m.Map <StorageLocationCreateViewModel, StorageLocation>(storageLocationCreateModel)).Returns(storageLocation);
            _mockStorageLocationRepository.Setup(m => m.AddAsync(storageLocation)).ReturnsAsync(1);

            var actionSuccess = await _storageLocationService.AddAsync(storageLocationCreateModel);

            actionSuccess.Should().Be(true);
            Mock.VerifyAll();
        }
Пример #2
0
        public async Task <IActionResult> NewStorageLocation(StorageLocationCreateViewModel storageLocation)
        {
            try
            {
                var success = await _storageLocationService.AddAsync(storageLocation);

                if (success)
                {
                    return(Created("", storageLocation));
                }

                return(BadRequest($"Erro ao criar local"));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }