Exemple #1
0
        public void SameObject()
        {
            var decorated       = new GrouperByTwoFieldsMock();
            var secondDecorated = new GrouperByTwoFieldsValidationDecorator(decorated);

            Assert.Throws(typeof(ArgumentException), () => { new GrouperByTwoFieldsValidationDecorator(secondDecorated); });
        }
Exemple #2
0
        public void SameField()
        {
            var source    = GenerateStorage;
            var decorated = new GrouperByTwoFieldsMock();
            var f1        = "Age";
            var f2        = "Age";

            var validator = new GrouperByTwoFieldsValidationDecorator(decorated);

            Assert.Throws(typeof(GrouperByTwoFieldsException), () => { validator.GroupByTwoFields(source, f1, f2, Aggregation); });

            Assert.Equal(0, decorated.CountOfCalling);
        }
Exemple #3
0
        public void CommonCase()
        {
            var fields = typeof(Person).GetRuntimeProperties().Where(e => e.CanRead).Select(e => e.Name);
            var pairs  = from f1 in fields
                         from f2 in fields
                         where f2 != f1
                         select new { f1, f2 };

            foreach (var iPair in pairs)
            {
                var source    = GenerateStorage;
                var decorated = new GrouperByTwoFieldsMock();

                var validator = new GrouperByTwoFieldsValidationDecorator(decorated);
                var result    = validator.GroupByTwoFields(source, iPair.f1, iPair.f2, Aggregation);

                Assert.Equal(decorated.LastReturned, result);
                Assert.Equal(1, decorated.CountOfCalling);
            }
        }