public void RandomNegativeNumberTest()
        {
            HpBuildStrategy builder = new HpBuildStrategy();
            var computers = builder.BuildComputers();
            Computer pc = computers[0];

            CommandProcessor.ProcessCommand("Play -5", pc, null, null);
            var value = pc.Ram.LoadValue();

            Assert.AreEqual(null, value);
        }
        public void RandomEmptyNumberTest()
        {
            HpBuildStrategy builder = new HpBuildStrategy();
            var computers = builder.BuildComputers();
            Computer pc = computers[0];

            bool isProcessed = true;
            try
            {
                CommandProcessor.ProcessCommand("Play  ", pc, null, null);
            }
            catch (InvalidArgumentException)
            {
                isProcessed = false;
            }

            Assert.AreEqual(false, isProcessed);
        }
        public void RandomAllNumbersTest()
        {
            HpBuildStrategy builder = new HpBuildStrategy();
            var computers = builder.BuildComputers();
            Computer pc = computers[0];
            List<int> expected = new List<int>(){1,2,3,4,5,6,7,8,9,10};
            List<int> generated = new List<int>();
            bool allNumbersPresent = false;

            for (int i = 0; i < 100; i++)
            {
                CommandProcessor.ProcessCommand("Play  15", pc, null, null);
                var value = pc.Ram.LoadValue();
                if (!generated.Contains(value))
                {
                    generated.Add(value);
                }
            }
            List<int> result = expected.Except(generated).ToList();
            Assert.AreEqual(0, result.Count);
        }
        public void SquareZeroNumber64BitTest()
        {
            HpBuildStrategy builder = new HpBuildStrategy();
            var computers = builder.BuildComputers();
            Computer server = computers[1];

            FieldInfo fieldInfo = server.Ram.GetType().GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);
            fieldInfo.SetValue(server.Ram, 0);

            server.Cpu.SquareNumber();

            var originalConsoleOut = Console.Out; // preserve the original stream
            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);
                server.Cpu.SquareNumber();
                writer.Flush(); // when you're done, make sure everything is written out

                var myString = writer.GetStringBuilder().ToString();
                Console.SetOut(originalConsoleOut);
                Assert.AreEqual("Square of 0 is 0.\r\n", myString);
            }

            Console.SetOut(originalConsoleOut); // restore Console.Out
        }
        public void SquareFloatingNumber64BitTest()
        {
            HpBuildStrategy builder = new HpBuildStrategy();
            var computers = builder.BuildComputers();
            Computer server = computers[1];

            FieldInfo fieldInfo = server.Ram.GetType().GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);

            bool isWoring = false;
            try
            {
                fieldInfo.SetValue(server.Ram, 1.11111d);
            }
            catch (ArgumentException)
            {
                isWoring = true;
            }

            Assert.AreEqual(true, isWoring);
        }