예제 #1
0
        public GroupSearch ToGroupSearch()
        {
            GroupSearchBuilder builder = new GroupSearchBuilder();

            if (null != Name)
            {
                builder.SetName(Name);
            }

            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));
                }
            }

            if (null != Member)
            {
                foreach (string member in Member)
                {
                    builder.AddMember(member);
                }
            }

            return(builder.Build());
        }
예제 #2
0
        public void Test_GroupSearchBuilder()
        {
            GroupSearchBuilder builderGIDTest = new GroupSearchBuilder();

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

            GroupSearchBuilder builderNameTest = new GroupSearchBuilder();

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

            GroupSearchBuilder builderMembersTest = new GroupSearchBuilder();

            evaluate(
                ParameterChecker.EqualsIncludeNullList(
                    builderMembersTest.AddMember("corywixom")
                    .Build()
                    .Members,
                    new string[] { "corywixom" }),
                "builderMembersTest.AddMember",
                "The member corywixom should be present",
                new ToStringHelper().Build("members", builderMembersTest.Build().Members).ToString(),
                "new string[] { corywixom }");

            evaluate(
                ParameterChecker.EqualsIncludeNullList(
                    builderMembersTest.AddMember("cory2wixom")
                    .Build()
                    .Members,
                    new string[] { "corywixom", "cory2wixom" }),
                "builderMembersTest.AddMember_2",
                "The member corywixom and cory2wixom should be present",
                new ToStringHelper().Build("members", builderMembersTest.Build().Members).ToString(),
                "new string[] { corywixom, cory2wixom }");

            evaluate(
                ParameterChecker.EqualsIncludeNullList(
                    builderMembersTest.AddMembers(new string[] { "cory3wixom", "cory4wixom" })
                    .Build()
                    .Members,
                    new string[] { "corywixom", "cory2wixom", "cory3wixom", "cory4wixom" }),
                "builderMembersTest.AddMembers",
                "The members should all be present",
                new ToStringHelper().Build("members", builderMembersTest.Build().Members).ToString(),
                "new string[] { corywixom, cory2wixom, cory3wixom, cory4wixom }");

            evaluate(
                ParameterChecker.EqualsIncludeNullList(
                    builderMembersTest.SetMembers(new string[] { "cory3wixom", "cory4wixom" })
                    .Build()
                    .Members,
                    new string[] { "cory3wixom", "cory4wixom" }),
                "builderMembersTest.SetMembers",
                "The members should all be present",
                new ToStringHelper().Build("members", builderMembersTest.Build().Members).ToString(),
                "new string[] { cory3wixom, cory4wixom }");
        }