示例#1
0
        public void ParkingMeter_IsExpiredTimeWhenQuarterIsNotAdded_ReturnsTrue()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            bool isExpired = parkingMeter.IsExpired();

            Assert.That(isExpired, Is.True);
        }
        public void ParkingMeter_CanNotAddQuarterWhenTillIsFull_ReturnsFalse()
        {
            ParkingMeter parkingMeter = new ParkingMeter(dateTimeProvider, CreateFakeFullMeterTill().Object);

            bool badAdd = parkingMeter.AddQuarter();

            Assert.That(badAdd, Is.False);
        }
示例#3
0
        public void ParkingMeter_GetTillValueWhenEmpty_ReturnsZero()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            int value = parkingMeter.GetTillValue();

            Assert.That(value, Is.Zero);
        }
示例#4
0
        public void ParkingMeter_CanAddQuarterWhenTillNotFull_ReturnsTrue()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            bool isAdded = parkingMeter.AddQuarter();

            Assert.That(isAdded, Is.True);
        }
示例#5
0
        public void ParkingMeter_GetRemainingTimeWhenQuarterIsNotAdded_IsZero()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            double remainingTime = parkingMeter.GetRemainingTime();

            Assert.That(remainingTime, Is.Zero);
        }
        public void ParkingMeter_CanAddQuarterWhenTillNotFull_ReturnsTrue()
        {
            ParkingMeter parkingMeter = new ParkingMeter(dateTimeProvider, CreateFakeEmptyMeterTill().Object);

            bool isAdded = parkingMeter.AddQuarter();

            Assert.That(isAdded, Is.True);
        }
示例#7
0
        public void ParkingMeter_GetTillValueWhenOneQuarter_ReturnsOne()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            parkingMeter.AddQuarter();
            int value = parkingMeter.GetTillValue();

            Assert.That(value, Is.EqualTo(1));
        }
示例#8
0
        public void ParkingMeter_IsExpiredTimeWhenQuarterIsAdded_ReturnsFalse()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            parkingMeter.AddQuarter();
            bool isExpired = parkingMeter.IsExpired();

            Assert.That(isExpired, Is.False);
        }
示例#9
0
        public void ParkingMeter_GetRemainingTimeWhenQuarterIsAdded_IsGreaterThanZero()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            parkingMeter.AddQuarter();
            double remainingTime = parkingMeter.GetRemainingTime();

            Assert.That(remainingTime, Is.GreaterThan(0));
        }
示例#10
0
        public void Run()
        {
            ParkingMeter meter    = new ParkingMeter(new WeekdayRate());
            Ticket       myticket = meter.InsertCoins(10);

            // time passes, now it is sunday
            meter.RateCalculator = new WeekendRate();

            Ticket myweekendticket = meter.InsertCoins(20);
        }
示例#11
0
        public void ParkingMeter_GetRemainingTimeWhenTimeExpires_IsZero()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            parkingMeter.AddQuarter();

            //THIS TEST HAS TO WAIT 15 MINUTES?  IMPOSSIBLE TO RUN
            double remainingTime = parkingMeter.GetRemainingTime();

            Assert.That(remainingTime, Is.Zero);
        }
示例#12
0
        public void ParkingMeter_IsExpiredTimeWhenTimeExpires_ReturnsTrue()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            parkingMeter.AddQuarter();

            //THIS TEST HAS TO WAIT 15 MINUTES?  IMPOSSIBLE TO RUN
            bool isExpired = parkingMeter.IsExpired();

            Assert.That(isExpired, Is.True);
        }
        private FormattedString SetLabelMeterDetails(ParkingMeter meter)
        {
            FormattedString fs = new FormattedString();

            fs.Spans.Add(new Span {
                Text = "Meter ID: ", FontAttributes = FontAttributes.Bold, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.METER_NO + "\n", FontSize = 20
            });

            fs.Spans.Add(new Span {
                Text = "Location: ", FontAttributes = FontAttributes.Bold, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.STREET + ", " + meter.SUBURB + "\n", FontSize = 20
            });

            fs.Spans.Add(new Span {
                Text = "Bays available: ", FontAttributes = FontAttributes.Bold, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.VEH_BAYS, FontAttributes = FontAttributes.Italic, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = " car bays & ", FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.MC_BAYS, FontAttributes = FontAttributes.Italic, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = " motorcycle bays. \n", FontSize = 20
            });

            fs.Spans.Add(new Span {
                Text = "Maximum Stay: ", FontAttributes = FontAttributes.Bold, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.MAX_STAY_HRS, FontAttributes = FontAttributes.Italic, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = " hours, and it costs $", FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = meter.TAR_RATE_WEEKDAY, FontAttributes = FontAttributes.Italic, FontSize = 20
            });
            fs.Spans.Add(new Span {
                Text = " per hour to park here.", FontSize = 20
            });

            return(fs);
        }
