public void ScreenAnalyzer_ValidData_RyanAirMatched()
        {
            var            matcher  = new TestMatcher();
            IDataProvider  dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, matcher);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            var expected = new Dictionary <string, bool>()
            {
                { "bmw", false },
                { "ryanair", true }
            };

            matcher._counter        = 1;
            matcher._indexOfPattern = 1;

            sa.AnalyzeScreenAsync(pic);

            var result = dataBase.GetUserActivity();

            var dict3 = result.Where(entry => expected[entry.Key] != entry.Value)
                        .ToDictionary(entry => entry.Key, entry => entry.Value);

            //if it is 0 there is match between both dictionaries
            Assert.That(dict3.Count, Is.Zero);
        }
        public void ScreenAnalyzer_InvalidDatabase_ExceptionThrown()
        {
            var            matcher = new TestMatcher();
            ScreenAnalyzer sa      = new ScreenAnalyzer(null, matcher);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            Task task = sa.AnalyzeScreenAsync(null)
                        .ContinueWith(innerTask =>
            {
                // ... assertions here ...
            });
        }
        public void ScreenAnalyzer_NoPatternMatch_ScreenIsUploaded()
        {
            var matcher = new TestMatcher(true);

            var            dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, matcher);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            var expected = new Dictionary <string, bool>()
            {
                { "bmw", false },
                { "ryanair", false }
            };

            sa.AnalyzeScreenAsync(pic);

            var result = dataBase.GetUserActivity();

            var dict3 = result.Where(entry => expected[entry.Key] != entry.Value)
                        .ToDictionary(entry => entry.Key, entry => entry.Value);

            //if it is 0 there is match between both dictionaries
            Assert.That(dict3.Count, Is.Zero);

            var comparisonResult = ByteArrayCompare(BitmapByteConverter.ConvertBitmapToByteArray(pic), dataBase.getScreen());

            Assert.That(comparisonResult, Is.True);
        }