public void WhenDoorsOpenAndSummonsAtSameLevelAndDirection_ThenStayOpen() { var lift = new Lift { Level = 1, State = LiftState.DoorsOpen, Direction = Direction.Up }; var summons = new List <Summon>() { new Summon(1, Direction.Up, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.OpenDoors); }
public void WhenStoppedDirectionDownAndSummonsBelow_ThenTravelDown() { var lift = new Lift { Level = 5, State = LiftState.Stopped, Direction = Direction.Down }; var summons = new List <Summon>() { new Summon(2, Direction.Up, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.TravelDown); }
public void WhenDoorsOpenAndPassengerAtDesiredLevel_ThenStayOpen() { var lift = new Lift { Level = 1, State = LiftState.DoorsOpen, Passengers = new List <Passenger>() { new Passenger(1) } }; var summons = new List <Summon>(); var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.OpenDoors); }
public void WhenStoppedDirectionUpAndSummonsAbove_ThenTravelUp() { var lift = new Lift { Level = 1, State = LiftState.Stopped, Direction = Direction.Up }; var summons = new List <Summon>() { new Summon(2, Direction.Down, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.TravelUp); }
public void WhenStoppedAndDirectionDownAndNoPassengersAndNoSummonsBelowAndSummonOnLevel_ThenOpenDoors() { var lift = new Lift { Level = 5, State = LiftState.Stopped, Direction = Direction.Down }; var summons = new List <Summon>() { new Summon(5, Direction.Up, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.OpenDoors); }
public void WhenStoppedAndSummonsAtSameLevelWithOppositeDirectionAndSummonsInSameDirection_ThenDontOpen() { var lift = new Lift { Level = 1, State = LiftState.Stopped, Direction = Direction.Up }; var summons = new List <Summon>() { new Summon(1, Direction.Down, new List <Passenger>()), new Summon(2, Direction.Down, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.False(nextInstruction == Instruction.OpenDoors); }
public void WhenMovingAndSummonAtLevelWithOppositeDirectionAndNoOtherSummonsOrPassengers_ThenStop() { var lift = new Lift { Level = 5, State = LiftState.Moving, Direction = Direction.Down, Passengers = new List <Passenger>() }; var summons = new List <Summon>() { new Summon(5, Direction.Up, new List <Passenger>()) }; var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.Stop); }
public void WhenMovingAndPassengerAtDesiredLevel_ThenStop() { var lift = new Lift { Level = 1, State = LiftState.Moving, Direction = Direction.Up, Passengers = new List <Passenger>() { new Passenger(1) } }; var summons = new List <Summon>(); var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.Stop); }
public void WhenStoppedAndDirectionDownAndPassengersDesiredLevelBelow_ThenTravelDown() { var lift = new Lift { Level = 5, State = LiftState.Stopped, Direction = Direction.Down, Passengers = new List <Passenger>() { new Passenger(2) } }; var summons = new List <Summon>(); var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.TravelDown); }
public void WhenStoppedDirectionUpAndPassengersDesiredLevelAbove_ThenTravelUp() { var lift = new Lift { Level = 1, State = LiftState.Stopped, Direction = Direction.Up, Passengers = new List <Passenger>() { new Passenger(4) } }; var summons = new List <Summon>(); var nextInstruction = LiftService.CalculateNextInstruction(lift, summons); Assert.True(nextInstruction == Instruction.TravelUp); }