コード例 #1
0
ファイル: ComputerCpu.cs プロジェクト: damy90/Telerik-all
 public ComputerCpu(byte numberOfCores, byte numberOfBits, ComputerRam ram, ComputerHardDrive hardDrive)
 {
     this.numberOfBits = numberOfBits;
     this.ram = ram;
     this.NumberOfCores = numberOfCores;
     this.computerHardDrive = hardDrive;
 }
コード例 #2
0
 public void TestCpuReturnExactCoreAndNumberOfBits()
 {
     var ram = new ComputerRam(8);
     var hardDrive = new ComputerHardDrive();
     var cpu = new ComputerCpu(4, 64, ram, hardDrive);
     cpu.SquareNumber64();
     var cores = cpu.NumberOfCores;
     Assert.AreEqual(4, cores);
 }
コード例 #3
0
ファイル: TestCpuRand.cs プロジェクト: damy90/Telerik-all
 public void TestRandomNumberIsOutOfRange()
 {
     var ram = new ComputerRam(8);
     var hardDrive = new ComputerHardDrive();
     var cpu = new ComputerCpu(4, 64, ram, hardDrive);
     var expectedNumber = cpu.Rand(1, 100);
     var result = expectedNumber > 100 ? true : false;
     Assert.IsFalse(false);
 }
コード例 #4
0
ファイル: TestCpuRand.cs プロジェクト: damy90/Telerik-all
 public void TestRandomNumberBetweenNumbers()
 {
     var ram = new ComputerRam(8);
     var hardDrive = new ComputerHardDrive();
     var cpu = new ComputerCpu(4, 64, ram, hardDrive);
     var expectedNumber = cpu.Rand(1, 10);
     var result = ((0 > expectedNumber) && (expectedNumber > 10)) ? true : false; 
     Assert.IsFalse(false);
 }
コード例 #5
0
ファイル: CreateHpSystem.cs プロジェクト: damy90/Telerik-all
        public override ComputerTemplate BuildComputer()
        {
            var desctopRam = new ComputerRam(ComputerNumber / 4);
            var desctopHardDrive = new ComputerHardDrive(false);
            var desctopCpu = new ComputerCpu(ComputerNumber / 4, 32, desctopRam, desctopHardDrive);
            var desctopHardDrives = new[]
            {
                new ComputerHardDrive(500, false, 0)
            };
            var desctopComputer = new Computer(
                Type.PC,
                desctopCpu,
                desctopRam,
                desctopHardDrives,
                desctopHardDrive,
                null);

            var serverRam = new ComputerRam(ComputerNumber * 4);
            var serverHardDrive = new ComputerHardDrive();
            var serverCpu = new ComputerCpu(ComputerNumber / 2, 32, serverRam, serverHardDrive);
            var serverHardDrives = new List<ComputerHardDrive>
            {
                new ComputerHardDrive(1000, false, 0), 
                new ComputerHardDrive(1000, false, 0)
            };
            var serverRaidHardDrive = new List<ComputerHardDrive>
            {
                new ComputerHardDrive(0, true, 2, serverHardDrives)
            };

            var server = new Computer(
                Type.SERVER,
                serverCpu,
                serverRam,
                serverRaidHardDrive,
                serverHardDrive,
                null);

            var laptopHardDrive = new ComputerHardDrive(false);
            var laptopRam = new ComputerRam(ComputerNumber / 2);
            var laptopCpu = new ComputerCpu(ComputerNumber / 4, 64, laptopRam, laptopHardDrive);
            var laptopHardDrives = new[]
            {
                new ComputerHardDrive(500, false, 0)
            };
            var laptop = new Computer(
                Type.LAPTOP,
                laptopCpu,
                laptopRam,
                laptopHardDrives,
                laptopHardDrive,
                new LaptopBattery());

            return new ComputerTemplate(desctopComputer, laptop, server);
        }
コード例 #6
0
ファイル: Computer.cs プロジェクト: damy90/Telerik-all
        internal Computer(Type type, ComputerCpu cpu, ComputerRam ram, IEnumerable<ComputerHardDrive> hardDrives, ComputerHardDrive hardDrive, LaptopBattery battery)
        {
            this.Cpu = cpu;
            this.Ram = ram;
            this.HardDrives = hardDrives;
            this.HardDrive = hardDrive;
            if (type == Type.SERVER)
            {
                this.HardDrive.IsMonochrome = true;
            }

            this.battery = battery;
        }
コード例 #7
0
        public override ComputerTemplate BuildComputer()
        {
            var desctopRam = new ComputerRam(ComputerNumber);
            var desctopHardDrive = new ComputerHardDrive(false);
            var desctopCpu = new ComputerCpu(ComputerNumber / 2, 64, desctopRam, desctopHardDrive);
            var desctopHardDrives = new[] { new ComputerHardDrive(1000, false, 0) };
            var pc = new Computer(
                Type.PC,
                desctopCpu,
                desctopRam,
                desctopHardDrives,
                desctopHardDrive,
                null);

            var serverRam = new ComputerRam(ComputerNumber * ComputerNumber);
            var initServerHardDrives = new List<ComputerHardDrive>
            {
                new ComputerHardDrive(2000, false, 0),
                new ComputerHardDrive(2000, false, 0)
            };
            var serverHardDrive = new ComputerHardDrive(0, true, 2, initServerHardDrives);
            var serverCpu = new ComputerCpu(ComputerNumber, 64, serverRam, serverHardDrive);
            var serversHardDrives = new List<ComputerHardDrive> { serverHardDrive };
            var server = new Computer(
                Type.SERVER,
                serverCpu,
                serverRam,
                serversHardDrives,
                serverHardDrive,
                null);

            var laptopRam = new ComputerRam(ComputerNumber);
            var laptopVideoCard = new ComputerHardDrive(false);
            var laptopCpu = new ComputerCpu(ComputerNumber / 2, 32, laptopRam, laptopVideoCard);
            var laptopHardDrives = new[] { new ComputerHardDrive(1000, false, 0) };
            var laptopBattery = new LaptopBattery();
            var laptop = new Computer(
                Type.LAPTOP,
                laptopCpu,
                laptopRam,
                laptopHardDrives,
                laptopVideoCard,
                laptopBattery);

            return new ComputerTemplate(pc, laptop, server);
        }