public void RandomTest()
 {
     PriorityQueue<int> TestObject = new PriorityQueue<int>();
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     int Value=0;
     for (int x = 0; x < 10; ++x)
     {
         Value=Rand.Next();
         TestObject.Add(x, Value);
         Assert.Equal(Value, TestObject.Peek());
     }
     int HighestValue = TestObject.Peek();
     for (int x = 9; x >= 0; --x)
     {
         Value = Rand.Next();
         TestObject.Add(x, Value);
         Assert.Equal(HighestValue, TestObject.Peek());
     }
     int Count=0;
     foreach(int Priority in TestObject.Keys)
     {
         foreach(int Item in TestObject[Priority])
         {
             ++Count;
         }
     }
     Assert.Equal(20, Count);
 }
        public void RandomTest()
        {
            RingBuffer<int> TestObject = new RingBuffer<int>(10);
            Utilities.Random.Random Rand = new Utilities.Random.Random();
            int Value = 0;
            for (int x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(Value);
                Assert.Equal(1, TestObject.Count);
                Assert.Equal(Value, TestObject.Remove());
            }
            Assert.Equal(0, TestObject.Count);
            System.Collections.Generic.List<int> Values=new System.Collections.Generic.List<int>();
            for (int x = 0; x < 10; ++x)
            {
                Values.Add(Rand.Next());
            }
            TestObject.Add(Values);
            Assert.Equal(Values.ToArray(), TestObject.ToArray());

            for (int x = 0; x < 10; ++x)
            {
                Assert.Throws<IndexOutOfRangeException>(() => TestObject.Add(Rand.Next()));
                Assert.Equal(10, TestObject.Count);
            }
        }
Ejemplo n.º 3
0
        public void RandomTest()
        {
            RingBuffer <int> TestObject = new RingBuffer <int>(10);

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            int Value = 0;

            for (int x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(Value);
                Assert.Equal(1, TestObject.Count);
                Assert.Equal(Value, TestObject.Remove());
            }
            Assert.Equal(0, TestObject.Count);
            System.Collections.Generic.List <int> Values = new System.Collections.Generic.List <int>();
            for (int x = 0; x < 10; ++x)
            {
                Values.Add(Rand.Next());
            }
            TestObject.Add(Values);
            Assert.Equal(Values.ToArray(), TestObject.ToArray());

            for (int x = 0; x < 10; ++x)
            {
                Assert.Throws <IndexOutOfRangeException>(() => TestObject.Add(Rand.Next()));
                Assert.Equal(10, TestObject.Count);
            }
        }
        public void NextStringTest2()
        {
            var Rand = new Utilities.Random.Random();

            Assert.True(Regex.IsMatch(Rand.Next <string>(new PatternGenerator("(###)###-####")), @"\(\d{3}\)\d{3}-\d{4}"));
            Assert.True(Regex.IsMatch(Rand.Next <string>(new PatternGenerator("(@@@)###-####")), @"\([a-zA-Z]{3}\)\d{3}-\d{4}"));
        }
Ejemplo n.º 5
0
        public void RandomTest()
        {
            PriorityQueue <int> TestObject = new PriorityQueue <int>();

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            int Value = 0;

            for (int x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(x, Value);
                Assert.Equal(Value, TestObject.Peek());
            }
            int HighestValue = TestObject.Peek();

            for (int x = 9; x >= 0; --x)
            {
                Value = Rand.Next();
                TestObject.Add(x, Value);
                Assert.Equal(HighestValue, TestObject.Peek());
            }
            int Count = 0;

            foreach (int Priority in TestObject.Keys)
            {
                foreach (int Item in TestObject[Priority])
                {
                    ++Count;
                }
            }
            Assert.Equal(20, Count);
        }
