Beispiel #1
0
        public void GetAndSetFunc()
        {
            Assert.AreEqual(LengthOf, chain.Func);

            Gallio.Common.GallioFunc <string, int> func = x => 1;
            chain.Func = func;
            Assert.AreEqual(func, chain.Func);
        }
        public void NormalizeCollection_WhenCompareIsNull_Throws()
        {
            List <string> collection = null;

            Gallio.Common.GallioFunc <IList <string> > collectionFactory = () => new List <string>();
            Gallio.Common.GallioFunc <string, string>  normalize         = x => x + "*";
            EqualityComparison <string> compare = null;

            Assert.Throws <ArgumentNullException>(() => NormalizationUtils.NormalizeCollection <IList <string>, string>(
                                                      collection, collectionFactory, normalize, compare));
        }
        public void NormalizeCollection_WhenAllNormalizedValuesAreUnchanged_ReturnsTheSameCollection()
        {
            IList <string> collection = new[] { "abc", "def", "ghi" };

            Gallio.Common.GallioFunc <IList <string> > collectionFactory = () => new List <string>();
            Gallio.Common.GallioFunc <string, string>  normalize         = x => x;
            EqualityComparison <string> compare = ReferenceEquals;

            IList <string> normalizedCollection = NormalizationUtils.NormalizeCollection <IList <string>, string>(
                collection, collectionFactory, normalize, compare);

            Assert.AreSame(collection, normalizedCollection);
        }
        public void NormalizeCollection_WhenCollectionIsNull_ReturnsNull()
        {
            List <string> collection = null;

            Gallio.Common.GallioFunc <IList <string> > collectionFactory = () => new List <string>();
            Gallio.Common.GallioFunc <string, string>  normalize         = x => x + "*";
            EqualityComparison <string> compare = ReferenceEquals;

            IList <string> normalizedCollection = NormalizationUtils.NormalizeCollection <IList <string>, string>(
                collection, collectionFactory, normalize, compare);

            Assert.IsNull(normalizedCollection);
        }
        public void NormalizeCollection_WhenAllNormalizedValuesAreChanged_ReturnsANewCollectionOfNormalizedValues()
        {
            IList <string> collection = new[] { "abc", "def", "ghi" };

            Gallio.Common.GallioFunc <IList <string> > collectionFactory = () => new List <string>();
            Gallio.Common.GallioFunc <string, string>  normalize         = x => x + "*";
            EqualityComparison <string> compare = ReferenceEquals;

            IList <string> normalizedCollection = NormalizationUtils.NormalizeCollection <IList <string>, string>(
                collection, collectionFactory, normalize, compare);

            Assert.AreNotSame(collection, normalizedCollection);
            Assert.AreElementsEqual(new[] { "abc*", "def*", "ghi*" }, normalizedCollection);
        }