public void Add_ValidRequest_Added() { var configurationReader = new ConfigurationEngine(_dataRepository, _mockCacheRepository, ApplicationName, 1); _dataRepository.IsRecordExists(Arg.Any <string>(), Arg.Any <string>()).Returns(false); _dataRepository.Add(Arg.Any <AddConfigurationRepositoryDTO>()).Returns(true); var result = configurationReader.Add(new AddConfigurationDTO { IsActive = true, Name = "Name", Type = "Type", Value = "Value" }); Assert.True(result); }
public bool Add(AddConfigurationDTO dto) { var validationResult = new AddNewConfigurationValidator().Validate(dto); if (!validationResult.IsValid) { return(false); } var isExist = _storageProvider.IsRecordExists(dto.Name, _applicationName); if (!isExist) { return(_storageProvider.Add(new AddConfigurationRepositoryDTO { Type = dto.Type, IsActive = dto.IsActive, Value = dto.Value, Name = dto.Name, ApplicationName = _applicationName })); } return(false); }