Skip to content

Commit

Permalink
added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brockallen committed Feb 15, 2022
1 parent aa0f719 commit f1fdfac
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/IdentityServer.UnitTests/Extensions/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Xunit;
using Duende.IdentityServer.Extensions;
using FluentAssertions;
using System.Linq;

namespace UnitTests.Extensions;

Expand Down Expand Up @@ -76,6 +77,40 @@ public void TestGetOrigin()
CheckOrigin("test://localhost:8080/test/resource", "test://localhost:8080");
}

[Fact]
[Trait("Category", Category)]
public void ToSpaceSeparatedString_should_return_correct_value()
{
var value = new[] { "foo", "bar", "baz", "baz", "foo", "bar" }.ToSpaceSeparatedString();
value.Should().Be("foo bar baz baz foo bar");
}

[Fact]
[Trait("Category", Category)]
public void FromSpaceSeparatedString_should_return_correct_values()
{
var values = "foo bar baz baz foo bar".FromSpaceSeparatedString().ToArray();
values.Length.Should().Be(6);
values[0].Should().Be("foo");
values[1].Should().Be("bar");
values[2].Should().Be("baz");
values[3].Should().Be("baz");
values[4].Should().Be("foo");
values[5].Should().Be("bar");
}

[Fact]
[Trait("Category", Category)]
public void FromSpaceSeparatedString_should_only_process_spaces()
{
var values = "foo bar\tbaz baz\rfoo bar\r\nbar".FromSpaceSeparatedString().ToArray();
values.Length.Should().Be(4);
values[0].Should().Be("foo");
values[1].Should().Be("bar\tbaz");
values[2].Should().Be("baz\rfoo");
values[3].Should().Be("bar\r\nbar");
}


// scope parsing

Expand Down

0 comments on commit f1fdfac

Please sign in to comment.