public void Add_ExistingName_NotAdded() { var configurationReader = new ConfigurationEngine(_dataRepository, _mockCacheRepository, ApplicationName, 1); _dataRepository.IsRecordExists(Arg.Any <string>(), Arg.Any <string>()).Returns(true); var result = configurationReader.Add(new AddConfigurationDTO { IsActive = true, Name = "Name", Type = "Type", Value = "Value" }); Assert.False(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); }