public void GetGroupTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "ws_client";

            string targetGroup = "everyone";

            for (int i = 0; i < 2; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Group u = rep.GetGroup(targetGroup, null);

                        Assert.IsNotNull(u);
                        Assert.AreEqual(targetGroup, u.Id);

                        bool disconnected = con.Disconnect();
                        Assert.IsTrue(disconnected);

                        // connect as admin user Alex
                        con.UserName    = "******";
                        con.Client      = new Client();
                        con.Client.Name = "Alex_space";

                        connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        // create a group as admin user Alex
                        Group  group       = new Group();
                        string groupstring = "anotherGroup";
                        group.Id        = groupstring;
                        group.UserNames = new List <string> {
                            "Alice"
                        };
                        group.OwnerNames = new List <string> {
                            "Alex"
                        };
                        group.MaxResults = 9999;
                        rep.CreateGroup(group, new Options(GroupCmdFlags.AdminAdd));

                        // use the -A flag to get the group
                        GroupCmdOptions opts = new GroupCmdOptions(GroupCmdFlags.OwnerAccess);
                        Group           u2   = rep.GetGroup(groupstring, opts);

                        Assert.IsNotNull(u2);
                        Assert.AreEqual(groupstring, u2.Id);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void DeleteGroupTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            string targetGroup = "deleteme";

            for (int i = 0; i < 2; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 7, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Group u = new Group();
                        u.Id        = targetGroup;
                        u.UserNames = new List <string> {
                            "Alex"
                        };
                        u.OwnerNames = new List <string> {
                            "Alex"
                        };
                        u.MaxResults = 9999;

                        Group newGuy = rep.CreateGroup(u, null);

                        IList <Group> u2 = rep.GetGroups(new Options(GroupsCmdFlags.IncludeAllValues, 2));

                        Assert.IsNotNull(u2);
                        Assert.AreEqual(2, u2.Count);

                        rep.DeleteGroup(u, null);

                        u2 = rep.GetGroups(new Options(GroupsCmdFlags.IncludeAllValues, 2));

                        Assert.IsNotNull(u2);
                        Assert.AreEqual(1, u2.Count);

                        Group u3 = new Group();
                        u3.Id        = targetGroup;
                        u3.UserNames = new List <string> {
                            "Alex"
                        };
                        u3.OwnerNames = new List <string> {
                            "admin"
                        };
                        u3.MaxResults = 9999;

                        newGuy = rep.CreateGroup(u3, null);
                        try
                        {
                            Assert.Inconclusive("NewGuy {0}", newGuy.Id);
                        }
                        catch { }
                        if (newGuy == null)
                        {
                            P4CommandResult res = con.LastResults;

                            Assert.IsNotNull(res.ErrorList);
                            foreach (P4ClientError e in res.ErrorList)
                            {
                                Assert.Fail("CreateGroup returned null: {0}:{1}", e.ErrorCode, e.ErrorMessage);
                            }
                        }
                        Assert.IsNotNull(newGuy);

                        IList <Group> u4 = rep.GetGroups(new Options(GroupsCmdFlags.IncludeAllValues, 2));

                        Assert.IsNotNull(u4);
                        if (con.ApiLevel >= 38)
                        {
                            Assert.AreEqual(2, u4.Count);
                        }
                        else
                        {
                            Assert.AreEqual(1, u4.Count);
                        }
                        // delete the group when the user is an owner but not a superuser
                        GroupCmdOptions opts = new GroupCmdOptions(GroupCmdFlags.OwnerAccess);

                        rep.DeleteGroup(u3, opts);

                        u4 = rep.GetGroups(new Options(GroupsCmdFlags.IncludeAllValues, 2));

                        Assert.IsNotNull(u4);
                        Assert.AreEqual(1, u4.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }