Ejemplo n.º 1
0
        public void GivenTestXXX_generatesExpectedResult()
        {
            var text = Util.LoadText("MainWindow.md");

            var markdown = new Markdown.Avalonia.Markdown();
            var control  = markdown.Transform(text);

            control.Styles.Add(new StyleInclude(new Uri("avares://Avalonia.Themes.Default/"))
            {
                Source = new Uri("avares://Avalonia.Themes.Default/DefaultTheme.xaml")
            });
            control.Styles.Add(new StyleInclude(new Uri("avares://Avalonia.Themes.Default/"))
            {
                Source = new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml")
            });
            control.Styles.Add(MarkdownStyle.DefaultTheme);
            control.Resources.Add("FontSizeNormal", 16d);

            var umefont = new FontFamily(new Uri("avares://UnitTest.CTxt/Assets/Fonts/ume-ugo4.ttf"), "Ume UI Gothic");

            TextBlock.SetFontFamily(control, umefont);

            var info = new MetryHolder(control, 500, 10000);

            Approvals.Verify(
                new ApprovalImageWriter(info.Image),
                Approvals.GetDefaultNamer(),
                new DiffToolReporter(DiffEngine.DiffTool.WinMerge));
        }
Ejemplo n.º 2
0
        public void WriteFile_WithBlock_ReturnsExpectedResult()
        {
            var namer = Approvals.GetDefaultNamer();
            var file  = Path.Combine(namer.SourcePath, namer.Name + ".received.stl");

            _objectUnderTest.WriteToFile(file, TestHelpers.BlockExpectedResult);
            Approvals.Verify(new FileInfo(file));
        }
Ejemplo n.º 3
0
 public void WithScenarioData()
 {
     using (ApprovalResults.ForScenario("scenarioname"))
     {
         var name = Approvals.GetDefaultNamer().Name;
         Assert.AreEqual("AdditionalInformationTests.WithScenarioData.ForScenario.scenarioname", name);
     }
 }
Ejemplo n.º 4
0
 public void WithMultiplePartScenarioData(string a, string b)
 {
     using (ApprovalResults.ForScenario(a, b))
     {
         var name = Approvals.GetDefaultNamer().Name;
         Assert.AreEqual("AdditionalInformationTests.WithMultiplePartScenarioData.ForScenario.foo.bar", name);
     }
 }
Ejemplo n.º 5
0
 public void WithScenarioDataScrubsInvalidChars()
 {
     using (ApprovalResults.ForScenario("invalid/chars"))
     {
         var name = Approvals.GetDefaultNamer().Name;
         Assert.AreEqual(
             "AdditionalInformationTests.WithScenarioDataScrubsInvalidChars.ForScenario.invalid_chars", name);
     }
 }
 public void TestApprovalNameWithAdditionalInformation(string fileName)
 {
     using (ApprovalResults.ForScenario(fileName))
     {
         var name = Approvals.GetDefaultNamer().Name;
         Assert.Equal("XunitTheoryStackTraceParserTest.TestApprovalNameWithAdditionalInformation.ForScenario." + fileName,
                      name);
     }
 }
        public void TestSourcePath()
        {
            var path = Approvals.GetDefaultNamer().SourcePath;

            Assert.IsNotEmpty(path);
            var fullPath = path.ToLower() + Path.DirectorySeparatorChar + GetType().Name + ".cs";

            Assert.IsTrue(File.Exists(fullPath), fullPath + " does not exist");
        }
Ejemplo n.º 8
0
        public void FileNames()
        {
            var    namer        = Approvals.GetDefaultNamer();
            string className    = ___;
            string methodName   = "FileNames";
            string approvalName = className + "." + methodName;

            Assert.AreEqual(namer.Name, approvalName);
        }
Ejemplo n.º 9
0
        public void TestExistFileIsApproved()
        {
            var basePath = Environment.CurrentDirectory + @"\..\..\";

            var original = basePath + "a.png";
            var copy     = basePath + "a1.png";

            File.Copy(original, copy);
            Approvals.Approve(new ExistingFileWriter(copy), Approvals.GetDefaultNamer(), Approvals.GetReporter());
        }
Ejemplo n.º 10
0
            public ApprovalFileNamer(string name)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentException("You must specify a name for the approval file");
                }

                Name       = name;
                SourcePath = Approvals.GetDefaultNamer().SourcePath;
            }
            public ApprovalFileNamer(string name)
            {
                if (String.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentException("A file name for the approvals file must be provided");
                }

                Name       = name;
                SourcePath = Approvals.GetDefaultNamer().SourcePath;
            }
Ejemplo n.º 12
0
        public void TestExistFileIsApproved()
        {
            var basePath = PathUtilities.GetDirectoryForCaller() + ".." + Path.DirectorySeparatorChar;

            var original = basePath + "a.png";
            var copy     = basePath + "a1.png";

            File.Copy(original, copy, true);
            Approvals.Verify(new ExistingFileWriter(copy), Approvals.GetDefaultNamer(), Approvals.GetReporter());
        }
        public async Task WithScenarioDataAsync()
        {
            using (ApprovalResults.ForScenario("asyncScenario"))
            {
                await Task.Delay(10);

                var name = Approvals.GetDefaultNamer().Name;
                Assert.AreEqual("AdditionalInformationTests.WithScenarioDataAsync.ForScenario.asyncScenario", name);
            }
        }
