Projekt

Obecné

Profil

« Předchozí | Další » 

Revize cbf3b0c6

Přidáno uživatelem Pultak před asi 2 roky(ů)

re #9443 Added implementation of InfoFetcher tests

Zobrazit rozdíly:

ld_client/LDClientTests/detection/DebuggerInfoParserTests.cs
2 2
using LDClient.detection;
3 3
using NUnit.Framework;
4 4

  
5
namespace LDClientTests.detection {
6
    public class DebuggerInfoParserTests {
5
namespace LDClientTests.detection; 
7 6

  
8
        public static readonly string CorrectFileContent =
9
            "B::version.hardware \r\n\r\n" +
10
            "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
11
            "   Serial Number: C12345678912 \r\n\r\n" +
12
            "   Firmware R.2021.02 (136263) \r\n\r\n" +
13
            "   Instance: 1. \r\n\r\n" +
14
            "   Automotive Debug Cable \r\n\r\n" +
15
            "      Serial Number: C98765432198 ";
7
public class DebuggerInfoParserTests {
16 8

  
17
        public static readonly string HeadSerialNumber = "C98765432198";
18
        public static readonly string BodySerialNumber = "C12345678912";
9
    public static readonly string CorrectFileContent =
10
        "B::version.hardware \r\n\r\n" +
11
        "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
12
        "   Serial Number: C12345678912 \r\n\r\n" +
13
        "   Firmware R.2021.02 (136263) \r\n\r\n" +
14
        "   Instance: 1. \r\n\r\n" +
15
        "   Automotive Debug Cable \r\n\r\n" +
16
        "      Serial Number: C98765432198 ";
19 17

  
18
    public static readonly string HeadSerialNumber = "C98765432198";
19
    public static readonly string BodySerialNumber = "C12345678912";
20 20

  
21
        [Test]
22
        [TestCase("B::version.hardware \r\n\r\n" +
23
                  "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
24
                  "   Serial Number: C12345678912 \r\n\r\n" +
25
                  "   Firmware R.2021.02 (136263) \r\n\r\n" +
26
                  "   Instance: 1. \r\n\r\n" +
27
                  "   Automotive Debug Cable \r\n\r\n" +
28
                  "      Serial Number: C12345678912 ", "C12345678912", "C12345678912")]
29
        [TestCase("B::version.hardware \r\n\r\n" +
30
                  "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
31
                  "   Serial Number: C1awfaw484 \r\n\r\n" +
32
                  "   Firmware R.2021.02 (136263) \r\n\r\n" +
33
                  "   Instance: 1. \r\n\r\n" +
34
                  "   Automotive Debug Cable \r\n\r\n" +
35
                  "      Serial Number: C16468551", "C16468551", "C1awfaw484")]
36
        public void Parse_CorrectValues_ReturnSerials(string file, string expectedHead, string expectedBody) {
37
            var (headResult, bodyResult) = DebuggerInfoParser.Parse(file);
38 21

  
39
            Assert.AreEqual(expectedHead, headResult);
40
            Assert.AreEqual(expectedBody, bodyResult);
41
        }
22
    [Test]
23
    [TestCase("B::version.hardware \r\n\r\n" +
24
              "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
25
              "   Serial Number: C12345678912 \r\n\r\n" +
26
              "   Firmware R.2021.02 (136263) \r\n\r\n" +
27
              "   Instance: 1. \r\n\r\n" +
28
              "   Automotive Debug Cable \r\n\r\n" +
29
              "      Serial Number: C12345678912 ", "C12345678912", "C12345678912")]
30
    [TestCase("B::version.hardware \r\n\r\n" +
31
              "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
32
              "   Serial Number: C1awfaw484 \r\n\r\n" +
33
              "   Firmware R.2021.02 (136263) \r\n\r\n" +
34
              "   Instance: 1. \r\n\r\n" +
35
              "   Automotive Debug Cable \r\n\r\n" +
36
              "      Serial Number: C16468551", "C16468551", "C1awfaw484")]
37
    public void Parse_CorrectValues_ReturnSerials(string file, string expectedHead, string expectedBody) {
38
        var (headResult, bodyResult) = DebuggerInfoParser.Parse(file);
42 39

  
43

  
44
        [Test]
45
        [TestCase("B::version.hardware \r\n\r\n" +
46
                  "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
47
                  "   Serial Number: C12345678912 \r\n\r\n" +
48
                  "   Firmware R.2021.02 (136263) \r\n\r\n" +
49
                  "   Instance: 1. \r\n\r\n" +
50
                  "   Automotive Debug Cable \r\n\r\n" +
51
                  "      Serial Number: C12345678912 \n" +
52
                  "      Serial Number: C12345678912 ")]
53
        [TestCase("B::version.hardware \r\n\r\n" +
54
                  "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
55
                  "   Serial Number: C1awfaw484 \r\n\r\n" +
56
                  "   Firmware R.2021.02 (136263) \r\n\r\n" +
57
                  "   Instance: 1. \r\n\r\n" +
58
                  "   Automotive Debug Cable \r\n\r\n" +
59
                  "      Serial Numbeeeer: C16468551")]
60
        public void Parse_IncorrectValues_ThrowException(string file) {
61
            Assert.Throws<ArgumentException>(() => DebuggerInfoParser.Parse(file));
62
        }
40
        Assert.AreEqual(expectedHead, headResult);
41
        Assert.AreEqual(expectedBody, bodyResult);
42
    }
63 43

  
64 44

  
45
    [Test]
46
    [TestCase("B::version.hardware \r\n\r\n" +
47
              "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
48
              "   Serial Number: C12345678912 \r\n\r\n" +
49
              "   Firmware R.2021.02 (136263) \r\n\r\n" +
50
              "   Instance: 1. \r\n\r\n" +
51
              "   Automotive Debug Cable \r\n\r\n" +
52
              "      Serial Number: C12345678912 \n" +
53
              "      Serial Number: C12345678912 ")]
54
    [TestCase("B::version.hardware \r\n\r\n" +
55
              "PowerDebug USB 3.0 via USB 3.0 \r\n\r\n" +
56
              "   Serial Number: C1awfaw484 \r\n\r\n" +
57
              "   Firmware R.2021.02 (136263) \r\n\r\n" +
58
              "   Instance: 1. \r\n\r\n" +
59
              "   Automotive Debug Cable \r\n\r\n" +
60
              "      Serial Numbeeeer: C16468551")]
61
    public void Parse_IncorrectValues_ThrowException(string file) {
62
        Assert.Throws<ArgumentException>(() => DebuggerInfoParser.Parse(file));
65 63
    }
66
}
64

  
65

  
66
}

Také k dispozici: Unified diff