1
exercism fetch csharp run-length-encoding

RunLengthEncodingTest.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// This file was auto-generated based on version 1.0.0 of the canonical data.

using Xunit;

public class RunLengthEncodingTest
{
    [Fact]
    public void Encode_empty_string()
    {
        Assert.Equal("", RunLengthEncoding.Encode(""));
    }

    [Fact(Skip = "Remove to run test")]
    public void Encode_single_characters_only_are_encoded_without_count()
    {
        Assert.Equal("XYZ", RunLengthEncoding.Encode("XYZ"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Encode_string_with_no_single_characters()
    {
        Assert.Equal("2A3B4C", RunLengthEncoding.Encode("AABBBCCCC"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Encode_single_characters_mixed_with_repeated_characters()
    {
        Assert.Equal("12WB12W3B24WB", RunLengthEncoding.Encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Encode_multiple_whitespace_mixed_in_string()
    {
        Assert.Equal("2 hs2q q2w2 ", RunLengthEncoding.Encode("  hsqq qww  "));
    }

    [Fact(Skip = "Remove to run test")]
    public void Encode_lowercase_characters()
    {
        Assert.Equal("2a3b4c", RunLengthEncoding.Encode("aabbbcccc"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_empty_string()
    {
        Assert.Equal("", RunLengthEncoding.Decode(""));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_single_characters_only()
    {
        Assert.Equal("XYZ", RunLengthEncoding.Decode("XYZ"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_string_with_no_single_characters()
    {
        Assert.Equal("AABBBCCCC", RunLengthEncoding.Decode("2A3B4C"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_single_characters_with_repeated_characters()
    {
        Assert.Equal("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB", RunLengthEncoding.Decode("12WB12W3B24WB"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_multiple_whitespace_mixed_in_string()
    {
        Assert.Equal("  hsqq qww  ", RunLengthEncoding.Decode("2 hs2q q2w2 "));
    }

    [Fact(Skip = "Remove to run test")]
    public void Decode_lower_case_string()
    {
        Assert.Equal("aabbbcccc", RunLengthEncoding.Decode("2a3b4c"));
    }

    [Fact(Skip = "Remove to run test")]
    public void Consistency_encode_followed_by_decode_gives_original_string()
    {
        Assert.Equal("zzz ZZ  zZ", RunLengthEncoding.Decode(RunLengthEncoding.Encode("zzz ZZ  zZ")));
    }
}