public void NumberGenerator_OnAllowableLength_NumberReturned() { var generator = new NumberGenerator(); int value1 = generator.Generate(4); int value2 = generator.Generate(8); Assert.Equal(4, value1.ToString().Length); Assert.Equal(8, value2.ToString().Length); }
public void NullTest() { string seedName = nameof(NumberGeneratorTests); string prefix = null; string timeFormat = null; int length = 3; string description = null; //生成序列号 NumberGenerator generator = new NumberGenerator(); int count = 30; ICollection <string> keys = new HashSet <string>(); for (int index = 0; index < count; index++) { string serialNo = generator.Generate(seedName, prefix, timeFormat, length, description); keys.Add(serialNo); //断言 Assert.AreEqual(serialNo.Length, length); } Assert.AreEqual(count, keys.Count); }
public void NumberGenerator() { INumberGenerator numbergenerator = new NumberGenerator(); int testnumber = numbergenerator.Generate(random, 0, 1000); Assert.Between(testnumber, 0, 1000); }
public void NumberGeneratorWithIntOverride() { INumberGenerator numbergenerator = new NumberGenerator(); int testnumber = numbergenerator.Generate(random, 99); Assert.IsNotNull(testnumber); Assert.AreEqual(99, testnumber); }
public void DoRangeFizzBuzzTest() { string expected = "1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz Fizz 97 98 Fizz Buzz"; new FizzBuzzResolver() .PrintFizzBuzz( NumberGenerator.Generate(100) .Select(FizzBuzzInputFactory.Make)) .Should() .Be(expected); }
public void NumberGeneratorWithAttributeOverride() { INumberGenerator numbergenerator = new NumberGenerator(); AttributeMap attmap = new AttributeMap { DefaultInt = 99 }; int testnumber = numbergenerator.Generate(random, attmap); Assert.IsNotNull(testnumber); Assert.AreEqual(99, testnumber); }
public void NumberGeneratorWithAttributeRangeMap() { INumberGenerator numbergenerator = new NumberGenerator(); AttributeMap attmap = new AttributeMap { MinInt = 0, MaxInt = 100 }; int testnumber = numbergenerator.Generate(random, attmap); Assert.IsNotNull(testnumber); Assert.Between(testnumber, 0, 100); }
public void GenerateTinyUrlNumbers(int from, int to) { EveShoppingContext contexto = new EveShoppingContext(); NumberGenerator generator = new NumberGenerator(); IEnumerable <int> numbers = generator.Generate(from, to); foreach (var n in numbers) { } }
public GameResults Generate(int current) { var randomNumber = numberGenerator.Generate(); var correctResult = mathOperator.Apply(current, randomNumber); var correct = new GameResult(correctResult); var results = new List <GameResult> { correct }; for (var i = 0; i < quantity - 1; i++) { var incorrectResult = Random.Range(correctResult + 2, correctResult + 10); results.Add(new GameResult(incorrectResult)); } return(new GameResults(mathOperator, results, current, randomNumber)); }
static void Main(string[] args) { // Take dimentions from console and create base layer int[] dimentions = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); int[,] wall = NumberGenerator.Generate(dimentions[0], dimentions[1]); for (int row = 0; row < wall.GetLength(0); row++) { for (int coll = 0; coll < wall.GetLength(1); coll++) { Console.Write(wall[row, coll] + " "); } Console.WriteLine(); } }
public void GenerateTest() { string seedName = nameof(NumberGeneratorTests); string prefix = "PRE"; string timeFormat = "yyyyMMdd"; int length = 3; string description = "描述"; //生成序列号 NumberGenerator generator = new NumberGenerator(); string serialNo = generator.Generate(seedName, prefix, timeFormat, length, description); //预期序列号 StringBuilder keyBuilder = new StringBuilder(); keyBuilder.Append(prefix); keyBuilder.Append(DateTime.Now.ToString(timeFormat)); string patialKey = keyBuilder.ToString(); //断言 Assert.IsTrue(serialNo.Contains(patialKey)); Assert.AreEqual(serialNo.Length, patialKey.Length + length); }
static void Main(string[] args) { var generator = new NumberGenerator(); var boardManager = new BoardManager(generator, MATRIX_LENGTH); var board = boardManager.CreateBoard(); var stepCounter = 0; //count of steps for cheking winner var isGameFinished = false; ConsoleHelper.Title(); ConsoleHelper.RenderBoard(board); ConsoleHelper.Footer(); while (Console.ReadKey().Key != ConsoleKey.Escape && !isGameFinished) { stepCounter++; var nextNumber = generator.Generate(); //check number on the board boardManager.SelectNumberInBoard(board, nextNumber); ConsoleHelper.Header(nextNumber, stepCounter); ConsoleHelper.RenderBoard(board); //check winner if (stepCounter >= 5 && boardManager.IsBoardWon(board)) { isGameFinished = true; ConsoleHelper.WinnerMessage(); } else { ConsoleHelper.Footer(); } } }