예제 #1
0
        public void Favorite_Validate_ReturnsErrors()
        {
            var favorite = new Favorite();

            favorite.Protocol   = LongText.Substring(0, 11);
            favorite.ServerName = LongText;
            var results = this.validator.Validate(favorite);

            Assert.AreEqual(3, results.Count(), "Some properties arent validated properly for Favorite");
        }
예제 #2
0
        // Sets Text to a substring of LongText based on _placement and _curLen.
        private void CalcText()
        {
            if (LongText == null)
            {
                switch (EllipsisPlacement)
                {
                case EllipsisPlacement.Left:
                case EllipsisPlacement.Center:
                case EllipsisPlacement.Right:
                case EllipsisPlacement.Path:
                    SetText(LongText);
                    break;
                }

                return;
            }

            switch (EllipsisPlacement)
            {
            case EllipsisPlacement.Right:
                SetText(LongText.Substring(0, _curLen) + "\u2026");
                break;

            case EllipsisPlacement.Center:
                int firstLen  = _curLen / 2;
                int secondLen = _curLen - firstLen;
                SetText(LongText.Substring(0, firstLen) + "\u2026" + LongText.Substring(LongText.Length - secondLen));
                break;

            case EllipsisPlacement.Left:
                int start = LongText.Length - _curLen;
                SetText("\u2026" + LongText.Substring(start));
                break;

            case EllipsisPlacement.Path:
                var sb = new StringBuilder(_curLen + 1);
                PathCompactPathEx(sb, LongText, _curLen, 0);
                SetText(sb.ToString());
                break;

            default:
                throw new Exception("Unexpected switch value: " + EllipsisPlacement.ToString());
            }
        }
예제 #3
0
        private ValidationStates ValidateDbFavorite()
        {
            // created dbfavorite is not compleate, only necessary to make validable using IFavorite
            var favorite = new DbFavorite();

            favorite.ExecuteBeforeConnect = new DbBeforeConnectExecute();
            favorite.Security             = new DbSecurityOptions();
            favorite.Details.LoadFieldsFromReferences();

            favorite.Protocol   = LongText.Substring(0, 11);
            favorite.ServerName = LongText;
            favorite.Name       = LongText;
            favorite.Notes      = LongText;

            favorite.ExecuteBeforeConnect.Command          = LongText;
            favorite.ExecuteBeforeConnect.CommandArguments = LongText;
            favorite.ExecuteBeforeConnect.InitialDirectory = LongText;

            return(validator.Validate(favorite));
        }