Projekt

Obecné

Profil

Stáhnout (2.66 KB) Statistiky
| Větev: | Tag: | Revize:
1
using System;
2
using LDClient.detection;
3
using NUnit.Framework;
4

    
5
namespace LDClientTests.detection; 
6

    
7
public class DebuggerInfoParserTests {
8

    
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 ";
17

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

    
21

    
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);
39

    
40
        Assert.AreEqual(expectedHead, headResult);
41
        Assert.AreEqual(expectedBody, bodyResult);
42
    }
43

    
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));
63
    }
64

    
65

    
66
}
(1-1/3)