public void GIVEN_dispense_ticket_number_10_WHEN_dispense_a_new_ticket_THEN_the_new_ticket_is_number_11() { TestingTicketDispenser testingTicketDispenser = new TestingTicketDispenser(); TurnTicket ticket = testingTicketDispenser.GetTurnTicket(); Assert.AreEqual(11, ticket.TurnNumber); }
public TurnTicket GetTurnTicket() { int newTurnNumber = _turnNumberSequence.GetNextTurnNumber(); var newTurnTicket = new TurnTicket(newTurnNumber); return(newTurnTicket); }
// A class with the only goal of simulating dependencies on // TurnTicket and TurnNumberSequence that have impact on the refactoring. public TurnTicketAndSequenceClient() { var globalSequence = TurnNumberSequence.GlobalTurnNumberSequence; var turnTicket1 = new TurnTicket(globalSequence.GetNextTurnNumber()); var turnTicket2 = new TurnTicket(globalSequence.GetNextTurnNumber()); var turnTicket3 = new TurnTicket(globalSequence.GetNextTurnNumber()); }
/// <summary> /// This ends the turn for the given turnTicket /// </summary> /// <param name="ticket">Ticket to take turn from</param> private void TakeTurnAwayFromTicket(TurnTicket ticket) { if (TurnEndedEvent != null) { TurnEndedEvent(ticket.TicketId); } }
public TurnTicket GetTurnTicket() { int newTurnNumber = turnNumberSequence.GetNextTurnNumber(); var newTurnTicket = new TurnTicket(newTurnNumber); return newTurnTicket; }
/// <summary> /// This gives turn to given ticket. /// </summary> /// <param name="ticket">Ticket to give turn to</param> private void GiveTicketTurn(TurnTicket ticket) { if (TurnStartedEvent != null) { TurnStartedEvent(ticket.TicketId); } }
public void GIVEN_dispense_a_ticket_WHEN_dispense_a_new_ticket_at_the_same_machine_THEN_turn_number_of_the_new_ticket_is_greater() { TicketDispenser ticketDispenser = new TicketDispenser(); TurnTicket oldTicket = ticketDispenser.GetTurnTicket(); TurnTicket newTicket = ticketDispenser.GetTurnTicket(); Assert.Greater(newTicket.TurnNumber, oldTicket.TurnNumber); }
public virtual TurnTicket GetTurnTicket() { TurnNumberSequence turnNumberSequence = new TurnNumberSequence(); int newTurnNumber = turnNumberSequence.GetNextTurnNumber(); var newTurnTicket = new TurnTicket(newTurnNumber); return(newTurnTicket); }
public void turnTicketDispenser_should_samedispenser_send_a_ticker_with_greater_number_than_previous_ticket() { TicketDispenser ticketDispenser = new TicketDispenser(); TurnTicket ticket = ticketDispenser.GetTurnTicket(); TurnTicket ticket2 = ticketDispenser.GetTurnTicket(); Assert.Greater(ticket2.TurnNumber, ticket.TurnNumber); }
/// <summary> /// The sorting algoritm for the priorityLevel in each turnTicket. /// The higher the priorityLevel, the earlier in the list it gets placed. /// </summary> /// <param name="x">fist tested turnTicket</param> /// <param name="y">Second tested turnTicket</param> /// <returns></returns> private int PrioritySort(TurnTicket x, TurnTicket y) { if (x.PriorityLevel > y.PriorityLevel) { return(1); } return(-1); }
public void A_new_ticket_must_have_the_turn_number_subsequent_to_the_previous_ticket() { TicketDispenser ticketDispenser = new TicketDispenser(); TurnTicket previousTicket = ticketDispenser.GetTurnTicket(); TurnTicket newTicket = ticketDispenser.GetTurnTicket(); Assert.Greater(newTicket.TurnNumber, previousTicket.TurnNumber, "turn number"); }
public void A_new_ticket_must_have_the_turn_number_subsequent_to_the_previous_ticket_from_another_dispencer() { TicketDispenser firstTicketDispenser = new TicketDispenser(); TurnTicket previousTicket = firstTicketDispenser.GetTurnTicket(); TicketDispenser secondTicketDispenser = new TicketDispenser(); TurnTicket newTicket = secondTicketDispenser.GetTurnTicket(); Assert.Greater(newTicket.TurnNumber, previousTicket.TurnNumber, "turn number"); }
// A class with the only goal of simulating a dependency on TurnTicket // that has impact on the refactoring. public TurnTicketClient() { var turnTicket1 = new TurnTicket(1); var turnTicket2 = new TurnTicket(2); var turnTicket3 = new TurnTicket(3); var num1 = turnTicket1.TurnNumber; var num2 = turnTicket2.TurnNumber; var num3 = turnTicket3.TurnNumber; }
public void A_new_ticket_should_have_the_turn_number_subsequent_to_the_previous_ticket() { // Arrange var ticketDispenser = new TicketDispenser(); TurnTicket previouseTicket = ticketDispenser.GetTurnTicket(); // Act TurnTicket newTicket = ticketDispenser.GetTurnTicket(); // Assert Assert.AreEqual(1, newTicket.TurnNumber - previouseTicket.TurnNumber); }
public void After_ticket_10_come_ticket_11() { MockTurnNumberSequence mockTurnNumberSequence = new MockTurnNumberSequence(); mockTurnNumberSequence.SetExpectedGetNextTurnNumber(11); TicketDispenser ticketDispenser = new TicketDispenser(mockTurnNumberSequence); TurnTicket newTicket = ticketDispenser.GetTurnTicket(); Assert.AreEqual(11, newTicket.TurnNumber, "turn number"); mockTurnNumberSequence.Verify(); }
public void The_turn_number_sequence_of_the_vip_customers_starts_from_1001() { // Arrange TurnNumberSequence vipCustomerTurnNumberSequence = new TurnNumberSequence(TurnNumberSequence.VIPCustomerFirstNumber); TicketDispenser ticketDispenser = new TicketDispenser(vipCustomerTurnNumberSequence); // Act TurnTicket ticket = ticketDispenser.GetTurnTicket(); // Assert Assert.AreEqual(TurnNumberSequence.VIPCustomerFirstNumber, ticket.TurnNumber); }
public void The_turn_number_sequence_of_the_regular_customers_starts_from_2001() { // Arrange TurnNumberSequence regularCustomerTurnNumberSequence = new TurnNumberSequence(2001); TicketDispenser ticketDispenser = new TicketDispenser(regularCustomerTurnNumberSequence); // Act TurnTicket ticket = ticketDispenser.GetTurnTicket(); // Assert Assert.AreEqual(TurnNumberSequence.RegularCustomerFirstNumber, ticket.TurnNumber); }
/// <summary> /// Set the priorityLevel of tickets. The higher the priorityLevel, the sooner the ticket gets its turn in the sorting algoritm. /// </summary> /// <param name="ticket">Ticket to change priorityLevel of</param> /// <param name="priorityLevel">The level to assign it</param> public void SetPriorityLevelOfTicket(int ticket, int priorityLevel) { TurnTicket tt = GetTicketWithId(ticket); if (tt != null) { tt.SetPriorityLevel(priorityLevel); } else { Debug.LogWarning("No ticket found with id: " + ticket.ToString()); } }
public override TurnTicket GetTurnTicket() { var turnNumberSequence = new Mock<TurnNumberSequence>(); turnNumberSequence .Setup(t => t.GetNextTurnNumber()) .Returns(11); int newTurnNumber = turnNumberSequence.Object.GetNextTurnNumber(); var newTurnTicket = new TurnTicket(newTurnNumber); turnNumberSequence.Verify(t => t.GetNextTurnNumber()); return newTurnTicket; }
public override TurnTicket GetTurnTicket() { var turnNumberSequence = new Mock <TurnNumberSequence>(); turnNumberSequence .Setup(t => t.GetNextTurnNumber()) .Returns(11); int newTurnNumber = turnNumberSequence.Object.GetNextTurnNumber(); var newTurnTicket = new TurnTicket(newTurnNumber); turnNumberSequence.Verify(t => t.GetNextTurnNumber()); return(newTurnTicket); }
public void The_ticket_dispenser_should_dispense_the_ticket_number_11_if_give_a_turn_number_11_to_it() { // Arrange MockTurnNumberSequence mockTurnNumberSequence = new MockTurnNumberSequence(); mockTurnNumberSequence.ArrangeNextTurnNumber(11); TicketDispenser ticketDispenser = new TicketDispenser(mockTurnNumberSequence); // Act TurnTicket ticket = ticketDispenser.GetTurnTicket(); // Assert Assert.AreEqual(11, ticket.TurnNumber); mockTurnNumberSequence.VerifyMethodGetNextTurnNumberCalledOnce(); }
public void TestLegacyTickeTispensers() { MockRepository mocks = new MockRepository(); ITurnNumberSequence sequence = mocks.StrictMock<ITurnNumberSequence>(); Expect.Call(sequence.GetNextNumber()).Return(0); Expect.Call(sequence.GetNextNumber()).Return(1); TurnNumberSequence.Instance=sequence; mocks.ReplayAll(); LegacyTicketDispenser ticketDispenser = new LegacyTicketDispenser(); TurnTicket first = new TurnTicket(0); TurnTicket second = new TurnTicket(1); Assert.AreEqual(first,ticketDispenser.GetTurnTicket()); Assert.AreEqual(second,ticketDispenser.GetTurnTicket()); mocks.VerifyAll(); }
public void ShuldBeableToUseConsistentlyLegacyAndNonLegacyDispenserUsingSameSequence() { MockRepository mocks = new MockRepository(); ITurnNumberSequence sequence = mocks.StrictMock<ITurnNumberSequence>(); Expect.Call(sequence.GetNextNumber()).Return(0); Expect.Call(sequence.GetNextNumber()).Return(1); TurnNumberSequence.Instance=sequence; mocks.ReplayAll(); LegacyTicketDispenser legacyticketDispenser = new LegacyTicketDispenser(); TicketDispenser ticketDispenser = new TicketDispenser(TurnNumberSequence.Instance); TurnTicket first = new TurnTicket(0); TurnTicket second = new TurnTicket(1); Assert.AreEqual(first,ticketDispenser.GetTurnTicket()); Assert.AreEqual(second,legacyticketDispenser.GetTurnTicket()); mocks.VerifyAll(); }
// A class with the only goal of simulating a dependencies on // TurnNumberSequence and TurnTicket that have impact on the refactoring. public TurnTicketAndSequenceClient() { var turnTicket1 = new TurnTicket(TurnNumberSequence.GetNextTurnNumber()); var turnTicket2 = new TurnTicket(TurnNumberSequence.GetNextTurnNumber()); var turnTicket3 = new TurnTicket(TurnNumberSequence.GetNextTurnNumber()); }
/// <summary> /// This method returns the priorityLevel of the requested ticket. /// </summary> /// <param name="ticket">Ticket to know the PriorityLevel of</param> /// <returns></returns> public int GetPriorityLevelOfTicket(int ticket) { TurnTicket tt = GetTicketWithId(ticket); return((tt != null) ? tt.PriorityLevel : -1); }
public void TestTicketDispenserHighNumbers() { MockRepository mocks = new MockRepository(); ITurnNumberSequence sequence = mocks.StrictMock<ITurnNumberSequence>(); Expect.Call(sequence.GetNextNumber()).Return(999999); Expect.Call(sequence.GetNextNumber()).Return(1000000); mocks.ReplayAll(); TicketDispenser ticketDispenser = new TicketDispenser(sequence); TurnTicket first = new TurnTicket(999999); TurnTicket second = new TurnTicket(1000000); Assert.AreEqual(first,ticketDispenser.GetTurnTicket()); Assert.AreEqual(second,ticketDispenser.GetTurnTicket()); mocks.VerifyAll(); }