Ejemplo n.º 14
0
        public void GivenTest2_generatesExpectedResult()
        {
            var tst2 = new Test2();
            var ctxt = (CTextBlock)tst2.Content;

            var info = new MetryHolder(ctxt, 1000, 1000);

            Approvals.Verify(
                new ApprovalImageWriter(info.Image),
                Approvals.GetDefaultNamer(),
                new DiffToolReporter(DiffEngine.DiffTool.WinMerge));
        }
Ejemplo n.º 15
0
        public void VerifyingBiggerText()
        {
            Rectangle r = new Rectangle();

            r.Width  = 100;
            r.Height = ____;
            r.X      = 134;
            r.Y      = 162;
            var namer = Approvals.GetDefaultNamer();

            FileAssert.VerifyContentsIsEqual(namer.Name + ".txt", r.ToString());
        }
Ejemplo n.º 16
0
 public void TestMultipleNames()
 {
     using (ApprovalResults.ForScenario("scenario"))
     {
         using (ApprovalResults.ForScenario("machineName"))
         {
             string name = Approvals.GetDefaultNamer().Name;
             Assert.AreEqual(name,
                             "AdditionalInformationTests.TestMultipleNames.ForScenario.scenario.ForScenario.machineName");
         }
     }
 }
Ejemplo n.º 17
0
        public void GivenTest3_generatesExpectedResult_sub2()
        {
            var tst3 = new Test3();
            var spnl = (StackPanel)tst3.Content;

            var ctxt = (CTextBlock)spnl.Children[2];
            var info = new MetryHolder(ctxt, 1000, 1000);

            Approvals.Verify(
                new ApprovalImageWriter(info.Image),
                Approvals.GetDefaultNamer(),
                new DiffToolReporter(DiffEngine.DiffTool.WinMerge));
        }
 public void DemoAlternativeMachineSpecific()
 {
     using var previous =
               // begin-snippet: alternative_naming
               WinFormsApprovals.RegisterDefaultAdditionalInfo(ApprovalResults.UniqueForUserName);
     // end-snippet
     using var info = WinFormsApprovals.GetDefaultAdditionalInfo()();
     var name         = Approvals.GetDefaultNamer().Name;
     var approvalName =
         // begin-snippet: alternative_custom_name
         "WinFormTests.DemoAlternativeMachineSpecific.ForUser.Tomas";
     // end-snippet
 }
Ejemplo n.º 19
0
        public void UsingAutomaticFileNames()
        {
            var namer = Approvals.GetDefaultNamer();

            FileAssert.VerifyContentsIsEqual(namer.Name + ".txt", ___);
        }
Ejemplo n.º 20
0
        public void AutomaticallyGeneratedNames()
        {
            var namer = Approvals.GetDefaultNamer();

            Assert.AreEqual(namer.Name, ___);
        }
Ejemplo n.º 21
0
        public void SeeingFilesSideBySide()
        {
            var namer = Approvals.GetDefaultNamer();

            Approvals.Verify(___ + "\r\n" + namer.Name);
        }
Ejemplo n.º 22
0
        public void ApprovalFileName()
        {
            var namer = Approvals.GetDefaultNamer();

            Assert.AreEqual(namer.Name, ___);
        }
Ejemplo n.º 23
0
        public void WithoutExtraInfo()
        {
            var name = Approvals.GetDefaultNamer().Name;

            Assert.AreEqual("AdditionalInformationTests.WithoutExtraInfo", name);
        }
Ejemplo n.º 24
0
            public void WithNestedClass()
            {
                var name = Approvals.GetDefaultNamer().Name;

                Assert.AreEqual("AdditionalInformationTests.NestedClassTests.WithNestedClass", name);
            }
Ejemplo n.º 25
0
        public void _____()
        {
            var namer = Approvals.GetDefaultNamer();

            Assert.AreEqual(namer.Name, "GettingStarted.UsesMethodName");
        }
Ejemplo n.º 26
0
 private void SetGeneratedApprovedFilePath()
 {
     generatedApprovedFilePath = solutiondirecory + Approvals.GetDefaultNamer().Name + ".approved.jpg";
 }
Ejemplo n.º 27
0
        public static void VerifyXlsxFile(string xlsxFile, bool deleteOnSuccess = true)
        {
            var zipApprover = new ZipApprover(new ExistingFileWriter(xlsxFile), Approvals.GetDefaultNamer(), deleteOnSuccess);

            Approver.Verify(zipApprover, Approvals.GetReporter());
        }
Ejemplo n.º 28
0
        public static void VerifyXlsx(byte[] xlsxBytes)
        {
            var zipApprover = new ZipApprover(new ApprovalBinaryWriter(xlsxBytes, "xlsx"), Approvals.GetDefaultNamer(), true);

            Approver.Verify(zipApprover, Approvals.GetReporter());
        }