Пример #1
0
        public void TestRandomInvalid_ReplaceNewGuid_GuidGenerater(int count, int repeat)
        {
            // GUID generator for source data
            var srcGuidGenerator = new GuidGenerater();

            TestGuidByRandomInvalidFormat(count, repeat, TestMethod.ReplaceNewGuid, srcGuidGenerator.NewGuid);
        }
Пример #2
0
        /// <summary>
        /// utility function for ReplaceSameGuidToSameGuid
        /// </summary>
        /// <param name="count">loop count</param>
        /// <param name="repeat">repeat count</param>
        /// <param name="testMethod">test method</param>
        /// <param name="newSrcGuid">delegate for creating new source GUIDs</param>
        public void TestGuidByRandomInvalidFormat(int count, int repeat, TestMethod testMethod, ReplaceWithNewGuid.NewGuid newSrcGuid)
        {
            var builderInput = new StringBuilder();

            Array values = Enum.GetValues(typeof(InvalidFormat));
            var   random = new Random();

            // GUID generator for dest data
            var dstGuidGenerator = new GuidGenerater();

            // create source data
            for (int i = 0; i < count; i++)
            {
                // choose enum 'Format' randomly
                var format = (InvalidFormat)values.GetValue(random.Next(values.Length));

                var separator = string.Format("------ {0} ------", i);
#if PRINTF_DEBUG
                Console.WriteLine(i.ToString() + ": " + format.ToString());
#endif // PRINTF_DEBUG

                var srcGuid = newSrcGuid();
                var dstGuid = dstGuidGenerator.NewGuid();

                InvalidFormatGuid formatGuid = delegate(StringBuilder builder, Guid guid, InvalidFormat destFormat)
                {
                    builder.Append(separator);
                    builder.Append(Environment.NewLine);
                    builder.Append(FormatGuidString(guid, destFormat));
                    builder.Append(Environment.NewLine);
                    builder.Append(Environment.NewLine);
                };

                for (int j = 0; j < repeat; j++)
                {
                    // create input data
                    formatGuid(builderInput, srcGuid, format);
                }
            }

            var input = builderInput.ToString();

            var replaceWithGuid = new ReplaceWithNewGuid(this.guidGenerator.NewGuid);
            var output          = CallMethodOfReplaceWithNewGuid(replaceWithGuid, testMethod, input);

#if PRINTF_DEBUG
            Console.WriteLine("input: ");
            Console.WriteLine(input);

            Console.WriteLine("output: ");
            Console.WriteLine(output);
#endif // PRINTF_DEBUG

            Assert.That(output, Is.EqualTo(input));
        }
Пример #3
0
 public void TearDown()
 {
     this.guidGenerator = null;
 }
Пример #4
0
 public void SetUp()
 {
     this.guidGenerator = new GuidGenerater();
 }