Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #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();
            }
        }