コード例 #1
0
        public void ClaimTestAndMarkSuccess()
        {
            using (var connProvider = new SqliteConnectionProvider("claimtest"))
            {
                var repo = new TestRepository(connProvider);
                repo.EnsureSchema();
                repo.CreateTestRun("prod");

                repo.SaveBenchmark("prod", "/this/that", "mytestimage", new byte[] { 1, 2, 3 });
                repo.SaveTestImage(1, "/this/that", "mytestimage", new byte[] { 1, 2, 3 });

                var claimedImage = repo.ClaimNextTestImage("test");

                Assert.Equal(1, claimedImage.TestRunId);
                Assert.Equal("/this/that", claimedImage.Path);

                var benchmark = repo.GetBenchmark(claimedImage.Application, claimedImage.Path);
                var testImage = repo.GetTestImage(claimedImage.TestRunId, claimedImage.Path);

                Assert.Equal(new byte[] { 1, 2, 3 }, benchmark);
                Assert.Equal(new byte[] { 1, 2, 3 }, testImage);

                repo.MarkTestImageSuccess(1, "/this/that");

                Assert.Null(repo.ClaimNextTestImage("test"));

                var testRun = repo.GetTestRun(1);
                Assert.Equal("Submitted", testRun.TestImages[0].State);
            }
        }
コード例 #2
0
        public void ClaimTestAndMarkDifference()
        {
            using (var connProvider = new SqliteConnectionProvider("claimtest"))
            {
                var repo = new TestRepository(connProvider);
                repo.EnsureSchema();
                repo.CreateTestRun("prod");

                repo.SaveBenchmark("prod", "/this/that", "mytestimage", new byte[] { 1, 2, 3 });
                repo.SaveTestImage(1, "/this/that", "mytestimage", new byte[] { 1, 2, 3 });

                var claimedImage = repo.ClaimNextTestImage("test");

                Assert.Equal(1, claimedImage.TestRunId);
                Assert.Equal("/this/that", claimedImage.Path);

                repo.MarkTestImageDifferent(1, "/this/that", new byte[] { 2, 3 });

                Assert.Null(repo.ClaimNextTestImage("test"));

                var testRun = repo.GetTestRun(1);
                Assert.Equal("Different", testRun.TestImages[0].State);

                var diff = repo.GetDifferenceImage(1, "/this/that");
                Assert.Equal(new byte[] { 2, 3 }, diff);
            }
        }
コード例 #3
0
        public void TestImageWithoutBenchmarkCantBeClaimed()
        {
            using (var connProvider = new SqliteConnectionProvider("claimtest"))
            {
                var repo = new TestRepository(connProvider);
                repo.EnsureSchema();
                repo.CreateTestRun("prod");

                repo.SaveTestImage(1, "/this/that", "mytestimage", new byte[] { 1, 2, 3 });

                Assert.Null(repo.ClaimNextTestImage("test"));

                var testRun = repo.GetTestRun(1);
                Assert.Equal(ImageState.NoBenchmark, testRun.TestImages[0].State);
            }
        }