static void Main(string[] args)
        {
            string ip = "";
            string subnetMask = "";

            bool isValid = false;
            do
            {
                Console.WriteLine("Type ip:");
                ip = Console.ReadLine();
                isValid = IsValidIP(ip);
            } while (!isValid);

            isValid = false;
            do
            {
                Console.WriteLine("Type submask:");
                subnetMask = Console.ReadLine();
                isValid = IsValidSubmask(subnetMask);
            } while (!isValid);

            Calculator calculator = new Calculator();
            var result = calculator.Calculate(ip, subnetMask);

            string network = result["network"];
            string broadcast = result["broadcast"];
            string firstHost = result["firstHost"];
            string lastHost = result["lastHost"];
            Console.WriteLine(string.Format($"++++++++++++++++++++++++++++"));
            Console.WriteLine(string.Format($"ip:          {ip}"));
            Console.WriteLine(string.Format($"subnet mask: {subnetMask}"));
            Console.WriteLine(string.Format($"network:     {network}"));
            Console.WriteLine(string.Format($"broadcast:   {broadcast}"));
            Console.WriteLine(string.Format($"first host:  {firstHost}"));
            Console.WriteLine(string.Format($"last host:   {lastHost}"));
            Console.WriteLine(string.Format($"++++++++++++++++++++++++++++"));
            Console.ReadLine();
        }
        public void CalculationTest()
        {
            string ip = "126.1.100.100";
            string subnetMask = "255.255.255.224";

            Calculator calculator = new Calculator();
            var result = calculator.Calculate(ip, subnetMask);

            string network = result["network"];
            string broadcast = result["broadcast"];
            string firstHost = result["firstHost"];
            string lastHost = result["lastHost"];

            Assert.AreEqual("126.1.100.96", network);
            Assert.AreEqual("126.1.100.127", broadcast);
            Assert.AreEqual("126.1.100.97", firstHost);
            Assert.AreEqual("126.1.100.126", lastHost);

            ip = "126.100.100.100";
            subnetMask = "255.255.255.248";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("126.100.100.96", network);
            Assert.AreEqual("126.100.100.103", broadcast);
            Assert.AreEqual("126.100.100.97", firstHost);
            Assert.AreEqual("126.100.100.102", lastHost);

            ip = "192.0.0.0";
            subnetMask = "255.255.255.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("192.0.0.0", network);
            Assert.AreEqual("192.0.0.255", broadcast);
            Assert.AreEqual("192.0.0.1", firstHost);
            Assert.AreEqual("192.0.0.254", lastHost);

            ip = "192.125.203.15";
            subnetMask = "255.255.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("192.125.0.0", network);
            Assert.AreEqual("192.125.255.255", broadcast);
            Assert.AreEqual("192.125.0.1", firstHost);
            Assert.AreEqual("192.125.255.254", lastHost);

            ip = "192.125.203.15";
            subnetMask = "255.0.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("192.0.0.0", network);
            Assert.AreEqual("192.255.255.255", broadcast);
            Assert.AreEqual("192.0.0.1", firstHost);
            Assert.AreEqual("192.255.255.254", lastHost);

            ip = "126.125.203.15";
            subnetMask = "255.192.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("126.64.0.0", network);
            Assert.AreEqual("126.127.255.255", broadcast);
            Assert.AreEqual("126.64.0.1", firstHost);
            Assert.AreEqual("126.127.255.254", lastHost);

            ip = "126.125.203.15";
            subnetMask = "255.192.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("126.64.0.0", network);
            Assert.AreEqual("126.127.255.255", broadcast);
            Assert.AreEqual("126.64.0.1", firstHost);
            Assert.AreEqual("126.127.255.254", lastHost);

            ip = "1.0.0.0";
            subnetMask = "255.0.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("1.0.0.0", network);
            Assert.AreEqual("1.255.255.255", broadcast);
            Assert.AreEqual("1.0.0.1", firstHost);
            Assert.AreEqual("1.255.255.254", lastHost);

            ip = "10.0.0.15";
            subnetMask = "255.128.0.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("10.0.0.0", network);
            Assert.AreEqual("10.127.255.255", broadcast);
            Assert.AreEqual("10.0.0.1", firstHost);
            Assert.AreEqual("10.127.255.254", lastHost);

            ip = "10.0.255.15";
            subnetMask = "255.255.254.0";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("10.0.254.0", network);
            Assert.AreEqual("10.0.255.255", broadcast);
            Assert.AreEqual("10.0.254.1", firstHost);
            Assert.AreEqual("10.0.255.254", lastHost);

            ip = "10.0.255.15";
            subnetMask = "255.255.255.252";
            result = calculator.Calculate(ip, subnetMask);

            network = result["network"];
            broadcast = result["broadcast"];
            firstHost = result["firstHost"];
            lastHost = result["lastHost"];

            Assert.AreEqual("10.0.255.12", network);
            Assert.AreEqual("10.0.255.15", broadcast);
            Assert.AreEqual("10.0.255.13", firstHost);
            Assert.AreEqual("10.0.255.14", lastHost);
        }