示例#1
0
 public void SquareOfNegativeNumberShouldReturnTooLow()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(-1001);
     var cpu = new Cpu(4, 64, ram);
     Assert.AreEqual("Number too low.", cpu.SquareNumber());
 }
示例#2
0
 public void SquareOf1001ShouldReturnTooLong()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(1001);
     var cpu = new Cpu(4, 64, ram);
     Assert.AreEqual("Number too high.", cpu.SquareNumber());
 }
示例#3
0
 public void SquareOf1000ShouldReturn1000000()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(1000);
     var cpu = new Cpu(4, 64, ram);
     Assert.AreEqual("Square of 1000 is 1000000.", cpu.SquareNumber());
 }
示例#4
0
 public void UsingInvalidCpuShouldReturnInvalid()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(0);
     var cpu = new Cpu(4, 86, ram);
     Assert.AreEqual("Invalid CPU", cpu.SquareNumber());
 }
示例#5
0
 public void SquareOfZeroShouldReturnZero()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(0);
     var cpu = new Cpu(4, 32, ram);
     Assert.AreEqual("Square of 0 is 0.", cpu.SquareNumber());
 }
示例#6
0
 public void SquareOfFiveShouldReturn25()
 {
     var ram = new RamMemory(8);
     ram.SaveValue(5);
     var cpu = new Cpu(4, 32, ram);
     Assert.AreEqual("Square of 5 is 25.", cpu.SquareNumber());
 }
示例#7
0
        public static Computer GetComputer(ComputerType computerType)
        {
            RamMemory ram;
            VideoCard videoCard;
            Cpu cpu;

            switch (computerType)
            {
                case ComputerType.Pc:
                    {
                        ram = new RamMemory(DefaultRamSize / 4);
                        videoCard = new VideoCard()
                        {
                            IsMonochrome = false
                        };

                        cpu = new Cpu(DefaultRamSize / 4, ThirtyTwoBitsArchitecture, ram);
                        var computerHardDrivers = new[] { new HardDriver(500, false, 0, null) };
                        return new Computer(computerType, cpu, ram, computerHardDrivers, videoCard, null);
                    }

                case ComputerType.Server:
                    {
                        ram = new RamMemory(DefaultRamSize * 4);
                        videoCard = new VideoCard();
                        cpu = new Cpu(DefaultRamSize / 2, ThirtyTwoBitsArchitecture, ram);
                        var serverHardDrivers = new List<HardDriver> { new HardDriver(0, true, 2, new List<HardDriver> { new HardDriver(1000, false, 0, null), new HardDriver(1000, false, 0, null) }) };

                        return new Computer(computerType, cpu, ram, serverHardDrivers, videoCard, null);
                    }

                case ComputerType.Laptop:
                    {
                        ram = new RamMemory(DefaultRamSize / 2);
                        videoCard = new VideoCard()
                        {
                            IsMonochrome = false
                        };
                        cpu = new Cpu(DefaultRamSize / 4, ThirtyTwoBitsArchitecture * 2, ram);
                        var laptopHardDriver = new[] { new HardDriver(500, false, 0, null) };

                        return new Computer(computerType, cpu, ram, laptopHardDriver, videoCard, new LaptopBattery());
                    }

                default:
                    throw new ArgumentException();
            }
        }