public void ShouldReturnValueIfKeyIsInDictionary()
            {
                // Given
                var dictionary = new Dictionary<int, string> {{1, "a"}, {2, "b"}};

                // When / Then
                dictionary.FindValue(1).Should().Be("a");
                dictionary.FindValue(2).Should().Be("b");
            }
Example #2
0
        public static void Execute()
        {
            using (var vmClient = new VmClient())
            using (var mouseClient = new MouseClient(VmIp))
            {
                var printIndex = new Dictionary<ScreenPrint, int>();

                for (;;)
                {
                    var bmp = GetScreenImage(vmClient.GameScreenRect);
                    var img = bmp.ToIplImage();
                    var vBmp = new Mat(img, false).CvtColor(ColorConversion.RgbToHsv).Split()[2];
                    //vBmp.ToBitmap().Save("v.png");
                    //vBmp.Resize(new OpenCvSharp.CPlusPlus.Size(16, 16)).ToBitmap().Save("v.16.png");
                    //vBmp.Resize(new OpenCvSharp.CPlusPlus.Size(128, 128)).ToBitmap().Save("v.128.png");

                    var small = vBmp.Resize(new OpenCvSharp.CPlusPlus.Size(4, 4));
                    //Console.WriteLine(small.ElemSize());
                    //Console.WriteLine(vBmp.ElemSize());
                    //return;
                    var print = new ScreenPrint(ColorCut(ToByteArray(small)));
                    var index = printIndex.FindValue(print);
                    if (index == null)
                    {
                        index = (printIndex.Count > 0 ? printIndex.Values.Max() : 0) + 1;
                        printIndex[print] = index.Value;
                    }
                    Console.WriteLine(index);

                    GC.Collect();
                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
                }
            }
        }
            public void ShouldReturnNullIfKeyIsNotDictionary()
            {
                // Given
                var dictionary = new Dictionary<int, string> {{1, "a"}};

                // When / Then
                dictionary.FindValue(2).Should().BeNull();
            }