コード例 #1
0
 /// <summary>
 ///     Create Nodeprep profile
 /// </summary>
 /// <returns>Nodeprep process</returns>
 public static IPreparationProcess Create()
 {
     return(PreparationProcess.Build()
            .WithMappingStep(MappingTable.Build()
                             .WithMappingTable(Mapping.B_1)
                             .WithMappingTable(Mapping.B_2)
                             .Compile())
            .WithNormalizationStep()
            .WithProhibitedValueStep(ValueRangeTable.Create(
                                         Prohibited.C_1_1,
                                         Prohibited.C_1_2,
                                         Prohibited.C_2_1,
                                         Prohibited.C_2_2,
                                         Prohibited.C_3,
                                         Prohibited.C_4,
                                         Prohibited.C_5,
                                         Prohibited.C_6,
                                         Prohibited.C_7,
                                         Prohibited.C_8,
                                         Prohibited.C_9,
                                         NodeprepProhibited))
            .WithBidirectionalStep()
            .WithProhibitedValueStep(ValueRangeTable.Create(
                                         Unassigned.A_1))
            .Compile());
 }
コード例 #2
0
 public BidirectionalStepTest()
 {
     _step = new BidirectionalStep(
         ValueRangeTable.Create(Prohibited.C8),
         ValueRangeTable.Create(BidirectionalTables.D1),
         ValueRangeTable.Create(BidirectionalTables.D2));
 }
コード例 #3
0
        public void WillThrowForMixedRALAndLCharacters()
        {
            var input = "" + Convert.ToChar(0x05BE) + Convert.ToChar(0x0041);
            var step  = new BidirectionalStep(
                ValueRangeTable.Create(Prohibited.C_8),
                ValueRangeTable.Create(Bidirectional.D_1),
                ValueRangeTable.Create(Bidirectional.D_2));

            Assert.Throws <BidirectionalFormatException>(() => step.Run(input));
        }
コード例 #4
0
        public void WillThrowForRALStringNotEndingWithRALCharacter()
        {
            var input = "" + Convert.ToChar(0x0627) + "1";
            var step  = new BidirectionalStep(
                ValueRangeTable.Create(Prohibited.C_8),
                ValueRangeTable.Create(Bidirectional.D_1),
                ValueRangeTable.Create(Bidirectional.D_2));

            Assert.Throws <BidirectionalFormatException>(() => step.Run(input));
        }
コード例 #5
0
        public void WillThrowForProhibitValues()
        {
            var input = Convert.ToChar(0x0340).ToString();
            var step  = new BidirectionalStep(
                ValueRangeTable.Create(Prohibited.C_8),
                ValueRangeTable.Create(Bidirectional.D_1),
                ValueRangeTable.Create(Bidirectional.D_2));

            Assert.Throws <ProhibitedValueException>(() => step.Run(input));
        }
コード例 #6
0
        public void WillPassForRALStringEndingWithRALCharacter()
        {
            var input = "" + Convert.ToChar(0x0627) + "1" + Convert.ToChar(0x0628);
            var step  = new BidirectionalStep(
                ValueRangeTable.Create(Prohibited.C_8),
                ValueRangeTable.Create(Bidirectional.D_1),
                ValueRangeTable.Create(Bidirectional.D_2));
            var output = step.Run(input);

            Assert.Equal(input, output);
        }
コード例 #7
0
ファイル: PreparationProcess.cs プロジェクト: pihi/stringprep
 public static IPreparationProcess Create()
 {
     return(StringPrep.PreparationProcess.Build()
            .WithMappingStep(MappingTable.Build()
                             .WithValueRangeTable(Prohibited.ASCIISpaceCharacters, ' ')
                             .WithMappingTable(Mapping.MappedToNothing)
                             .Compile())
            .WithNormalizationStep()
            .WithProhibitedValueStep(ValueRangeTable.Create(
                                         Prohibited.NonASCIISpaceCharacters,
                                         Prohibited.ASCIIControlCharacters,
                                         Prohibited.NonASCIIControlCharacters,
                                         Prohibited.PrivateUseCharacters,
                                         Prohibited.NonCharacterCodePoints,
                                         Prohibited.SurrogateCodePoints,
                                         Prohibited.InappropriateForPlainText,
                                         Prohibited.InappropriateForCanonicalRepresentation,
                                         Prohibited.TaggingCharacters))
            .WithBidirectionalStep()
            .WithProhibitedValueStep(ValueRangeTable.Create(
                                         Unassigned.UnassignedCodePoints))
            .Compile());
 }