private ILuckyTicketCounterAlgorithm[] GetTicketCounters(string[] args) { if (args == null) { return(null); } Queue <ILuckyTicketCounterAlgorithm> counters = new Queue <ILuckyTicketCounterAlgorithm>(); for (int i = 0; i < args.Length; i++) { ILuckyTicketCounterAlgorithm algorithm = null; if (args[i] == PITER_ALGORITHM) { algorithm = new PiterAlgorithm(); } if (args[i] == MOSKOW_ALGORITHM) { algorithm = new MoskowAlgorithm(); } if (algorithm != null) { counters.Enqueue(algorithm); } } return(counters.ToArray <ILuckyTicketCounterAlgorithm>()); }
public void Insert_WrongString_EnmptyAlgorithmContainerExpected() { //arrange ILuckyTicketCounterAlgorithm[] current; ILuckyTicketCounterAlgorithm[] expected = new ILuckyTicketCounterAlgorithm[] { }; string algorithmName = "algorithm"; //Act current = validator.GetAlgorythmType(algorithmName); //Assert CollectionAssert.AreEqual(expected, current); }
public void Insert_oneString_PiterAndMoskowAlgorythmsExpected() { //arrange ILuckyTicketCounterAlgorithm[] actual; ILuckyTicketCounterAlgorithm[] expected = new ILuckyTicketCounterAlgorithm[] { new MoskowAlgorithm(), new PiterAlgorithm() }; string algorithmName = "piterADS moskow"; //Act actual = validator.GetAlgorythmType(algorithmName); //Assert CollectionAssert.AreEqual(expected, actual, arrComparer); }
public int Compare(object x, object y) { ILuckyTicketCounterAlgorithm algorithm1 = x as ILuckyTicketCounterAlgorithm; ILuckyTicketCounterAlgorithm algorithm2 = y as ILuckyTicketCounterAlgorithm; if (algorithm1 == null || algorithm2 == null) { throw new ArgumentException(); } if (algorithm1.GetType() == algorithm2.GetType()) { return(0); } else { return(-1); } }
public TicketCounter(ILuckyTicketCounterAlgorithm algorithm) { _algorithm = algorithm; }