Beispiel #1
0
        public static async Task DialogTask_Frame_Scoring_Throws_Out_Of_Range(double score)
        {
            var state    = new object();
            var item     = new Activity();
            var token    = new CancellationTokenSource().Token;
            var scorable = MockScorable(item, state, score, token);

            var        innerLoop     = new Mock <IEventLoop>();
            var        innerProducer = new Mock <IEventProducer <IActivity> >();
            var        queue         = new EventQueue <IActivity>();
            IEventLoop loop          = new ScoringEventLoop <double>(innerLoop.Object, innerProducer.Object, queue, new TraitsScorable <IActivity, double>(NormalizedTraits.Instance, Comparer <double> .Default, new[] { scorable.Object }));

            try
            {
                IEventProducer <IActivity> producer = queue;
                producer.Post(item);
                await loop.PollAsync(token);

                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            scorable.Verify();
        }
Beispiel #2
0
        public async Task DialogTask_Frame_Scoring_Stops_At_Maximum()
        {
            var state1    = new object();
            var item      = new Activity();
            var token     = new CancellationTokenSource().Token;
            var scorable1 = MockScorable(item, state1, 1.0, token);
            var scorable2 = new Mock <IScorable <object, double> >(MockBehavior.Strict);

            var        innerLoop     = new Mock <IEventLoop>();
            var        innerProducer = new Mock <IEventProducer <IActivity> >();
            var        queue         = new EventQueue <IActivity>();
            IEventLoop loop          = new ScoringEventLoop <double>(innerLoop.Object, innerProducer.Object, queue, new TraitsScorable <IActivity, double>(NormalizedTraits.Instance, Comparer <double> .Default, new[] { scorable1.Object, scorable2.Object }));

            scorable1
            .Setup(s => s.PostAsync(item, state1, token))
            .Returns(Task.FromResult(0));

            IEventProducer <IActivity> producer = queue;

            producer.Post(item);
            await loop.PollAsync(token);

            scorable1.Verify();
            scorable2.Verify();
        }
Beispiel #3
0
        public static async Task DialogTask_Frame_Scoring_Allows_Value(double score)
        {
            var state    = new object();
            var item     = new Activity();
            var token    = new CancellationTokenSource().Token;
            var scorable = MockScorable(item, state, score, token);

            var        innerLoop     = new Mock <IEventLoop>();
            var        innerProducer = new Mock <IEventProducer <IActivity> >();
            var        queue         = new EventQueue <IActivity>();
            IEventLoop loop          = new ScoringEventLoop <double>(innerLoop.Object, innerProducer.Object, queue, new TraitsScorable <IActivity, double>(NormalizedTraits.Instance, Comparer <double> .Default, new[] { scorable.Object }));

            scorable
            .Setup(s => s.PostAsync(item, state, token))
            .Returns(Task.FromResult(0));

            IEventProducer <IActivity> producer = queue;

            producer.Post(item);
            await loop.PollAsync(token);

            scorable.Verify();
        }