public void FullDockingStation()
        {
            var            bike           = Mock.Of <Bike>();
            var            bike2          = Mock.Of <Bike>();
            DockingStation dockingstation = new DockingStation(1);

            dockingstation.DockBike(bike);
            dockingstation.DockBike(bike2);
        }
Ejemplo n.º 2
0
        public void DockingStation_DockBike_ShouldThrowException_WhennTheBikeIsNotValid()
        {
            var dockingStation = new DockingStation(1);

            Assert.Throws <Exception>(() => dockingStation.DockBike(null, 0));

            Action action = () => dockingStation.DockBike(null, 0);

            action.Should().Throw <Exception>().WithMessage("Null is not a valid bike");
        }
Ejemplo n.º 3
0
        public void DockBike_ShouldRaiseException_WhenMax10BikesDocked()
        {
            var dockingStation = new DockingStation(10);

            for (var i = 0; i < 10; i++)
            {
                dockingStation.DockBike(new Bike());
            }
            Assert.Throws <Exception>(() => dockingStation.DockBike(new Bike()));
        }
Ejemplo n.º 4
0
        public void DockingStation_DockBike_ShouldThrowException_WhenThereIsNoSpaceInTheDockingStation()
        {
            var bike           = new Bike();
            var dockingStation = new DockingStation(0);

            Assert.Throws <Exception>(() => dockingStation.DockBike(bike, 0));

            Action action = () => dockingStation.DockBike(bike, 0);

            action.Should().Throw <Exception>().WithMessage("No space exists");
        }
Ejemplo n.º 5
0
        public void DockingStation_DockBike_ShouldThrowException_WhenThereAlreadyABikeParkedInTheLocation()
        {
            var bike1          = new Bike();
            var bike2          = new Bike();
            var dockingStation = new DockingStation(1);

            dockingStation.DockBike(bike1, 0);

            Assert.Throws <Exception>(() => dockingStation.DockBike(bike2, 0));

            Action action = () => dockingStation.DockBike(bike2, 0);

            action.Should().Throw <Exception>().WithMessage("Space is taken. MUPPET!");
        }
Ejemplo n.º 6
0
        public void ReleaseBike_ShouldReturnWorkingBike_WhenIsWorkingCalled()
        {
            var dockingStation = new DockingStation();
            var bike           = new Bike();

            dockingStation.DockBike(bike);
            Assert.IsTrue(dockingStation.ReleaseBike().IsWorking());
        }
Ejemplo n.º 7
0
        public void ReleaseBike_ShouldReturnFakeBike_WhenCalled()
        {
            var dockingStation = new DockingStation();
            var Fakebike       = new Mock <Bike>();

            dockingStation.DockBike(Fakebike.Object);
            Assert.IsInstanceOf(typeof(Bike), dockingStation.ReleaseBike());
        }
Ejemplo n.º 8
0
        public void ReleaseBike_ShouldReturnBike_WhenCalled()
        {
            var dockingStation = new DockingStation();
            var bike           = new Bike();

            dockingStation.DockBike(bike);
            Assert.IsInstanceOf(typeof(Bike), dockingStation.ReleaseBike());
        }
        public void CanDockBike()
        {
            var            bike           = Mock.Of <Bike>();
            DockingStation dockingstation = new DockingStation();

            dockingstation.DockBike(bike);
            Assert.AreEqual(1, dockingstation.GetDockedBikes().Count);
        }
        public void EmptyDockingStation2()
        {
            var            bike           = Mock.Of <Bike>();
            DockingStation dockingstation = new DockingStation();

            dockingstation.DockBike(bike);
            dockingstation.ReleaseBike();
            dockingstation.ReleaseBike();
        }
Ejemplo n.º 11
0
        public void DockBike_ShouldPass_WhenMax10BikesFor9Docked()
        {
            var dockingStation = new DockingStation(10);

            for (var i = 0; i < 9; i++)
            {
                dockingStation.DockBike(new Bike());
            }
            Assert.AreEqual(9, dockingStation.bikeDock.Count);
        }
Ejemplo n.º 12
0
        public void ReleaseBike_ShouldRaiseException_WhenBikeIsBroken()
        {
            var dockingStation = new DockingStation(10);
            var bike           = new Bike();

            bike.IsBroken();
            dockingStation.DockBike(bike);

            Assert.Throws <Exception>(() => dockingStation.ReleaseBike());
        }
        public void BrokenBike()
        {
            Mock <Bike> bike = new Mock <Bike>();

            bike.Setup(x => x.GetCondition()).Returns("Broken");
            DockingStation dockingstation = new DockingStation();

            dockingstation.DockBike(bike.Object);
            dockingstation.ReleaseBike();
        }
