예제 #1
0
        protected override void ProcessRecord()
        {
            var cols = CollationCollection.GetCollations(SmoContext.Connection);

            this.FilterByName(ref cols);
            this.FilterByLocaleId(ref cols);
            this.FilterByVersion(ref cols);

            if (this.MyInvocation.BoundParameters.ContainsKey("SortBy"))
            {
                this.Sort(ref cols);
            }

            WriteObject(cols, true);
        }
예제 #2
0
        public void TestCollation()
        {
            Type colType = typeof(Collation);
            Type colCol  = typeof(CollationCollection);

            // Test constructors
            ConstructorInfo[] constrs = colType.GetConstructors();
            Assert.IsTrue(constrs.Length > 0 &&
                          constrs.Any(
                              x => x.GetParameters().First(
                                  p => p.ParameterType.Equals(DRTYPE)) != null));

            // Test properties can be set.
            Assert.IsTrue(colType.GetProperties(FLAGS).All(x => x.CanWrite));

            Context.Validate();

            var cols = CollationCollection.GetCollations(Context.Connection);

            Assert.IsNotNull(cols);
            Assert.IsInstanceOfType(cols[0], colType);
            if (cols.Count > 1)
            {
                cols.SortByName();
                Assert.IsTrue(cols[0].Name.CompareTo(cols[1].Name) < 0);

                cols.SortByName(true);
                Assert.IsTrue(cols[0].Name.CompareTo(cols[1].Name) > 0);

                Assert.IsInstanceOfType(cols.Clone(), colCol);
                Assert.IsNotNull(cols.Find(x => x.Name.Equals(TEST_COLLATION, StringComparison.CurrentCultureIgnoreCase)));
                Assert.IsTrue(cols.FindAll(x => x.LocaleID.Equals(1033)).Count > 0);
                var newCol = cols.FindByLocaleID(1033);
                Assert.IsNotNull(newCol);
                Assert.IsTrue(newCol.Count > 0);
                Assert.IsInstanceOfType(newCol, colCol);
            }

            Assert.IsNotNull(CollationCollection.GetCollations(Context.Connection, CollationVersion.Version80));
            Assert.IsNotNull(CollationCollection.GetCollations(Context.Connection, 1033));
            Assert.IsNotNull(CollationCollection.GetCollations(Context.Connection, 1033, CollationVersion.Version80));
        }