Beispiel #1
0
        public void GenerateRangeTest()
        {
            string seedName    = nameof(NumberGeneratorTests);
            string prefix      = "PRE";
            string timeFormat  = "yyyyMMdd";
            int    length      = 3;
            string description = "描述";
            int    count       = 10;

            //生成序列号
            NumberGenerator generator = new NumberGenerator();

            string[] serialNos = generator.GenerateRange(seedName, prefix, timeFormat, length, description, count);

            //预期序列号
            StringBuilder keyBuilder = new StringBuilder();

            keyBuilder.Append(prefix);
            keyBuilder.Append(DateTime.Now.ToString(timeFormat));
            string patialKey = keyBuilder.ToString();

            //断言
            Assert.IsTrue(serialNos.All(serialNo => serialNo.Contains(patialKey)));
            Assert.AreEqual(serialNos.Length, count);
        }