Ejemplo n.º 1
0
        public async Task SaveScreenshot_WithSuffix_SavesImage()
        {
            var app          = new Simulators.App();
            var testRecorder = new TestRecorder(app);

            await testRecorder.SaveScreenshot("MySuffix");

            var file = GetScreenshots().Single();

            var fileName = Path.GetFileName(file);

            Assert.AreEqual($"{nameof(SaveScreenshot_WithSuffix_SavesImage)}MySuffix{GetLineNumber(-5)}-win1.jpg", fileName);
        }
Ejemplo n.º 2
0
        public async Task SaveScreenshot_WithSuffix_SavesImage()
        {
            await using var app = new Simulators.App();
            await using TestRecorder testRecorder = new(app);

            Assert.IsNotNull(await testRecorder.SaveScreenshot("MySuffix"));

            var file = testRecorder.EnumerateScreenshots()
                       .Where(x => Path.GetFileName(Path.GetDirectoryName(x)) == nameof(TestRecorderTests) &&
                              Path.GetFileName(x).StartsWith(nameof(SaveScreenshot_WithSuffix_SavesImage)))
                       .Single();

            var fileName = Path.GetFileName(file);

            Assert.AreEqual(nameof(TestRecorderTests), Path.GetFileName(Path.GetDirectoryName(file)));
            Assert.AreEqual($"{nameof(SaveScreenshot_WithSuffix_SavesImage)}MySuffix{GetLineNumber(-9)}-1.jpg", fileName);
            testRecorder.Success();
        }
Ejemplo n.º 3
0
        public async Task TestRecorder_WithCtorSuffix_AppendsToAllFileNames()
        {
            await using var app = new Simulators.App();
            await using TestRecorder testRecorder = new(app, "CtorSuffix");

            Assert.IsNotNull(await testRecorder.SaveScreenshot("OtherSuffix1"));
            Assert.IsNotNull(await testRecorder.SaveScreenshot("OtherSuffix2"));

            var files = testRecorder.EnumerateScreenshots()
                        .Where(x => Path.GetFileName(Path.GetDirectoryName(x)) == nameof(TestRecorderTests) &&
                               Path.GetFileName(x).StartsWith(nameof(TestRecorder_WithCtorSuffix_AppendsToAllFileNames)))
                        .ToList();

            Assert.AreEqual(2, files.Count);
            var file1Name = Path.GetFileName(files[0]);
            var file2Name = Path.GetFileName(files[1]);

            Assert.AreEqual($"{nameof(TestRecorder_WithCtorSuffix_AppendsToAllFileNames)}CtorSuffixOtherSuffix1{GetLineNumber(-11)}-1.jpg", file1Name);
            Assert.AreEqual($"{nameof(TestRecorder_WithCtorSuffix_AppendsToAllFileNames)}CtorSuffixOtherSuffix2{GetLineNumber(-11)}-2.jpg", file2Name);
            testRecorder.Success();
        }
Ejemplo n.º 4
0
 public async Task TestRecorder_WhenExceptionThrown_DoesNotRethrow()
 {
     await using var app = new Simulators.App();
     await using TestRecorder testRecorder = new(app);
     await app.InitializeWithDefaults(null !);
 }