예제 #1
0
        public override ComputerServer MakeServer()
        {
            ComputerServer server;

            var serverRam = new Ram(12);
            var serverHDD = new HardDrive();

            var hardDrives = new List<HardDrive>
                {
                    new HardDrive(
                        0,
                        true,
                        2,
                        new List<HardDrive>
                        { 
                            new HardDrive(1000, false, 0), new HardDrive(1000, false, 0) 
                        })
                };

            var serverCpu = new Cpu(4, 32, serverRam);

            server = new ComputerServer(
                serverCpu,
                serverRam,
                hardDrives,
                serverHDD,
                null, 
                new Videocard(true));

            return server;
        }
예제 #2
0
 public ComputerServer(
     Cpu cpu,
     Ram ram,
     IEnumerable<HardDrive> hardDrives,
     HardDrive hardDrive,
     LaptopBattery battery,
     Videocard videocard)
     : base(cpu, ram, hardDrives, hardDrive, battery, videocard)
 {
 }
        public void SqureShouldReturnNumberTooHigh128bit()
        {
            var ram = new Ram(8);
            var cpu = new Cpu(2, 128, ram);

            ram.SaveValue(2001);
            var actual = cpu.SquareNumber();
            var expected = NumTooHigh;

            Assert.AreEqual(expected, actual);
        }
        public void SqureShouldReturnNumberTooLow()
        {
            var ram = new Ram(8);
            var cpu = new Cpu(2, 32, ram);

            ram.SaveValue(-1);
            var actual = cpu.SquareNumber();
            var expected = NumTooLow;

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void CpuReturnsRandNumberInCorrectInterval()
        {
            int min = 10;
            int max = 100;

            var ram = new Ram(8);
            var cpu = new Cpu(2, 32, ram);

            cpu.Rand(min, max);
            var actual = ram.LoadValue();

            Assert.IsTrue(min <= actual && actual < max);
        }
예제 #6
0
 internal Computer(
     Cpu cpu,
     IRam ram,
     IEnumerable<HardDrive> hardDrives,
     IHardDrive hardDrive,
     LaptopBattery battery,
     IVideocard videocard)
 {
     this.cpu = cpu;
     this.ram = ram;
     this.hardDrives = hardDrives;
     this.hardDrive = hardDrive;
     this.videocard = videocard;
     this.battery = battery;
 }
        public void SqureShouldReturnCorrectValue()
        {
            int numberToSqure = 500;
            int square = numberToSqure * numberToSqure;
 
            // Create a mocked RAM to give a number to the CPU to operate with
            var mockedRam = new Mock<IRam>();
            mockedRam.Setup(r => r.LoadValue()).Returns(numberToSqure);

            var cpu = new Cpu(2, 32, mockedRam.Object);

            var actual = cpu.SquareNumber();
            var expected = string.Format(SquareResultFormat, numberToSqure, square);

            Assert.AreEqual(expected, actual);
        }
예제 #8
0
 public void CpuRandShouldThrowIfMinLessThanMax()
 {
     var cpu = new Cpu(2, 32, new Ram(8));
     cpu.Rand(100, 10);
 }