Esempio n. 1
0
            public void ConnectTo(IUsbSocket socket)
            {
                MAmp mAmps = socket.GetPower();

                if (mAmps > this._maxMAmps)
                {
                    throw new OverflowException();
                }
                this._mAmps = mAmps;
            }
Esempio n. 2
0
        public override void Execute()
        {
            MAmp maxUsbPower = 200;

            var phone = new Phone(maxMAmps: maxUsbPower);

            Assert.False(phone.IsCharging);

            var outlet  = new AcOutlet(amps: 15);
            var adapter = new UsbAdapter(socket: outlet, maxMAmps: maxUsbPower);

            phone.ConnectTo(adapter);
            Assert.True(phone.IsCharging);

            var badAdapter = new BadUsbAdapter(socket: outlet);

            Assert.Throws <OverflowException>(() => phone.ConnectTo(badAdapter));
        }
Esempio n. 3
0
 public Phone(MAmp maxMAmps)
 {
     this._maxMAmps = maxMAmps;
 }
Esempio n. 4
0
 public UsbAdapter(IAcSocket socket, MAmp maxMAmps)
 {
     this._socket   = socket;
     this._maxMAmps = maxMAmps;
 }