Ejemplo n.º 6
0
        public static Bitmap AddNoise(Bitmap OriginalImage, int Amount)
        {
            Bitmap     NewBitmap    = new Bitmap(OriginalImage.Width, OriginalImage.Height);
            BitmapData NewData      = NewBitmap.LockImage();     //Image.LockImage(NewBitmap);
            BitmapData OldData      = OriginalImage.LockImage(); //Image.LockImage(OriginalImage);
            int        NewPixelSize = NewData.GetPixelSize();    //Image.GetPixelSize(NewData);
            int        OldPixelSize = OldData.GetPixelSize();    //Image.GetPixelSize(OldData);

            Utilities.Random.Random TempRandom = new Utilities.Random.Random();
            for (int x = 0; x < NewBitmap.Width; ++x)
            {
                for (int y = 0; y < NewBitmap.Height; ++y)
                {
                    Color CurrentPixel = OldData.GetPixel(x, y, OldPixelSize);//Image.GetPixel(OldData, x, y, OldPixelSize);
                    int   R            = CurrentPixel.R + TempRandom.Next(-Amount, Amount + 1);
                    int   G            = CurrentPixel.G + TempRandom.Next(-Amount, Amount + 1);
                    int   B            = CurrentPixel.B + TempRandom.Next(-Amount, Amount + 1);
                    R = R > 255 ? 255 : R;
                    R = R < 0 ? 0 : R;
                    G = G > 255 ? 255 : G;
                    G = G < 0 ? 0 : G;
                    B = B > 255 ? 255 : B;
                    B = B < 0 ? 0 : B;
                    Color TempValue = Color.FromArgb(R, G, B);
                    NewData.SetPixel(x, y, TempValue, NewPixelSize);//Image.SetPixel(NewData, x, y, TempValue, NewPixelSize);
                }
            }
            NewBitmap.UnlockImage(NewData);     //Image.UnlockImage(NewBitmap, NewData);
            OriginalImage.UnlockImage(OldData); //Image.UnlockImage(OriginalImage, OldData);
            return(NewBitmap);
        }
        public void NextName()
        {
            var Rand = new Utilities.Random.Random();

            Assert.Equal(3, Rand.Next <string>(new NameGenerator(false, true, true, false)).Split(' ').Length);
            Assert.Equal(2, Rand.Next <string>(new NameGenerator(false, false, true, false)).Split(' ').Length);
            Assert.Equal(4, Rand.Next <string>(new NameGenerator(true, true, true, false)).Split(' ').Length);
            Assert.Equal(5, Rand.Next <string>(new NameGenerator(true, true, true, true)).Split(' ').Length);
        }
        public void RegisterGenerator()
        {
            var Rand = new Utilities.Random.Random();

            Rand.RegisterGenerator <string>(new NameGenerator());
            Assert.True(100.Times(x => Rand.Next <string>()).All(x => x.Split(' ').Length == 2));
        }
Ejemplo n.º 9
0
        public void RandomTest()
        {
            Vector <int> TestObject = new Vector <int>();

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            int Value = 0;

            for (int x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(Value);
                Assert.Equal(Value, TestObject[x]);
            }
            int Count = 0;

            foreach (int Temp in TestObject)
            {
                ++Count;
            }
            Assert.Equal(10, Count);
            TestObject.Remove(TestObject[0]);
            Assert.Equal(9, TestObject.Count);
            TestObject.Clear();
            Assert.Equal(0, TestObject.Count);
        }
Ejemplo n.º 10
0
 public void RandomTest()
 {
     ListMapping<string, int> TestObject = new ListMapping<string, int>();
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     for (int x = 0; x < 10; ++x)
     {
         string Name = Rand.Next<string>(new RegexStringGenerator(10));
         for (int y = 0; y < 5; ++y)
         {
             int Value=Rand.Next();
             TestObject.Add(Name, Value);
             Assert.Equal(y + 1, TestObject[Name].Count);
             Assert.Equal(Value, TestObject[Name].ElementAt(y));
         }
     }
     Assert.Equal(10, TestObject.Count);
 }
Ejemplo n.º 11
0
        public void RandomTest()
        {
            ListMapping <string, int> TestObject = new ListMapping <string, int>();

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            for (int x = 0; x < 10; ++x)
            {
                string Name = Rand.Next <string>(new RegexStringGenerator(10));
                for (int y = 0; y < 5; ++y)
                {
                    int Value = Rand.Next();
                    TestObject.Add(Name, Value);
                    Assert.Equal(y + 1, TestObject[Name].Count);
                    Assert.Equal(Value, TestObject[Name][y]);
                }
            }
            Assert.Equal(10, TestObject.Count);
        }
