This class specifies the SpecializedKnowledge.
상속: StreamObject
예제 #1
0
        /// <summary>
        /// This method is used to test Specialized Knowledge related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param>
        /// <param name="site">Specify the ITestSite instance.</param>
        public void VerifySpecializedKnowledge(SpecializedKnowledge instance, ITestSite site)
        {
            // If the instance is not null and there are no parsing errors, then the Specialized Knowledge related adapter requirements can be directly captured.
            if (null == instance)
            {
                site.Assert.Fail("The instance of type SpecializedKnowledge is null due to parsing error or type casting error.");
            }

            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            // Capture requirement MS-FSSHTTPB_R362, if stream object start type is StreamObjectHeaderStart32bit.
            site.CaptureRequirementIfAreEqual <Type>(
                typeof(StreamObjectHeaderStart32bit),
                instance.StreamObjectHeaderStart.GetType(),
                "MS-FSSHTTPB",
                362,
                @"[In Specialized Knowledge] Specialized Knowledge Start (4 bytes): A 32-bit stream object header (section 2.2.1.5.2) that specifies A specialized knowledge start.");

            // Directly capture requirement MS-FSSHTTPB_R363, if there are no parsing errors.
            site.CaptureRequirement(
                "MS-FSSHTTPB",
                363,
                @"[In Specialized Knowledge] GUID (16 bytes): A GUID that specifies the type of specialized knowledge.");

            bool isVerifyR364 = instance.GUID == SpecializedKnowledge.CellKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.ContentTagKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.WaterlineKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.FragmentKnowledgeGuid;

            site.Log.Add(
                LogEntryKind.Debug,
                "Actual GUID value {0}, expect the value either 327A35F6-0761-4414-9686-51E900667A4D, 3A76E90E-8032-4D0C-B9DD-F3C65029433E, 0ABE4F35-01DF-4134-A24A-7C79F0859844 or 10091F13-C882-40FB-9886-6533F934C21D for MS-FSSHTTPB_R364.",
                instance.GUID.ToString());

            // Capture requirement MS-FSSHTTPB_R364, if the GUID equals the mentioned four values {327A35F6-0761-4414-9686-51E900667A4D}, {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, {0ABE4F35-01DF-4134-A24A-7C79F0859844}, {10091F13-C882-40FB-9886-6533F934C21D}.
            site.CaptureRequirementIfIsTrue(
                isVerifyR364,
                "MS-FSSHTTPB",
                364,
                @"[In Specialized Knowledge] The following GUIDs detail the type of knowledge contained: [Its value must be one of] {327A35F6-0761-4414-9686-51E900667A4D}, {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, {0ABE4F35-01DF-4134-A24A-7C79F0859844}, {10091F13-C882-40FB-9886-6533F934C21D}].");

            switch (instance.GUID.ToString("D").ToUpper(CultureInfo.CurrentCulture))
            {
            case "327A35F6-0761-4414-9686-51E900667A4D":

                // Capture requirement MS-FSSHTTPB_R365, if the knowledge data type is CellKnowledge.
                site.CaptureRequirementIfAreEqual <Type>(
                    typeof(CellKnowledge),
                    instance.SpecializedKnowledgeData.GetType(),
                    "MS-FSSHTTPB",
                    365,
                    @"[In Specialized Knowledge][If the GUID field is set to ] {327A35F6-0761-4414-9686-51E900667A4D}, [it indicates the type of the specialized knowledge is]Cell knowledge (section 2.2.1.13.2).");
                break;

            case "3A76E90E-8032-4D0C-B9DD-F3C65029433E":

                // Capture requirement MS-FSSHTTPB_R366, if the knowledge data type is WaterlineKnowledge.
                site.CaptureRequirementIfAreEqual <Type>(
                    typeof(WaterlineKnowledge),
                    instance.SpecializedKnowledgeData.GetType(),
                    "MS-FSSHTTPB",
                    366,
                    @"[In Specialized Knowledge][If the GUID field is set to ] {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, [it indicates the type of the specialized knowledge is]Waterline knowledge (section 2.2.1.13.4).");

                break;

            case "0ABE4F35-01DF-4134-A24A-7C79F0859844":

                // Capture requirement MS-FSSHTTPB_R367, if the knowledge data type is FragmentKnowledge.
                site.CaptureRequirementIfAreEqual <Type>(
                    typeof(FragmentKnowledge),
                    instance.SpecializedKnowledgeData.GetType(),
                    "MS-FSSHTTPB",
                    367,
                    @"[In Specialized Knowledge][If the GUID field is set to ] {0ABE4F35-01DF-4134-A24A-7C79F0859844}, [it indicates the type of the specialized knowledge is]Fragment knowledge (section 2.2.1.13.3).");

                break;

            case "10091F13-C882-40FB-9886-6533F934C21D":

                // Capture requirement MS-FSSHTTPB_R368, if the knowledge data type is ContentTagKnowledge.
                site.CaptureRequirementIfAreEqual <Type>(
                    typeof(ContentTagKnowledge),
                    instance.SpecializedKnowledgeData.GetType(),
                    "MS-FSSHTTPB",
                    368,
                    @"[In Specialized Knowledge][If the GUID field is set to ] {10091F13-C882-40FB-9886-6533F934C21D}, [it indicates the type of the specialized knowledge is]Content tag knowledge (section 2.2.1.13.5).");
                break;

            default:
                site.Assert.Fail("Unsupported specialized knowledge value " + instance.GUID.ToString());
                break;
            }

            // Directly capture requirement MS-FSSHTTPB_R369, if there are no parsing errors.
            site.CaptureRequirement(
                "MS-FSSHTTPB",
                369,
                @"[In Specialized Knowledge] Specialized Knowledge Data (variable): The data for the specific knowledge type.");

            // Verify the stream object header end related requirements.
            this.ExpectStreamObjectHeaderEnd(instance.StreamObjectHeaderEnd, instance.GetType(), site);
            this.ExpectCompoundObject(instance.StreamObjectHeaderStart, site);

            // Capture requirement MS-FSSHTTPB_R370, if the stream object end type is StreamObjectHeaderEnd16bit.
            site.CaptureRequirementIfAreEqual <Type>(
                typeof(StreamObjectHeaderEnd16bit),
                instance.StreamObjectHeaderEnd.GetType(),
                "MS-FSSHTTPB",
                370,
                @"[In Specialized Knowledge] Specialized Knowledge End (2 bytes): A 16-bit stream object header (section 2.2.1.5.4) that specifies specialized knowledge end.");
        }
        /// <summary>
        /// This method is used to test Specialized Knowledge related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param>
        /// <param name="site">Specify the ITestSite instance.</param>
        public void VerifySpecializedKnowledge(SpecializedKnowledge instance, ITestSite site)
        {
            // If the instance is not null and there are no parsing errors, then the Specialized Knowledge related adapter requirements can be directly captured.
            if (null == instance)
            {
                site.Assert.Fail("The instance of type SpecializedKnowledge is null due to parsing error or type casting error.");
            }

            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            // Capture requirement MS-FSSHTTPB_R362, if stream object start type is StreamObjectHeaderStart32bit. 
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderStart32bit),
                     instance.StreamObjectHeaderStart.GetType(),
                     "MS-FSSHTTPB",
                     362,
                     @"[In Specialized Knowledge] Specialized Knowledge Start (4 bytes): A 32-bit stream object header (section 2.2.1.5.2) that specifies A specialized knowledge start.");

            // Directly capture requirement MS-FSSHTTPB_R363, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     363,
                     @"[In Specialized Knowledge] GUID (16 bytes): A GUID that specifies the type of specialized knowledge.");

            bool isVerifyR364 = instance.GUID == SpecializedKnowledge.CellKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.ContentTagKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.WaterlineKnowledgeGuid ||
                                instance.GUID == SpecializedKnowledge.FragmentKnowledgeGuid;

            site.Log.Add(
                         LogEntryKind.Debug,
                        "Actual GUID value {0}, expect the value either 327A35F6-0761-4414-9686-51E900667A4D, 3A76E90E-8032-4D0C-B9DD-F3C65029433E, 0ABE4F35-01DF-4134-A24A-7C79F0859844 or 10091F13-C882-40FB-9886-6533F934C21D for MS-FSSHTTPB_R364.",
                         instance.GUID.ToString());

            // Capture requirement MS-FSSHTTPB_R364, if the GUID equals the mentioned four values {327A35F6-0761-4414-9686-51E900667A4D}, {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, {0ABE4F35-01DF-4134-A24A-7C79F0859844}, {10091F13-C882-40FB-9886-6533F934C21D}.
            site.CaptureRequirementIfIsTrue(
                     isVerifyR364,
                     "MS-FSSHTTPB",
                     364,
                     @"[In Specialized Knowledge] The following GUIDs detail the type of knowledge contained: [Its value must be one of] {327A35F6-0761-4414-9686-51E900667A4D}, {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, {0ABE4F35-01DF-4134-A24A-7C79F0859844}, {10091F13-C882-40FB-9886-6533F934C21D}].");

            switch (instance.GUID.ToString("D").ToUpper(CultureInfo.CurrentCulture))
            {
                case "327A35F6-0761-4414-9686-51E900667A4D":

                    // Capture requirement MS-FSSHTTPB_R365, if the knowledge data type is CellKnowledge.
                    site.CaptureRequirementIfAreEqual<Type>(
                             typeof(CellKnowledge),
                             instance.SpecializedKnowledgeData.GetType(),
                             "MS-FSSHTTPB",
                             365,
                             @"[In Specialized Knowledge][If the GUID field is set to ] {327A35F6-0761-4414-9686-51E900667A4D}, [it indicates the type of the specialized knowledge is]Cell knowledge (section 2.2.1.13.2).");
                    break;

                case "3A76E90E-8032-4D0C-B9DD-F3C65029433E":

                    // Capture requirement MS-FSSHTTPB_R366, if the knowledge data type is WaterlineKnowledge.
                    site.CaptureRequirementIfAreEqual<Type>(
                             typeof(WaterlineKnowledge),
                             instance.SpecializedKnowledgeData.GetType(),
                             "MS-FSSHTTPB",
                             366,
                             @"[In Specialized Knowledge][If the GUID field is set to ] {3A76E90E-8032-4D0C-B9DD-F3C65029433E}, [it indicates the type of the specialized knowledge is]Waterline knowledge (section 2.2.1.13.4).");

                    break;

                case "0ABE4F35-01DF-4134-A24A-7C79F0859844":

                    // Capture requirement MS-FSSHTTPB_R367, if the knowledge data type is FragmentKnowledge.
                    site.CaptureRequirementIfAreEqual<Type>(
                             typeof(FragmentKnowledge),
                             instance.SpecializedKnowledgeData.GetType(),
                             "MS-FSSHTTPB",
                             367,
                             @"[In Specialized Knowledge][If the GUID field is set to ] {0ABE4F35-01DF-4134-A24A-7C79F0859844}, [it indicates the type of the specialized knowledge is]Fragment knowledge (section 2.2.1.13.3).");

                    break;

                case "10091F13-C882-40FB-9886-6533F934C21D":

                    // Capture requirement MS-FSSHTTPB_R368, if the knowledge data type is ContentTagKnowledge.
                    site.CaptureRequirementIfAreEqual<Type>(
                             typeof(ContentTagKnowledge),
                             instance.SpecializedKnowledgeData.GetType(),
                             "MS-FSSHTTPB",
                             368,
                             @"[In Specialized Knowledge][If the GUID field is set to ] {10091F13-C882-40FB-9886-6533F934C21D}, [it indicates the type of the specialized knowledge is]Content tag knowledge (section 2.2.1.13.5).");
                    break;

                default:
                    site.Assert.Fail("Unsupported specialized knowledge value " + instance.GUID.ToString());
                    break;
            }

            // Directly capture requirement MS-FSSHTTPB_R369, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     369,
                     @"[In Specialized Knowledge] Specialized Knowledge Data (variable): The data for the specific knowledge type.");

            // Verify the stream object header end related requirements.
            this.ExpectStreamObjectHeaderEnd(instance.StreamObjectHeaderEnd, instance.GetType(), site);
            this.ExpectCompoundObject(instance.StreamObjectHeaderStart, site);

            // Capture requirement MS-FSSHTTPB_R370, if the stream object end type is StreamObjectHeaderEnd16bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderEnd16bit),
                     instance.StreamObjectHeaderEnd.GetType(),
                     "MS-FSSHTTPB",
                     370,
                     @"[In Specialized Knowledge] Specialized Knowledge End (2 bytes): A 16-bit stream object header (section 2.2.1.5.4) that specifies specialized knowledge end.");
        }