Ejemplo n.º 1
0
        public void GetDeliveringVolume_SingleHose_ReturnsHoseDeliveringVolume()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.GetDeliveringVolume, "01", ref status))
                .Callback(() => status = "00")
                .Returns("024394300000000000001");
            var forecourt = new Wayne(_mockIO.Object);

            var volume = forecourt.GetDeliveringVolume(new Hose(1));
            forecourt.Dispose();

            status.Should().Be("00");
            volume.Should().Be(243.943d);
        }
Ejemplo n.º 2
0
        public void GetDeliveringVolume_HoseList_ReturnsDeliveringVolumeForEachHose()
        {
            var status = string.Empty;
            var callCount = 0;
            var returnValues = new string[] { "024394300000000000001", "002075200000000000002" };
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.GetDeliveringVolume, "01", ref status))
                .Returns(() => returnValues[callCount])
                .Callback(() => { status = "00"; callCount++; });
            var forecourt = new Wayne(_mockIO.Object);
            var hose1 = new Hose(1);
            var hose2 = new Hose(2);
            var hoseList = new List<Hose>() { hose1, hose2 };

            var dic = forecourt.GetDeliveringVolume(hoseList);
            forecourt.Dispose();

            status.Should().Be("00");
            dic[hose1].Should().Be(243.943d);
            dic[hose2].Should().Be(20.752d);
        }
Ejemplo n.º 3
0
        public void GetPrice_SingleHose_ReturnsHosePrice()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.GetPrice, "01", ref status))
                .Callback(() => status = "00")
                .Returns("0000000002890");
                
            var forecourt = new Wayne(_mockIO.Object);

            var price = forecourt.GetPrice(new Hose(1));
            forecourt.Dispose();

            status.Should().Be("00");
            price.Should().Be(2.890d);
        }
Ejemplo n.º 4
0
        public void SetPrice_SingleHoseAndSomeValue_SetsHosePriceWithSpecifiedValue()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.SetPrice, "0113784", ref status))
                .Verifiable();
            var forecourt = new Wayne(_mockIO.Object);

            forecourt.SetPrice(new Hose(1), 3.784);
            forecourt.Dispose();

            _mockIO.Verify(c => c.SendAndReceive(WayneCommands.SetPrice, "0113784", ref status));
        }
Ejemplo n.º 5
0
        public void PresetByVolume_SingleHoseAndSomeVolume_PresetHoseWithSpecifiedVolume()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.PresetByVolume, "0101581", ref status))
                .Verifiable();
            var forecourt = new Wayne(_mockIO.Object);

            forecourt.PresetByVolume(new Hose(1), 158d);
            forecourt.Dispose();

            _mockIO.Verify(c => c.SendAndReceive(WayneCommands.PresetByVolume, "0101581", ref status));
        }
Ejemplo n.º 6
0
        public void Block_SingleHose_BlocksHose()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.BlockHose, "012", ref status))
                .Verifiable();
            var forecourt = new Wayne(_mockIO.Object);

            forecourt.Block(new Hose(1));
            forecourt.Dispose();

            _mockIO.Verify(c => c.SendAndReceive(WayneCommands.BlockHose, "012", ref status));
        }
Ejemplo n.º 7
0
        public void GetPumpsState_PumpList_ReturnsPumpStateForEachPump()
        {
            var status = string.Empty;
            _mockIO.Setup(c => c.SendAndReceive(WayneCommands.GetPumpsState, string.Empty, ref status))
                .Callback(() => status = "00")
                .Returns("0000070001");
            var forecourt = new Wayne(_mockIO.Object);
            var pump1 = new Pump(1);
            var pump2 = new Pump(2);
            var pumpList = new List<Pump>() { pump1, pump2 };

            var dic = forecourt.GetPumpsState(pumpList);
            forecourt.Dispose();

            status.Should().Be("00");
            dic[pump1].Should().Be(PumpState.Delivering);
            dic[pump2].Should().Be(PumpState.Free);
        }