Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            var service = new FlickrImageService();
            DataContext = new FlickrSearchViewModel(service);
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            var service = new FlickrImageService();

            DataContext = new FlickrSearchViewModel(service);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var service = new FlickrImageService();

            ViewModel = new FlickrSearchViewModel(service);

            // Load views
            SearchText   = FindViewById <EditText> (Resource.Id.searchText);
            SearchButton = FindViewById <Button>(Resource.Id.searchButton);
            ImagesList   = FindViewById <ListView> (Resource.Id.imagesList);

            // Set up bindings
            this.Bind(ViewModel, vm => vm.SearchText, v => v.SearchText.Text);
            this.OneWayBind(ViewModel, vm => vm.CanEnterSearchText, v => v.SearchText.Enabled);
            this.BindCommand(ViewModel, vm => vm.Search, v => v.SearchButton);

            // Configure list adapter
            var adapter = new ReactiveListAdapter <SearchResultViewModel>(
                ViewModel.Images,
                (viewModel, parent) => new ImageItemView(viewModel, this, parent));

            ImagesList.Adapter = adapter;

            // Set up animations
            var loadingAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.loading_rotate);

            loadingAnimation.RepeatCount = Animation.Infinite;
            loadingAnimation.RepeatMode  = RepeatMode.Restart;

            this.WhenAnyValue(v => v.ViewModel.IsLoading)
            .Subscribe(isLoading => {
                if (loadingItem != null)
                {
                    if (isLoading)
                    {
                        loadingView.StartAnimation(loadingAnimation);
                    }
                    else
                    {
                        loadingView.ClearAnimation();
                    }

                    loadingItem.SetVisible(isLoading);
                }
            });

            this.WhenAnyValue(v => v.ViewModel.ShowError)
            .Where(x => x)
            .Subscribe(showError => {
                Toast.MakeText(this, "Could not load image data", ToastLength.Long)
                .Show();
            });
        }
Ejemplo n.º 4
0
        public void ConstructFlikrImageService_GivenEmptyString_ShouldBuildFlikrImageService()
        {
            //---------------Set up test pack-------------------
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var flickrImageService = new FlickrImageService();
            //---------------Test Result -----------------------
            Assert.IsNotNull(flickrImageService);
        }
Ejemplo n.º 5
0
        public void ConstructFlikrImageService_GivenEmptyString_ShouldBuildFlikrImageService()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var flickrImageService = new FlickrImageService();

            //---------------Test Result -----------------------
            Assert.IsNotNull(flickrImageService);
        }
Ejemplo n.º 6
0
        public async void GetImages_GivenSearchTerm_ShouldReturnGreaterThan0()
        {
            //---------------Set up test pack-------------------
            var flickrImageService = new FlickrImageService();
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            //var searchResultViewModel = await flickrImageService.GetImages("cats");
            //Assert.IsNotNull(searchResultViewModel);
            var flickrSearchViewModel = new FlickrSearchViewModel(flickrImageService);
            flickrSearchViewModel.Search.Subscribe(x => Debug.WriteLine("*****\n"+x.Title),
                () => Debug.WriteLine("Sequence Completed."));

            await flickrSearchViewModel.Search.ExecuteAsync();
            //---------------Test Result -----------------------
            Assert.IsTrue(flickrSearchViewModel.Images.Count > 0);
        }
Ejemplo n.º 7
0
        public async void GetImages_GivenSearchTerm_ShouldReturnGreaterThan0()
        {
            //---------------Set up test pack-------------------
            var flickrImageService = new FlickrImageService();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            //var searchResultViewModel = await flickrImageService.GetImages("cats");
            //Assert.IsNotNull(searchResultViewModel);
            var flickrSearchViewModel = new FlickrSearchViewModel(flickrImageService);

            flickrSearchViewModel.Search.Subscribe(x => Debug.WriteLine("*****\n" + x.Title),
                                                   () => Debug.WriteLine("Sequence Completed."));

            await flickrSearchViewModel.Search.ExecuteAsync();

            //---------------Test Result -----------------------
            Assert.IsTrue(flickrSearchViewModel.Images.Count > 0);
        }
Ejemplo n.º 8
0
        private void LoadViewModel()
        {
            var service = new FlickrImageService();

            ViewModel = new FlickrSearchViewModel(service);
        }