Ejemplo n.º 12
0
 public void RandomTest()
 {
     Vector<int> TestObject = new Vector<int>();
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     int Value = 0;
     for (int x = 0; x < 10; ++x)
     {
         Value = Rand.Next();
         TestObject.Add(Value);
         Assert.Equal(Value, TestObject[x]);
     }
     int Count = 0;
     foreach (int Temp in TestObject)
     {
         ++Count;
     }
     Assert.Equal(10, Count);
     TestObject.Remove(TestObject[0]);
     Assert.Equal(9, TestObject.Count);
     TestObject.Clear();
     Assert.Equal(0, TestObject.Count);
 }
 public void NextName()
 {
     var Rand = new Utilities.Random.Random();
     Assert.Equal(3, Rand.Next<string>(new NameGenerator(false, true, true, false)).Split(' ').Length);
     Assert.Equal(2, Rand.Next<string>(new NameGenerator(false, false, true, false)).Split(' ').Length);
     Assert.Equal(4, Rand.Next<string>(new NameGenerator(true, true, true, false)).Split(' ').Length);
     Assert.Equal(5, Rand.Next<string>(new NameGenerator(true, true, true, true)).Split(' ').Length);
 }
        public void NextStringTest()
        {
            var Rand = new Utilities.Random.Random();

            Assert.Equal(10, Rand.Next <string>(new RegexStringGenerator(10)).Length);
        }
 public void NextStringTest()
 {
     var Rand = new Utilities.Random.Random();
     Assert.Equal(10, Rand.Next<string>(new RegexStringGenerator(10)).Length);
 }
        public void NextLoremIpsumTest()
        {
            var Rand = new Utilities.Random.Random();

            Assert.NotNull(Rand.Next <string>(new LoremIpsumGenerator(1, 4)));
        }
Ejemplo n.º 17
0
 public static Bitmap AddNoise(Bitmap OriginalImage, int Amount)
 {
     Bitmap NewBitmap = new Bitmap(OriginalImage.Width, OriginalImage.Height);
     BitmapData NewData = NewBitmap.LockImage();//Image.LockImage(NewBitmap);
     BitmapData OldData = OriginalImage.LockImage();//Image.LockImage(OriginalImage);
     int NewPixelSize = NewData.GetPixelSize();//Image.GetPixelSize(NewData);
     int OldPixelSize = OldData.GetPixelSize();//Image.GetPixelSize(OldData);
     Utilities.Random.Random TempRandom = new Utilities.Random.Random();
     for (int x = 0; x < NewBitmap.Width; ++x)
     {
         for (int y = 0; y < NewBitmap.Height; ++y)
         {
             Color CurrentPixel = OldData.GetPixel(x, y, OldPixelSize);//Image.GetPixel(OldData, x, y, OldPixelSize);
             int R = CurrentPixel.R + TempRandom.Next(-Amount, Amount + 1);
             int G = CurrentPixel.G + TempRandom.Next(-Amount, Amount + 1);
             int B = CurrentPixel.B + TempRandom.Next(-Amount, Amount + 1);
             R = R > 255 ? 255 : R;
             R = R < 0 ? 0 : R;
             G = G > 255 ? 255 : G;
             G = G < 0 ? 0 : G;
             B = B > 255 ? 255 : B;
             B = B < 0 ? 0 : B;
             Color TempValue = Color.FromArgb(R, G, B);
             NewData.SetPixel(x, y, TempValue, NewPixelSize);//Image.SetPixel(NewData, x, y, TempValue, NewPixelSize);
         }
     }
     NewBitmap.UnlockImage(NewData);//Image.UnlockImage(NewBitmap, NewData);
     OriginalImage.UnlockImage(OldData);//Image.UnlockImage(OriginalImage, OldData);
     return NewBitmap;
 }
 public void NextStringTest2()
 {
     var Rand = new Utilities.Random.Random();
     Assert.True(Regex.IsMatch(Rand.Next<string>(new PatternGenerator("(###)###-####")), @"\(\d{3}\)\d{3}-\d{4}"));
     Assert.True(Regex.IsMatch(Rand.Next<string>(new PatternGenerator("(@@@)###-####")), @"\([a-zA-Z]{3}\)\d{3}-\d{4}"));
 }
 public void RegisterGenerator()
 {
     var Rand = new Utilities.Random.Random();
     Rand.RegisterGenerator<string>(new NameGenerator());
     Assert.True(100.Times(x => Rand.Next<string>()).All(x => x.Split(' ').Length == 2));
 }
 public void NextLoremIpsumTest()
 {
     var Rand = new Utilities.Random.Random();
     Assert.NotNull(Rand.Next<string>(new LoremIpsumGenerator(1, 4)));
 }