示例#14
0
        public void ParkingMeter_EmptyTill_TillValueIsZero(int addCount)
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            for (int x = 0; x < addCount; x++)
            {
                parkingMeter.AddQuarter();
            }
            parkingMeter.EmptyTill();
            int tillValue = parkingMeter.GetTillValue();

            Assert.That(tillValue, Is.Zero);
        }
示例#15
0
        public void ParkingMeter_NewTillIsNotFull_ReturnsFalse(int addCount, bool isFull)
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            for (int x = 0; x < addCount; x++)
            {
                parkingMeter.AddQuarter();
            }

            bool isEmpty = parkingMeter.IsTillFull();

            Assert.That(isEmpty, Is.EqualTo(isFull));
        }
示例#16
0
        public void ParkingMeter_GetTillValue_MatchesTestCase(int addCount, int tillValue)
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            for (int x = 0; x < addCount; x++)
            {
                parkingMeter.AddQuarter();
            }

            int value = parkingMeter.GetTillValue();

            Assert.That(value, Is.EqualTo(tillValue));
        }
 public void GetDataValidQueryTest()
 {
     try
     {
         ParkingMeter meter = APIDataStore.GetData("5601");
         Assert.IsNotNull(meter);
         Assert.AreEqual("5601", meter.METER_NO);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
示例#18
0
        public void ParkingMeter_CanNotAddQuarterWhenTillIsFull_ReturnsFalse()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            //add unitl the till is full, these should all succeed
            bool goodAdd = true;

            for (int addCount = 0; addCount < parkingMeter.GetTillCapacity(); addCount++)
            {
                goodAdd = goodAdd & parkingMeter.AddQuarter();
            }

            //the till should be full, this should now overflow the till and return false
            bool badAdd = parkingMeter.AddQuarter();

            Assert.Multiple(() =>
            {
                Assert.That(goodAdd, Is.True);
                Assert.That(badAdd, Is.False);
            });
        }
        public PostScanPage(Result result)
        {
            meter = APIDataStore.GetData(result.Text);

            FormattedString fs         = new FormattedString();
            bool            btnEnabled = true;

            if (meter.METER_NO != null)
            {
                fs = SetLabelMeterDetails(meter);
            }
            else
            {
                btnEnabled = false;
                fs.Spans.Add(new Span {
                    Text = "We were unable to retrieve\nthe data for this meter.\nPlease try again later.", FontSize = 20
                });
            }

            InitializeComponent();
            labelDetails.FormattedText = fs;
            btnStart.IsVisible         = btnEnabled;
            btnStart.IsEnabled         = btnEnabled;
        }
示例#20
0
        public void TestParkingMeterInitEmpty()
        {
            ParkingMeter meter = new ParkingMeter();

            Assert.IsNotNull(meter);
        }
 public void GetDataInvalidQueryTest()
 {
     ParkingMeter meter = APIDataStore.GetData("4000");
 }
示例#22
0
        public void ParkingMeter_TillCapacity_ReturnsTwenty()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            Assert.That(parkingMeter.GetTillCapacity(), Is.EqualTo(20));
        }
示例#23
0
        public void ParkingMeter_CanInitialize_ReturnsValidObject()
        {
            ParkingMeter parkingMeter = new ParkingMeter();

            Assert.That(parkingMeter, Is.Not.Null);
        }
        public void ParkingMeter_CanInitialize_ReturnsValidObject()
        {
            ParkingMeter parkingMeter = new ParkingMeter(dateTimeProvider, meterTill);

            Assert.That(parkingMeter, Is.Not.Null);
        }