Example #1
0
        private IObservable <IEnumerable <string> > GetImages(SolidColorBrush color)
        {
            if (color == null)
            {
                return(Observable.Return(new string[0]));
            }

            string url = string.Format("http://labs.tineye.com/multicolr/rest/color_search/?limit=73&offset=0&colors[0]={0:x2}{1:x2}{2:x2}&weights[0]=1", color.Color.R, color.Color.G, color.Color.B);

            HttpClient http = new HttpClient();

            return(http.GetStringAsync(url)
                   .ToObservable()
                   .Catch <string, Exception>(e => Observable.Empty <string>())
                   .Select(str => JsonConvert.DeserializeObject <ImageList>(str).result)
                   .Select(images => images.Select(image => "http://img.tineye.com/flickr-images/?filepath=labs-flickr-public/images/" + image.filepath)));
        }
        public void OAPHShouldBeObservable()
        {
            (new TestScheduler()).With(sched => {
                var input = sched.CreateHotObservable(
                    sched.OnNextAt(100, 5),
                    sched.OnNextAt(200, 10),
                    sched.OnNextAt(300, 15),
                    sched.OnNextAt(400, 20)
                );

                var result = new List<string>();

                var inputOaph = new ObservableAsPropertyHelper<int>(input, x => { }, 0);
                var fixture = new ObservableAsPropertyHelper<string>(inputOaph.Select(x => x.ToString()),
                    result.Add, "0");

                sched.RunToMilliseconds(500);

                new[] {"0", "5", "10", "15", "20"}.AssertAreEqual(result);
            });
        }
        public void OAPHShouldBeObservable()
        {
            (new TestScheduler()).With(sched => {
                var input = sched.CreateHotObservable(
                    sched.OnNextAt(100, 5),
                    sched.OnNextAt(200, 10),
                    sched.OnNextAt(300, 15),
                    sched.OnNextAt(400, 20)
                    );

                var result = new List <string>();

                var inputOaph = new ObservableAsPropertyHelper <int>(input, x => { }, 0);
                var fixture   = new ObservableAsPropertyHelper <string>(inputOaph.Select(x => x.ToString()),
                                                                        result.Add, "0");

                sched.AdvanceToMs(500);

                new[] { "0", "5", "10", "15", "20" }.AssertAreEqual(result);
            });
        }