示例#1
0
        public void ScopeDescription_FromString(String input)
        {
            ScopeDescription description = ScopeDescription.FromString(input);

            String result = description;

            Assert.Equal(input, result);
        }
示例#2
0
        public async Task <Boolean> Handle(UpdateDHCPv4ScopeCommand request, CancellationToken cancellationToken)
        {
            _logger.LogDebug("Handle started");

            var scope = _rootScope.GetScopeById(request.ScopeId);

            if (scope == DHCPv4Scope.NotFound)
            {
                return(false);
            }

            Guid?parentId          = scope.HasParentScope() == false ? new Guid?() : scope.ParentScope.Id;
            var  properties        = GetScopeProperties(request);
            var  addressProperties = GetScopeAddressProperties(request);

            if (request.Name != scope.Name)
            {
                _rootScope.UpdateScopeName(request.ScopeId, ScopeName.FromString(request.Name));
            }
            if (request.Description != scope.Description)
            {
                _rootScope.UpdateScopeDescription(request.ScopeId, ScopeDescription.FromString(request.Description));
            }
            if (request.ParentId != parentId)
            {
                _rootScope.UpdateParent(request.ScopeId, request.ParentId);
            }

            _rootScope.UpdateScopeResolver(request.ScopeId, GetResolverInformation(request));

            if (addressProperties != scope.AddressRelatedProperties)
            {
                _rootScope.UpdateAddressProperties(request.ScopeId, addressProperties);
            }

            if (properties != scope.Properties)
            {
                _rootScope.UpdateScopeProperties(request.ScopeId, properties);
            }

            Boolean result = await _store.Save(_rootScope);

            if (result == true)
            {
                var triggers = _rootScope.GetTriggers();

                if (triggers.Any() == true)
                {
                    await _serviceBus.Publish(new NewTriggerHappendMessage(triggers));

                    _rootScope.ClearTriggers();
                }
            }

            return(result);
        }
示例#3
0
        public void ScopeDescription_InvalidCharsEmpty()
        {
            List <String> inputs = new List <string> {
                "asfa`f`",
                "**~",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }
示例#4
0
        public void ScopeDescription_StringEmpty()
        {
            List <String> inputs = new List <string> {
                null,
                String.Empty,
                "",
                "    ",
                "\n\r\t",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }
示例#5
0
        public void ScopeDescription_ToLong()
        {
            Random random = new Random();
            Int32  max    = ScopeDescription.MaxLength;

            String inputToPass = random.GetAlphanumericString(max);
            String output      = ScopeDescription.FromString(inputToPass);

            Assert.Equal(inputToPass, output);

            List <String> inputs = new List <string> {
                random.GetAlphanumericString(max + 1),
                random.GetAlphanumericString(max + 2),
                random.GetAlphanumericString(max + random.Next(200, 400)),
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }