예제 #1
0
        public void when_connected_then_pulses_system_date_as_datetimeoffset()
        {
            var clock = new Subject<DateTimeOffset>();
            var stream = new EventStream();
            var converter = new ClockImpulses(Mock.Of<IClock>(x => x.Tick == clock));
            converter.Connect(stream);

            var tick = DateTimeOffset.Parse("2013/4/3 10:30:20-0300");
            var actual = DateTimeOffset.MinValue;

            stream.Of<IImpulse<DateTimeOffset>>().Where(x => x.Topic == Topics.System.Date).Subscribe(x => actual = x.Payload);

            clock.OnNext(tick);

            Assert.Equal(tick, actual);
        }
예제 #2
0
        public void when_connected_then_pulses_system_time_as_timespan()
        {
            var clock = new Subject<DateTimeOffset>();
            var stream = new EventStream();
            var converter = new ClockImpulses(Mock.Of<IClock>(x => x.Tick == clock));
            converter.Connect(stream);

            var actual = TimeSpan.Zero;
            var tick = DateTime.Parse("10:30:20");

            stream.Of<IImpulse<TimeSpan>>().Where(x => x.Topic == Topics.System.Time).Subscribe(x => actual = x.Payload);

            clock.OnNext(tick);

            Assert.Equal(new TimeSpan(tick.Hour, tick.Minute, tick.Second), actual);
        }
예제 #3
0
        public void when_connected_then_pulses_system_datetime_as_individual_components(string date, string topic, int expected)
        {
            var clock = new Subject<DateTimeOffset>();
            var stream = new EventStream();
            var converter = new ClockImpulses(Mock.Of<IClock>(x => x.Tick == clock));
            converter.Connect(stream);

            var tick = DateTime.Parse(date);
            var actual = 0;

            stream.Of<IImpulse<int>>().Where(x => x.Topic == topic).Subscribe(x => actual = x.Payload);

            clock.OnNext(tick);

            Assert.Equal(expected, actual);
        }