Esempio n. 1
0
 private void CheckParams(Options.ChecksumOpt expected, Options.ChecksumOpt obtained
                          )
 {
     Assert.Equal(expected.GetChecksumType(), obtained.GetChecksumType
                      ());
     Assert.Equal(expected.GetBytesPerChecksum(), obtained.GetBytesPerChecksum
                      ());
 }
Esempio n. 2
0
            /// <summary>
            /// A helper method for processing user input and default value to
            /// create a combined checksum option.
            /// </summary>
            /// <remarks>
            /// A helper method for processing user input and default value to
            /// create a combined checksum option. This is a bit complicated because
            /// bytesPerChecksum is kept for backward compatibility.
            /// </remarks>
            /// <param name="defaultOpt">Default checksum option</param>
            /// <param name="userOpt">User-specified checksum option. Ignored if null.</param>
            /// <param name="userBytesPerChecksum">
            /// User-specified bytesPerChecksum
            /// Ignored if &lt; 0.
            /// </param>
            public static Options.ChecksumOpt ProcessChecksumOpt(Options.ChecksumOpt defaultOpt
                                                                 , Options.ChecksumOpt userOpt, int userBytesPerChecksum)
            {
                bool useDefaultType;

                DataChecksum.Type type;
                if (userOpt != null && userOpt.GetChecksumType() != DataChecksum.Type.Default)
                {
                    useDefaultType = false;
                    type           = userOpt.GetChecksumType();
                }
                else
                {
                    useDefaultType = true;
                    type           = defaultOpt.GetChecksumType();
                }
                //  bytesPerChecksum - order of preference
                //    user specified value in bytesPerChecksum
                //    user specified value in checksumOpt
                //    default.
                if (userBytesPerChecksum > 0)
                {
                    return(new Options.ChecksumOpt(type, userBytesPerChecksum));
                }
                else
                {
                    if (userOpt != null && userOpt.GetBytesPerChecksum() > 0)
                    {
                        return(!useDefaultType ? userOpt : new Options.ChecksumOpt(type, userOpt.GetBytesPerChecksum
                                                                                       ()));
                    }
                    else
                    {
                        return(useDefaultType ? defaultOpt : new Options.ChecksumOpt(type, defaultOpt.GetBytesPerChecksum
                                                                                         ()));
                    }
                }
            }
Esempio n. 3
0
 private void CheckParams(DataChecksum.Type type, int bpc, Options.ChecksumOpt obtained
                          )
 {
     Assert.Equal(type, obtained.GetChecksumType());
     Assert.Equal(bpc, obtained.GetBytesPerChecksum());
 }