• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AlamoEngine-Tools / PetroglyphTools / 8252849769

12 Mar 2024 05:02PM UTC coverage: 74.489% (+0.8%) from 73.737%
8252849769

Pull #387

github

web-flow
Merge f7095f970 into f4ad7514b
Pull Request #387: Use CommonUtilites as dependency

653 of 788 branches covered (82.87%)

Branch coverage included in aggregate %.

80 of 143 new or added lines in 17 files covered. (55.94%)

15 existing lines in 4 files now uncovered.

1645 of 2297 relevant lines covered (71.62%)

73.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/PG.Commons/PG.Commons.Test/Utilities/EncodingExtensionsTest.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using Microsoft.VisualStudio.TestTools.UnitTesting;
5
using PG.Commons.Utilities;
6

7
namespace PG.Commons.Test.Utilities;
8

9
[TestClass]
10
public class EncodingExtensionsTest
11
{
12
    [TestMethod]
13
    public void Test_GetByteCountPG_NullArgs_Throws()
14
    {
15
        Encoding encoding = null!;
×
16
        Assert.ThrowsException<ArgumentNullException>(() => encoding.GetByteCountPG(4));
×
17
    }
×
18

19
    [TestMethod]
20
    public void Test_GetByteCountPG_NegativeCount_Throws()
21
    {
22
        Assert.ThrowsException<ArgumentOutOfRangeException>(() => Encoding.ASCII.GetByteCountPG(-1));
×
23
    }
×
24

25
    [DataTestMethod]
26
    [DynamicData(nameof(EncodingTestData), DynamicDataSourceType.Method)]
27
    public void Test_GetByteCountPG(Encoding encoding, int charCount, int expectedBytesCount)
28
    {
29
        Assert.AreEqual(expectedBytesCount, encoding.GetByteCountPG(charCount));
×
30
    }
×
31

32
    [DataTestMethod]
33
    [DynamicData(nameof(NotSupportedEncodings), DynamicDataSourceType.Method)]
34
    public void Test_GetByteCountPG_NotSupportedEncodings_Throws(Encoding encoding)
35
    {
36
        Assert.ThrowsException<NotSupportedException>(() => encoding.GetByteCountPG(4));
×
37
    }
×
38

39
    private static IEnumerable<object[]> EncodingTestData()
40
    {
41
        return new[]
×
42
        {
×
43
            [Encoding.Unicode, 0, 0],
×
44
            [Encoding.Unicode, 1, 2],
×
45
            [Encoding.Unicode, 2, 4],
×
46
            [Encoding.Unicode, 3, 6],
×
47
            [Encoding.Unicode, 256, 512],
×
48

×
49
            [Encoding.ASCII, 0, 0],
×
50
            [Encoding.ASCII, 1, 1],
×
51
            [Encoding.ASCII, 2, 2],
×
52
            [Encoding.ASCII, 3, 3],
×
53
            new object[] { Encoding.ASCII, 256, 256 },
×
54
        };
×
55
    }
56

57
    private static IEnumerable<object[]> NotSupportedEncodings()
58
    {
59
        return new[]
×
60
        {
×
61
            [Encoding.BigEndianUnicode],
×
62
            [Encoding.GetEncoding(28591)], // Latin1
×
63
            [Encoding.UTF32],
×
64
            [Encoding.UTF8],
×
NEW
65
#pragma warning disable SYSLIB0001
×
66
            [Encoding.UTF7],
×
NEW
67
#pragma warning restore SYSLIB0001
×
68
            [new MyAsciiEncoding()],
×
69
            new object[] { new MyUnicodeEncoding() },
×
70
        };
×
71
    }
72

73
    internal sealed class MyAsciiEncoding : ASCIIEncoding;
74

75
    internal sealed class MyUnicodeEncoding : UnicodeEncoding;
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc