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()); }
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()); }
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()); }
public void UsingInvalidCpuShouldReturnInvalid() { var ram = new RamMemory(8); ram.SaveValue(0); var cpu = new Cpu(4, 86, ram); Assert.AreEqual("Invalid CPU", cpu.SquareNumber()); }
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()); }
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()); }
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(); } }
public Cpu(byte numberOfCores, byte numberOfBits, RamMemory ram) { this.numberOfBits = numberOfBits; this.ram = ram; this.NumberOfCores = numberOfCores; }