// public static void RegisterRoutes(RouteCollection routes) // { // routes.MapPageRoute("", // "Category/{action}/{categoryName}", // "~/categoriespage.aspx"); // } // private string GetMacAddress() // { // string macAddresses = string.Empty; // // foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) // { // if (nic.OperationalStatus == OperationalStatus.Up) // { // macAddresses += nic.GetPhysicalAddress().ToString(); // break; // } // } // Console.WriteLine(macAddresses); // return macAddresses; // } public static string GetLocalIPAddress() { var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { return(ip.ToString()); } } throw new Exception("No network adapters with an IPv4 address in the system!"); }
public void Should_measure_lookups() { const int lookupsCount = 5; for (var i = 0; i < lookupsCount; i++) { DNS.GetHostEntry("google.com"); } Action assertion = () => collections.Should().HaveCount(lookupsCount); assertion.ShouldPassIn(5.Seconds()); collections.Any(info => info.IsFailed).Should().BeFalse(); }
public void Should_measure_lookup_latency() { var stopWatch = Stopwatch.StartNew(); DNS.GetHostEntry("google.com"); stopWatch.Stop(); Action assertion = () => collections.Should().HaveCount(1); assertion.ShouldPassIn(5.Seconds()); var latency = collections.Single().Latency; Math.Abs(stopWatch.ElapsedMilliseconds - latency.TotalMilliseconds).Should().BeLessThan(1); }
public Server(int port, IMPLEMENTATION implementor) { Debug.Assert(implementor != null); ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.ReflectionStarted)); var knownTypes = Utility.CollectKnownTypes(typeof(CONTRACT)); serializer = new(typeof(MethodSchema), knownTypes); methodDictionary = new MethodDictionary(); CreateImplementingDynamicMethods(implementor); ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.ReflectionComplete)); this.implementor = implementor; this.port = port; localIpAddress = Dns.GetHostEntry(DefinitionSet.localHost).AddressList[0]; listener = new(localIpAddress, port); listeningThread = new(ListenerThreadBody); protocolThread = new(ProtocolThreadBody); } //Server
public void Should_measure_failed_lookups() { const int lookupsCount = 5; for (var i = 0; i < lookupsCount; i++) { try { DNS.GetHostEntry("go23t2dst2ogle.c23t4vgwom"); } catch { // Ignore } } Action assertion = () => collections.Should().HaveCount(lookupsCount); assertion.ShouldPassIn(30.Seconds()); collections.All(info => info.IsFailed).Should().BeTrue(); }