예제 #1
0
        private static void Covid19Test()
        {
            IObservationService observationService = new FakeObservationService();

            var observations = observationService.Get();

            foreach (Observation observation in observations)
            {
                Console.WriteLine(observation);

                if (observation.Country == "Poland" && observation.Confirmed > 30)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine($"Poland ALERT");
                    Console.ResetColor();
                }

                if (observation.Country == "Germany" && observation.Confirmed > 10)
                {
                    Console.BackgroundColor = ConsoleColor.Green;
                    Console.WriteLine($"Germany ALERT");
                    Console.ResetColor();
                }
            }
        }
예제 #2
0
        public static void Test()
        {
            ReplaySubject <Observation> subject = new ReplaySubject <Observation>();

            IObservationService observationService = new FakeObservationService();

            var lastSubject = subject
                              .Where(o => o.Country == "Poland")
                              .Take(2);

            foreach (var observation in observationService.Get())
            {
                subject.OnNext(observation);
            }

            lastSubject.Subscribe(o => Console.WriteLine(o));
        }