public string Fire(Unit target)
        {
            string result = string.Empty;

            RuleSet idealHitRules = new RuleSet();
            idealHitRules.Add(new UnderMaximumIdealRangeRule(this, target));
            idealHitRules.Add(new OverMinimumIdealRangeRule(this, target));

            RuleSet regularHitRules = new RuleSet();
            regularHitRules.Add(new UnderMaximumRangeRule(this, target));
            regularHitRules.Add(new OverMinimumRangeRule(this, target));

            //Fire!
            if (idealHitRules.Validate())
            {
                result = "Ideal hit!";
            }
            else if (regularHitRules.Validate())
            {
                result = "Hit.";
            }
            else
            {
                result = regularHitRules.FailureMessages[0];
            }

            return result;
        }
        public static void Main()
        {
            Unit unit1 = new Unit();
            Unit unit2 = new Unit();

            Console.WriteLine("Unit1");
            Console.WriteLine("Name:");
            unit1.Name = Console.ReadLine();

            Console.WriteLine("Minimum Range:");
            unit1.MinimumRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Minimum Ideal Range:");
            unit1.MinimumIdealRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Maximum Range:");
            unit1.MaximumRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Maximum Ideal Range:");
            unit1.MaximumIdealRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("X:");
            unit1.XCoordinate = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Y:");
            unit1.YCoordinate = Int32.Parse(Console.ReadLine());

            Console.WriteLine(string.Empty);
            Console.WriteLine(string.Empty);
            Console.WriteLine(string.Empty);

            Console.WriteLine("Unit2");
            Console.WriteLine("Name:");
            unit2.Name = Console.ReadLine();

            Console.WriteLine("Minimum Range:");
            unit2.MinimumRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Minimum Ideal Range:");
            unit2.MinimumIdealRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Maximum Range:");
            unit2.MaximumRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("Maximum Ideal Range:");
            unit2.MaximumIdealRange = Double.Parse(Console.ReadLine());

            Console.WriteLine("X:");
            unit2.XCoordinate = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Y:");
            unit2.YCoordinate = Int32.Parse(Console.ReadLine());

            Console.WriteLine(unit1.Fire(unit2));

            Console.ReadLine();
        }
        public void FailMaxRangeTest()
        {
            //Assemble
            Unit unit1 = new Unit() { MaximumRange = 10, XCoordinate = 0, YCoordinate = 0 };
            Unit unit2 = new Unit() { MaximumRange = 10, XCoordinate = 0, YCoordinate = 500 };

            RuleSet rules = new RuleSet();
            rules.Add(new UnderMaximumRangeRule(unit1, unit2));

            //Act
            bool success = rules.Validate();

            //Assert
            Assert.IsFalse(success, "Unit should be outside of max range");
        }
        public void PassMaxIdealRangeTest()
        {
            //Assemble
            Unit unit1 = new Unit() { MaximumIdealRange = 10, XCoordinate = 0, YCoordinate = 0 };
            Unit unit2 = new Unit() { MaximumIdealRange = 10, XCoordinate = 0, YCoordinate = 5 };

            RuleSet rules = new RuleSet();
            rules.Add(new UnderMaximumIdealRangeRule(unit1, unit2));

            //Act
            bool success = rules.Validate();

            //Assert
            Assert.IsTrue(success, "Unit should be inside of max ideal range");
        }
        public void FailMinIdealRangeTest()
        {
            //Assemble
            Unit unit1 = new Unit() { MinimumIdealRange = 10, XCoordinate = 0, YCoordinate = 0 };
            Unit unit2 = new Unit() { MinimumIdealRange = 10, XCoordinate = 0, YCoordinate = 5 };

            RuleSet rules = new RuleSet();
            rules.Add(new OverMinimumIdealRangeRule(unit1, unit2));

            //Act
            bool success = rules.Validate();

            //Assert
            Assert.IsFalse(success, "Unit should be inside of min ideal range");
        }