< Summary

Information
Class: IceBox.Server
Assembly: iceboxnet
File(s): /home/runner/work/ice/ice/csharp/src/iceboxnet/Server.cs
Tag: 71_18251537082
Line coverage
46%
Covered lines: 20
Uncovered lines: 23
Coverable lines: 43
Total lines: 82
Line coverage: 46.5%
Branch coverage
25%
Covered branches: 3
Total branches: 12
Branch coverage: 25%
Method coverage
66%
Covered methods: 2
Total methods: 3
Method coverage: 66.6%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
usage()100%210%
run(...)25%301250%
Main(...)100%1.02175%

File(s)

/home/runner/work/ice/ice/csharp/src/iceboxnet/Server.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceBox;
 4
 5public static class Server
 6{
 7    private static void usage()
 8    {
 09        Console.Error.WriteLine("Usage: iceboxnet [options] --Ice.Config=<file>\n");
 010        Console.Error.WriteLine(
 011            "Options:\n" +
 012            "-h, --help           Show this message.\n" +
 013            "-v, --version        Display the Ice version.");
 014    }
 15
 16    private static int run(Ice.Communicator communicator, string[] args)
 17    {
 18        const string prefix = "IceBox.Service.";
 119        Ice.Properties properties = communicator.getProperties();
 120        Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix);
 21
 122        var argSeq = new List<string>(args);
 123        foreach (KeyValuePair<string, string> pair in services)
 24        {
 125            string name = pair.Key[prefix.Length..];
 026            argSeq.RemoveAll(v => v.StartsWith($"--{name}", StringComparison.Ordinal));
 27        }
 28
 129        foreach (string arg in args)
 30        {
 031            if (arg == "-h" || arg == "--help")
 32            {
 033                usage();
 034                return 0;
 35            }
 036            else if (arg == "-v" || arg == "--version")
 37            {
 038                Console.Out.WriteLine(Ice.Util.stringVersion());
 039                return 0;
 40            }
 41            else
 42            {
 043                Console.Error.WriteLine("IceBox.Server: unknown option `" + arg + "'");
 044                usage();
 045                return 1;
 46            }
 47        }
 48
 149        var serviceManagerImpl = new ServiceManagerI(communicator, args);
 150        return serviceManagerImpl.run();
 51    }
 52
 53    public static int Main(string[] args)
 54    {
 155        int status = 0;
 56
 157        var initData = new Ice.InitializationData
 158        {
 159            properties = new Ice.Properties(ref args, new Ice.Properties(["IceBox"]))
 160        };
 161        initData.properties.setProperty("Ice.Admin.DelayCreation", "1");
 62
 63        try
 64        {
 165            using Ice.Communicator communicator = Ice.Util.initialize(initData);
 166            Console.CancelKeyPress += (sender, eventArgs) =>
 167            {
 068                eventArgs.Cancel = true;
 069                communicator.shutdown();
 070            };
 71
 172            status = run(communicator, args);
 173        }
 074        catch (Exception ex)
 75        {
 076            Console.Error.WriteLine(ex);
 077            status = 1;
 078        }
 79
 180        return status;
 81    }
 82}