예제 #1
0
        public UserSearch ToUserSearch()
        {
            UserSearchBuilder builder = new UserSearchBuilder();

            if (null != Name)
            {
                builder.SetName(Name);
            }
            if (null != Comment)
            {
                builder.SetComment(Comment);
            }
            if (null != Home)
            {
                builder.SetHome(Home);
            }
            if (null != Shell)
            {
                builder.SetShell(Shell);
            }
            if (null != UID)
            {
                if (uint.TryParse(UID, out uint uid))
                {
                    builder.SetUID(uid);
                }
                else
                {
                    throw new HardFailureException(
                              "The UID is limited to an unsigned integer value. " +
                              "Please confirm that you are sending the correct values to the service " +
                              "Recevied: " + ParameterChecker.IsNull(UID));
                }
            }
            if (null != GID)
            {
                if (uint.TryParse(GID, out uint gid))
                {
                    builder.SetGID(gid);
                }
                else
                {
                    throw new HardFailureException(
                              "The GID is limited to an unsigned integer value. " +
                              "Please confirm that you are sending the correct values to the service " +
                              "Recevied: " + ParameterChecker.IsNull(GID));
                }
            }

            return(builder.Build());
        }
예제 #2
0
        public void Test_UserSearchBuilder()
        {
            UserSearchBuilder builderCommentTest = new UserSearchBuilder();

            evaluate(
                builderCommentTest.SetComment("comment")
                .Build()
                .Comment.Equals("comment"),
                "builderCommentTest.SetComment",
                "The Comment should be set",
                builderCommentTest.Build().Comment,
                "comment");

            UserSearchBuilder builderGIDTest = new UserSearchBuilder();

            evaluate(
                builderGIDTest.SetGID(99)
                .Build()
                .GID == 99,
                "builderGIDTest.SetGID",
                "The GID should be set",
                builderGIDTest.Build().GID.ToString(),
                "99");

            UserSearchBuilder builderNameTest = new UserSearchBuilder();

            evaluate(
                builderNameTest.SetName("cory wixom")
                .Build()
                .Name == "cory wixom",
                "builderNameTest.SetName",
                "The Name should be set",
                builderNameTest.Build().Name.ToString(),
                "cory wixom");

            UserSearchBuilder builderUIDTest = new UserSearchBuilder();

            evaluate(
                builderUIDTest.SetUID(89)
                .Build()
                .UID == 89,
                "builderUIDTest.SetUID",
                "The UID should be set",
                builderUIDTest.Build().UID.ToString(),
                "89");

            UserSearchBuilder builderShellTest = new UserSearchBuilder();

            evaluate(
                builderShellTest.SetShell("/shell/test")
                .Build()
                .Shell == "/shell/test",
                "builderShellTest.SetShell",
                "The Shell should be set",
                builderShellTest.Build().Shell.ToString(),
                "/shell/test");

            UserSearchBuilder builderHomeTest = new UserSearchBuilder();

            evaluate(
                builderHomeTest.SetHome("/home/test")
                .Build()
                .Home == "/home/test",
                "builderHomeTest.SetShell",
                "The Home should be set",
                builderHomeTest.Build().Home.ToString(),
                "/home/test");
        }