Exemplo n.º 1
0
        private void Display(ICheck check)
        {
            if (check is GroupCheck)
            {
                foreach (ICheck ck in check as GroupCheck)
                {
                    Display(ck);
                }
            }
            else if (check is CodeCheck)
            {
                cbxCode.SelectedValue = (check as CodeCheck).Expected;
            }
            else if (check is MessageTypeCheck)
            {
                cbxType.SelectedValue = (check as MessageTypeCheck).Expected;
            }
            else if (check is MessageIDCheck)
            {
                checkMessageIdMatch.Checked = true;
            }
            else if (check is PayLoadStringCheck)
            {
                checkPayLoad.Checked = true;
                txtPayLoad.Text      = (check as PayLoadStringCheck).Expected;
            }
            else if (check is PayLoadByteCheck)
            {
                checkPayLoad.Checked = true;
                txtPayLoad.Text      = Utils.ToHexString((check as PayLoadByteCheck).Expected);
            }
            else if (check is TokenStringCheck)
            {
                checkToken.Checked = true;
                txtToken.Text      = (check as TokenStringCheck).Expected;
            }
            else if (check is TokenByteCheck)
            {
                checkToken.Checked = true;
                txtToken.Text      = Utils.ToHexString((check as TokenByteCheck).Expected);
            }
            else if (check is TokenExistCheck)
            {
                checkToken.Checked = true;
            }
            else if (check is PayLoadExistCheck)
            {
                checkPayLoad.Checked = true;
            }
            else if (check is OptionCheck)
            {
                OptionCheck oc = check as OptionCheck;
                if (_optionControlMap.ContainsKey(oc.OptionType))
                {
                    Tuple <CheckBox, Control> tuple = _optionControlMap[oc.OptionType];
                    tuple.Item1.Checked = true;
                    if (tuple.Item2 is ComboBox)
                    {
                        if (oc.IntValue.HasValue)
                        {
                            (tuple.Item2 as ComboBox).SelectedValue = oc.IntValue;
                        }
                    }
                    else if (tuple.Item2 is TextBox)
                    {
                        TextBox tbx = tuple.Item2 as TextBox;
                        switch (oc.OptionType)
                        {
                        case OptionType.ETag:
                            tbx.Text = oc.RawValue == null ? oc.StringValue : Utils.ToHexString(oc.RawValue);
                            break;

                        case OptionType.IfMatch:
                        case OptionType.LocationPath:
                        case OptionType.LocationQuery:
                        case OptionType.ProxyUri:
                        case OptionType.UriHost:
                        case OptionType.UriPath:
                        case OptionType.UriQuery:
                            tbx.Text = oc.StringValue;
                            break;

                        case OptionType.Block1:
                        case OptionType.Block2:
                        case OptionType.MaxAge:
                        case OptionType.UriPort:
                        case OptionType.Observe:
                            tbx.Text = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                            break;

                        case OptionType.Token:
                            tbx.Text = oc.RawValue == null ? oc.StringValue : Utils.ToHexString(oc.RawValue);
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void BuildTestCaseResponse(ICheck check, TestCaseResponse tcResponse)
        {
            if (check is CodeCheck)
            {
                tcResponse.Code = (check as CodeCheck).Expected.ToString();
            }
            else if (check is MessageTypeCheck)
            {
                tcResponse.MessageType = (check as MessageTypeCheck).Expected.ToString();
            }
            else if (check is MessageIDCheck)
            {
                tcResponse.SameMID = "true".ToUpper();
            }
            else if (check is PayLoadStringCheck)
            {
                tcResponse.PayLoad = (check as PayLoadStringCheck).Expected.ToString();
            }
            else if (check is PayLoadByteCheck)
            {
                tcResponse.PayLoad = Utils.ToHexString((check as PayLoadByteCheck).Expected);
            }
            else if (check is TokenByteCheck)
            {
                tcResponse.Token = Utils.ToHexString((check as TokenByteCheck).Expected);
            }
            else if (check is TokenStringCheck)
            {
                tcResponse.Token = (check as TokenStringCheck).Expected.ToString();
            }
            else if (check is TokenExistCheck)
            {
                tcResponse.Token = "";
            }
            else if (check is PayLoadExistCheck)
            {
                tcResponse.PayLoad = "";
            }
            else if (check is OptionCheck)
            {
                OptionCheck oc = check as OptionCheck;
                switch (oc.OptionType)
                {
                case OptionType.LocationPath:

                    tcResponse.OptionType.Location_Path = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.LocationQuery:
                    tcResponse.OptionType.Location_Query = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.Observe:
                    tcResponse.OptionType.Observe = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                //case OptionType.Token:
                //    tcResponse.Token = oc.RawValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : Utils.ToHexString(oc.RawValue);
                //    break;
                case OptionType.Accept:
                    tcResponse.OptionType.Accept = oc.IntValue.ToString();
                    break;

                case OptionType.Block1:
                    tcResponse.OptionType.Block1 = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                case OptionType.Block2:
                    tcResponse.OptionType.Block2 = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                case OptionType.ContentType:
                    tcResponse.OptionType.Content_Format = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                case OptionType.ETag:
                    tcResponse.OptionType.ETag = oc.RawValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : Utils.ToHexString(oc.RawValue);
                    break;

                case OptionType.IfMatch:
                    tcResponse.OptionType.If_Match = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.IfNoneMatch:
                    tcResponse.OptionType.If_None_Match = "TRUE";
                    break;

                case OptionType.MaxAge:
                    tcResponse.OptionType.Max_Age = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                case OptionType.ProxyScheme:
                    tcResponse.OptionType.Proxy_Scheme = "TRUE";
                    break;

                case OptionType.ProxyUri:
                    tcResponse.OptionType.Proxy_Uri = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.UriHost:
                    tcResponse.OptionType.Uri_Host = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.UriPath:
                    tcResponse.OptionType.UriPath = oc.StringValue == null ? "" : oc.StringValue;
                    break;

                case OptionType.UriPort:
                    tcResponse.OptionType.Uri_Port = oc.IntValue == null ? (oc.StringValue == null ? "" : oc.StringValue) : oc.IntValue.ToString();
                    break;

                case OptionType.UriQuery:
                    tcResponse.OptionType.UriQuery = oc.StringValue == null ? "" : oc.StringValue;
                    break;
                }
            }
        }