public void FacilitySpecificConfigurationLogic_CreateFacilityExtensionAsync_ShouldThrowArgumentNulExceptionOnNullInput() { //Arrange FacilityLogisticsConfigurationExtension facilityExtensions = null; //Act Assert.ThrowsAsync <ArgumentNullException>(() => _facilitySpecificConfigurationLogic.CreateFacilityExtensionAsync(facilityExtensions)); //Assert }
public void FacilitySpecificConfigurationLogic_UpdateFacilityExtensionAsync_ShouldThrowArgumentNulExceptionOnEmptyFacilityKeyInput() { //Arrange FacilityLogisticsConfigurationExtension facilityExtensions = new FacilityLogisticsConfigurationExtension() { FacilityKey = Guid.Empty }; //Act Assert.ThrowsAsync <ArgumentNullException>(() => _facilitySpecificConfigurationLogic.UpdateFacilityExtensionAsync(facilityExtensions)); //Assert }
public async Task FacilitySpecificConfigurationLogic_CreateFacilityExtensionAsync_ShouldAddAndCommitRecordOnProperInput() { _unitOfWorkMock.Setup(u => u.CommitChangesAsync()).ReturnsAsync(1); Guid facilityKey = Guid.Parse("BEC05D78-2F6C-4034-8FB9-ACE3417F83E8"); FacilityLogisticsConfig existingfacilitySpecificConfiguration = null; _mockFacilitySpecificConfigurationRepository.Setup(f => f.GetAsync(facilityKey)).ReturnsAsync(existingfacilitySpecificConfiguration); _mockFacilitySpecificConfigurationRepository.Setup(f => f.Add(It.IsAny <FacilityLogisticsConfig>())).Verifiable(); FacilityLogisticsConfigurationExtension facilityExtensions = new FacilityLogisticsConfigurationExtension() { FacilityKey = facilityKey }; await _facilitySpecificConfigurationLogic.CreateFacilityExtensionAsync(facilityExtensions); // Assert _mockFacilitySpecificConfigurationRepository.Verify(f => f.Add(It.IsAny <FacilityLogisticsConfig>()), Times.Once); _unitOfWorkMock.Verify(w => w.CommitChangesAsync(), Times.Once); }
public async Task<ActionResult<FacilityLogisticsConfigurationExtension>> PostFacilityExtensionAsync(FacilityLogisticsConfigurationExtension facilityLogisticsConfigurationExtension) { try { facilityLogisticsConfigurationExtension.FacilityKey = Guid.Parse(_accessor.Current.Facility.FacilityKey); if (ModelState.IsValid) { BusinessResponse response = await _business.CreateFacilityExtensionAsync(facilityLogisticsConfigurationExtension); if (response.IsSuccess == false) { _logger.LogError("Bad Request:", response.Message); return BadRequest(response.Message); } else { _logger.LogInformation("Created Successfully : {CreatedResult}", facilityLogisticsConfigurationExtension); return Created(new Uri($"{Request.Path}", UriKind.Relative), new { Message = "Created Successfully.", Model = facilityLogisticsConfigurationExtension }); } } else { _logger.LogError("Bad Request:", ModelState.ValidationState); return BadRequestErrorMessage(); } } catch (ArgumentNullException ex) { _logger.LogError(ex.Message); return BadRequestErrorMessage(); } catch (DbUpdateException ex) { _logger.LogError(ex.Message); return BadRequestErrorMessage(); } }
public async Task<ActionResult<FacilityLogisticsConfigurationExtension>> PutFacilityExtensionAsync(FacilityLogisticsConfigurationExtension facilityLogisticsConfigurationExtension) { try { facilityLogisticsConfigurationExtension.FacilityKey = Guid.Parse(_accessor.Current.Facility.FacilityKey); if (ModelState.IsValid) { BusinessResponse businessResponse = await _business.UpdateFacilityExtensionAsync(facilityLogisticsConfigurationExtension); if (businessResponse.IsSuccess == false) { _logger.LogError("Bad Request:", businessResponse.Message); return BadRequest(businessResponse.Message); } else { _logger.LogInformation("Updated Successfully : {UpdateResult}", facilityLogisticsConfigurationExtension); return Ok(businessResponse.Message); } } else { _logger.LogError("Bad Request:", ModelState.ValidationState); return BadRequestErrorMessage(); } } catch (ArgumentNullException ex) { _logger.LogError(ex.Message); return BadRequestErrorMessage(); } catch (DbUpdateException ex) { _logger.LogError(ex.Message); return BadRequestErrorMessage(); } }