1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.IO; 6 using Xunit; 7 8 namespace System.Net.NetworkInformation.Tests 9 { 10 public class MiscParsingTests : FileCleanupTestBase 11 { 12 [Fact] NumRoutesParsing()13 public void NumRoutesParsing() 14 { 15 string fileName = GetTestFilePath(); 16 FileUtil.NormalizeLineEndings("route", fileName); 17 int numRoutes = StringParsingHelpers.ParseNumRoutesFromRouteFile(fileName); 18 Assert.Equal(4, numRoutes); 19 } 20 21 [Fact] DefaultTtlParsing()22 public void DefaultTtlParsing() 23 { 24 string fileName = GetTestFilePath(); 25 FileUtil.NormalizeLineEndings("snmp", fileName); 26 int ttl = StringParsingHelpers.ParseDefaultTtlFromFile(fileName); 27 Assert.Equal(64, ttl); 28 } 29 30 [Fact] RawIntFileParsing()31 public static void RawIntFileParsing() 32 { 33 int val = StringParsingHelpers.ParseRawIntFile("rawint"); 34 Assert.Equal(12, val); 35 36 int max = StringParsingHelpers.ParseRawIntFile("rawint_maxvalue"); 37 Assert.Equal(int.MaxValue, max); 38 } 39 40 [Fact] RawLongFileParsing()41 public static void RawLongFileParsing() 42 { 43 long val = StringParsingHelpers.ParseRawLongFile("rawlong"); 44 Assert.Equal(3147483647L, val); 45 46 long max = StringParsingHelpers.ParseRawLongFile("rawlong_maxvalue"); 47 Assert.Equal(long.MaxValue, max); 48 } 49 50 [Fact] RawHexIntParsing()51 public static void RawHexIntParsing() 52 { 53 int val = StringParsingHelpers.ParseRawHexFileAsInt("rawhexint"); 54 Assert.Equal(10, val); 55 } 56 } 57 } 58