Esempio n. 1
0
        public override void Mutate()
        {
            var randomRange = new RandomAddressRangeObjectFactory().Generate();

            RangeStartAddress = randomRange.RangeStartAddress;
            RangeEndAddress   = randomRange.RangeEndAddress;
        }
        public T GenerateRandomObject <T>() where T : FirewallObject
        {
            var typeToGenerate = typeof(T).Name;

            // Looks to complicated: why down and then up casting?
            switch (typeToGenerate)
            {
            case "AddressObject":
                FirewallObject addressObject = new RandomAddressObjectFactory().Generate();
                return((T)addressObject);

            case "SubnetObject":
                FirewallObject newSubnet = new RandomSubnetObjectFactory().Generate();
                return((T)newSubnet);

            case "AddressRangeObject":
                FirewallObject addressRange = new RandomAddressRangeObjectFactory().Generate();
                return((T)addressRange);

            case "AddressGroupObject":
                FirewallObject addressGroup = new RandomAddressGroupObjectFactory(addableRepository).Generate();
                return((T)addressGroup);

            default:
                throw new ArgumentException(string.Format("Unexpected type {0}", typeToGenerate));
            }
        }
        public AddressGroupObject Generate()
        {
            var address = new RandomAddressObjectFactory().Generate();
            var subnet  = new RandomSubnetObjectFactory().Generate();
            var range   = new RandomAddressRangeObjectFactory().Generate();

            this.addableRepository.Add(address);
            this.addableRepository.Add(subnet);
            this.addableRepository.Add(range);

            var members = new List <string> {
                address.Name, subnet.Name, range.Name
            };

            return(new AddressGroupObject(GenerateRandomName(), members));
        }