Projekt

Obecné

Profil

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

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

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

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

    
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

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

    
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
        }
63

    
64

    
65
    }
66
}
    (1-1/1)