Ejemplo n.º 1
0
        public void Execute_Numeric_TwoElements()
        {
            var resolvers = new List <IScalarResolver>()
            {
                new LiteralScalarResolver <decimal>(10),
                new LiteralScalarResolver <decimal>(11),
                new LiteralScalarResolver <decimal>(12),
                new LiteralScalarResolver <decimal>(13),
            };
            var innerArgs     = new ListSequenceResolverArgs(resolvers);
            var innerResolver = new ListSequenceResolver <decimal>(innerArgs);
            var predicate     = new NumericModulo(false, 2, new LiteralScalarResolver <decimal>(0));
            var args          = new FilterSequenceResolverArgs(innerResolver, predicate, null);

            var resolver = new FilterSequenceResolver <decimal>(args);
            var elements = resolver.Execute();

            Assert.That(elements.Count(), Is.EqualTo(2));
            Assert.That(elements, Has.Member(10));
            Assert.That(elements, Has.Member(12));
        }
Ejemplo n.º 2
0
        public void Execute_DateTime_TwoElements()
        {
            var resolvers = new List <IScalarResolver>()
            {
                new LiteralScalarResolver <string>("2014-01-01"),
                new LiteralScalarResolver <string>("2015-01-01"),
                new LiteralScalarResolver <string>("2016-01-01"),
                new LiteralScalarResolver <string>("2017-01-01"),
            };
            var innerArgs      = new ListSequenceResolverArgs(resolvers);
            var innerResolver  = new ListSequenceResolver <DateTime>(innerArgs);
            var predicate      = new DateTimeMoreThan(false, new LiteralScalarResolver <DateTime>("2015-06-01"));
            var transformation = new NativeTransformer <DateTime>(new ServiceLocator(), null, new DateTimeToNextYear());
            var args           = new FilterSequenceResolverArgs(innerResolver, predicate, transformation);

            var resolver = new FilterSequenceResolver <DateTime>(args);
            var elements = resolver.Execute();

            Assert.That(elements.Count(), Is.EqualTo(3));
            Assert.That(elements, Has.Member(new DateTime(2015, 1, 1)));
            Assert.That(elements, Has.Member(new DateTime(2016, 1, 1)));
            Assert.That(elements, Has.Member(new DateTime(2017, 1, 1)));
        }