public GenericIssueReportFixture(GenericIssueReportTemplate template)
 {
     this.Log = new FakeLog {
         Verbosity = Verbosity.Normal
     };
     this.GenericIssueReportFormatSettings =
         GenericIssueReportFormatSettings.FromEmbeddedTemplate(template);
 }
 public GenericIssueReportFixture(string templateContent)
 {
     this.Log = new FakeLog {
         Verbosity = Verbosity.Normal
     };
     this.GenericIssueReportFormatSettings =
         GenericIssueReportFormatSettings.FromContent(templateContent);
 }
            public void Should_Set_Embedded_Template()
            {
                // Given
                var template = GenericIssueReportTemplate.HtmlDiagnostic;

                // When
                var settings = GenericIssueReportFormatSettings.FromEmbeddedTemplate(template);

                // Then
                settings.Template.ShouldNotBeNullOrWhiteSpace();
            }
Ejemplo n.º 4
0
            public void Should_Throw_If_Log_Is_Null()
            {
                // Given / When
                var result = Record.Exception(() =>
                                              new GenericIssueReportGenerator(
                                                  null,
                                                  GenericIssueReportFormatSettings.FromContent("Foo")));

                // Then
                result.IsArgumentNullException("log");
            }
            public void Should_Set_Template()
            {
                // Given
                var templateContent = "foo";

                // When
                var settings = GenericIssueReportFormatSettings.FromContent(templateContent);

                // Then
                settings.Template.ShouldBe(templateContent);
            }
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                GenericIssueReportFormatSettings settings = null;

                // When
                var result = Record.Exception(() =>
                                              settings.WithOption(HtmlDxDataGridOption.Theme, "Bar"));

                // Then
                result.IsArgumentNullException("settings");
            }
            public void Should_Throw_If_TemplateContent_Is_WhiteSpace()
            {
                // Given
                var templateContent = " ";

                // When
                var result = Record.Exception(() =>
                                              GenericIssueReportFormatSettings.FromContent(templateContent));

                // Then
                result.IsArgumentOutOfRangeException("templateContent");
            }
            public void Should_Throw_If_TemplateContent_Is_Null()
            {
                // Given
                string templateContent = null;

                // When
                var result = Record.Exception(() =>
                                              GenericIssueReportFormatSettings.FromContent(templateContent));

                // Then
                result.IsArgumentNullException("templateContent");
            }
            public void Should_Throw_If_TemplatePath_Is_Null()
            {
                // Given
                FilePath templatePath = null;

                // When
                var result = Record.Exception(() =>
                                              GenericIssueReportFormatSettings.FromFilePath(templatePath));

                // Then
                result.IsArgumentNullException("templatePath");
            }
            public void Should_Add_Option()
            {
                // Given
                var key      = HtmlDxDataGridOption.Title;
                var value    = "Bar";
                var settings = GenericIssueReportFormatSettings.FromContent("Foo");

                // When
                var result = settings.WithOption(key, value);

                // Then
                result.Options.Count.ShouldBe(1);
                result.Options.ShouldContainKeyAndValue(key.ToString(), value);
            }
            public void Should_Read_Template_From_Disk()
            {
                var fileName = System.IO.Path.GetTempFileName();

                try
                {
                    // Given
                    string expected;
                    using (var ms = new MemoryStream())
                        using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Reporting.Generic.Tests.Templates.TestTemplate.cshtml"))
                        {
                            if (stream == null)
                            {
                                throw new ApplicationException("Resource 'Cake.Issues.Reporting.Generic.Tests.Templates.TestTemplate.cshtml' not found.");
                            }

                            stream.CopyTo(ms);
                            var data = ms.ToArray();

                            using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                            {
                                file.Write(data, 0, data.Length);
                            }

                            expected = ConvertFromUtf8(data);
                        }

                    // When
                    var settings =
                        GenericIssueReportFormatSettings.FromFilePath(fileName);

                    // Then
                    settings.Template.ShouldBe(expected);
                }
                finally
                {
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                }
            }