Exemplo n.º 1
0
        public void ScopeNameTester_FromString(String input)
        {
            ScopeName description = ScopeName.FromString(input);

            String result = description;

            Assert.Equal(input, result);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void ScopeName_InvalidCharsEmpty()
        {
            List <String> inputs = new List <string> {
                "asfsfsfsfsfa`f`",
                "gdg45sfsfsf**~",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeName.FromString(invalidInput));
            }
        }
Exemplo n.º 4
0
        public void ScopeNameTester_StringEmpty()
        {
            List <String> inputs = new List <string> {
                null,
                String.Empty,
                "",
                "    ",
                "\n\r\t",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeName.FromString(invalidInput));
            }
        }
Exemplo n.º 5
0
        public void ScopeName_ToLong()
        {
            Random random = new Random();
            Int32  max    = ScopeName.MaxLength;

            String inputToPass = random.GetAlphanumericString(max);
            String output      = ScopeName.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>(() => ScopeName.FromString(invalidInput));
            }
        }
Exemplo n.º 6
0
        public void ScopeName_ToShort()
        {
            Random random = new Random();
            Int32  min    = ScopeName.MinLenth;

            String inputToPass = random.GetAlphanumericString(min);
            String output      = ScopeName.FromString(inputToPass);

            Assert.Equal(inputToPass, output);

            List <String> inputs = new List <string> {
                random.GetAlphanumericString(min - 1),
                random.GetAlphanumericString(min - 2),
                random.GetAlphanumericString(min - random.Next(1, min - 1)),
            };

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