Skip to content

Commit

Permalink
Write some integration tests. (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Choc13 authored Nov 24, 2021
1 parent 0501dd4 commit ea33844
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 150 deletions.
4 changes: 2 additions & 2 deletions src/Symbolica.Extensions.Configuration.FSharp/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open Microsoft.Extensions.Configuration
/// <summary>
/// A <see cref="Binder" /> that retrieves the section specified by the <paramref name="key" />.
/// </summary>
/// <remarks>Will evaluate to <c>Failure</c> if the <pararef name="key" /> cannot be found.</remarks>
/// <remarks>Will evaluate to <c>Failure</c> if the <paramref name="key" /> cannot be found.</remarks>
/// <param name="key">The key of the child section to retrieve.</param>
let section key : Binder<'config, IConfigurationSection, Error> =
Binder (fun (parent: #IConfiguration) ->
Expand All @@ -23,7 +23,7 @@ let section key : Binder<'config, IConfigurationSection, Error> =
/// <summary>
/// A <see cref="Binder" /> that retrieves the optional section specified by the <paramref name="key" />.
/// </summary>
/// <remarks>Will evaluate to <c>Success(None)</c> if the <pararef name="key" /> cannot be found.</remarks>
/// <remarks>Will evaluate to <c>Success(None)</c> if the <paramref name="key" /> cannot be found.</remarks>
/// <param name="key">The key of the child section to retrieve.</param>
let optSection key =
Binder (fun (parent: #IConfiguration) ->
Expand Down
12 changes: 7 additions & 5 deletions src/Symbolica.Extensions.Configuration.FSharp/Error.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Symbolica.Extensions.Configuration.FSharp

open System

module private String =
let indent by string =
$"""{" " |> String.replicate (2 * by)}{string}"""
Expand Down Expand Up @@ -111,9 +113,9 @@ type Errors<'a> =
let printedErrors =
errors
|> List.map (printItem (indent + 1))
|> String.concat "\n"
|> String.concat Environment.NewLine

$"{key |> String.indent indent}:\n{printedErrors}"
$"{key |> String.indent indent}:{Environment.NewLine}{printedErrors}"

module Errors =
/// <summary>Maps the errors contained within the <see cref="Errors" />.</summary>
Expand Down Expand Up @@ -196,14 +198,14 @@ type Error =
member x.ToString(indent) =
(match x with
| SectionError (key, error) ->
$"@'{key}':\n{error.ToString(indent + 1)}"
$"@'{key}':{Environment.NewLine}{error.ToString(indent + 1)}"
|> String.indent indent
| Many errors -> errors.ToString(indent, (fun i x -> x.ToString(i)))
| ValueError (value, error) ->
[ $"Value: '{value}'"
$"Error:\n{error.ToString(indent + 1)}" ]
$"Error:{Environment.NewLine}{error.ToString(indent + 1)}" ]
|> List.map (String.indent indent)
|> String.concat "\n"
|> String.concat Environment.NewLine
| NotAValueNode ->
"Expected a value, but found a section with children."
|> String.indent indent
Expand Down
142 changes: 0 additions & 142 deletions tests/Symbolica.Extensions.Configuration.FSharp.Tests/BuilderTests.fs

This file was deleted.

Loading

0 comments on commit ea33844

Please sign in to comment.