Ejemplo n.º 14
0
        public void DockingStation_DockBike_ShouldAddABikeToTheBikeStore()
        {
            var bike           = new Bike();
            var dockingStation = new DockingStation(5);

            dockingStation.DockBike(bike, 0);

            Assert.Equal(dockingStation.BikeStore[0], bike);

            dockingStation.BikeStore[0].Should().Equals(bike);
        }
Ejemplo n.º 15
0
        public void VanPickUp_PickupBrokenBikes_AddToVanDock()
        {
            var brokenBike = new Bike();

            brokenBike.IsBroken();
            var dockingStation = new DockingStation();

            dockingStation.DockBike(brokenBike);
            var van = new Van();

            van.PickupBikeForRepair(dockingStation);
            Assert.AreEqual(1, van.bikeDock.Count);
        }
Ejemplo n.º 16
0
        public void VanReleaseBrokenBike_ReleaseBrokenBikes_RemoveFromVanDock()
        {
            var brokenBike = new Bike();

            brokenBike.IsBroken();
            var dockingStation = new DockingStation();

            dockingStation.DockBike(brokenBike);
            var van = new Van();

            van.PickupBikeForRepair(dockingStation);
            Assert.IsInstanceOf(typeof(Bike), van.ReleaseBikeForRepair());
        }
Ejemplo n.º 17
0
        public void TakeBikeForRepair_AcceptsBrokenBike_FRomVan()
        {
            var brokenBike = new Bike();

            brokenBike.IsBroken();
            var dockingStation = new DockingStation();

            dockingStation.DockBike(brokenBike);
            var van = new Van();

            van.PickupBikeForRepair(dockingStation);
            var garage = new Garage();

            garage.TakeBikeForRepair(van);
            Assert.IsInstanceOf(typeof(Bike), garage.bikeDock[garage.bikeDock.Count - 1]);
        }
Ejemplo n.º 18
0
        public void RepairBikes_ShouldChangeBrokenStatusOnBikesToFalse_WhenRepaired()
        {
            var brokenBike = new Bike();

            brokenBike.IsBroken();
            var dockingStation = new DockingStation();

            dockingStation.DockBike(brokenBike);
            var van = new Van();

            van.PickupBikeForRepair(dockingStation);
            var garage = new Garage();

            garage.TakeBikeForRepair(van);
            garage.RepairBikes();
            Assert.IsTrue(garage.bikeDock[0].bikeStatus);
        }
Ejemplo n.º 19
0
        public void DockingStation_ReleaseBike_ShouldRemoveABikeToTheBikeStore()
        {
            var bike           = new Bike();
            var dockingStation = new DockingStation(5);

            dockingStation.DockBike(bike, 0);

            Assert.Equal(dockingStation.BikeStore[0], bike);

            var acquiredBike = dockingStation.ReleaseBike(0);

            Assert.Null(dockingStation.BikeStore[0]);
            Assert.Equal(bike, acquiredBike);

            dockingStation.BikeStore[0].Should().Equals(null);
            bike.Should().Equals(acquiredBike);
        }
Ejemplo n.º 20
0
        public void DockingStation_ReportBroken_ShouldChangeTheStateOfBikeWorkingToFalse()
        {
            var bike           = new Bike();
            var dockingStation = new DockingStation(1);

            dockingStation.DockBike(bike, 0);

            Assert.True(bike.Working);

            bike.Working.Should().Equals(true);

            dockingStation.ReportBroken(0);

            Assert.False(bike.Working);

            bike.Working.Should().Equals(false);
        }
Ejemplo n.º 21
0
        public void VanPicksUpRepairedBike_PicksUpRepairedBikes_RemoveRepairedBikeFromGarage()
        {
            var brokenBike = new Bike();

            brokenBike.IsBroken();
            var dockingStation = new DockingStation();

            dockingStation.DockBike(brokenBike);
            var van = new Van();

            van.PickupBikeForRepair(dockingStation);
            var garage = new Garage();

            garage.TakeBikeForRepair(van);
            garage.RepairBikes();
            van.PickupRepairedBike(garage);
            Assert.IsTrue(van.bikeDock[0].bikeStatus);
        }