コード例 #1
0
        public void Add_ValidRequest_Added()
        {
            var configurationReader = new ConfigurationReader(_mockCacheManager, _mockStorageProvider, ApplicationName, 1);

            _mockStorageProvider.Exists(Arg.Any <string>(), Arg.Any <string>()).Returns(false);
            _mockStorageProvider.Add(Arg.Any <AddStorageConfigurationDTO>()).Returns(true);

            var result = configurationReader.Add(new AddConfigurationDTO
            {
                IsActive = true,
                Name     = "Name",
                Type     = "Type",
                Value    = "Value"
            });

            Assert.True(result);
        }
コード例 #2
0
        public async Task <IActionResult> Create([FromForm] CreateViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create"));
            }

            var configurationModel = new ConfigurationModel();

            configurationModel.ApplicationName = viewModel.ApplicationName;
            configurationModel.Name            = viewModel.Name;
            configurationModel.Value           = viewModel.Value;
            configurationModel.IsActive        = viewModel.IsActive;

            await _storageProvider.Add(configurationModel);

            return(Content("Configuration added."));
        }
コード例 #3
0
        public bool Add(AddConfigurationDTO dto)
        {
            var validationResult = new AddNewConfigurationValidator().Validate(dto);

            if (validationResult.IsValid)
            {
                var isExist = _storageProvider.Exists(dto.Name, _applicationName);
                if (!isExist)
                {
                    return(_storageProvider.Add(new AddStorageConfigurationDTO
                    {
                        Type = dto.Type,
                        IsActive = dto.IsActive,
                        Value = dto.Value,
                        Name = dto.Name,
                        ApplicationName = _applicationName
                    }));
                }
            }

            return(false);
        }