Пример #1
0
        public void ExecuteTheFavouriteCommandShouldChangeDealProperty()
        {
            var detailVm = new DetailDealVM(_mockNavigation.Object);

            detailVm.Favourite = false;
            detailVm.AddFavourite.Execute(null);
            detailVm.Favourite.Should().Be(true);
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.DealDetail);
            //get the deal from navigation params.
            var param = Nav.GetAndRemoveParameter <Deal>(Intent);

            //set the image
            Resources res       = Android.App.Application.Context.Resources;
            int       id        = (int)typeof(Resource.Drawable).GetField(param.ImageUrl).GetValue(null);
            ImageView imageView = (ImageView)FindViewById(Resource.Id.photo);

            imageView.TransitionName = Intent.GetStringExtra(param.ImageUrl);
            var myImage = BitmapFactory.DecodeResource(res, id);

            imageView.SetImageBitmap(myImage);

            //intialize view model and set value.
            detailDealVM             = ViewModelLocator.detailViewModel;
            detailDealVM.Title       = param.mCaption;
            detailDealVM.Description = param.mDesc;
            detailDealVM.Favourite   = param.mFav;
            detailDealVM.Price       = param.mPrice;
            detailDealVM.Done        = param.mDone;



            //Toggle the favourite button icon image.
            ToggleFavourite(detailDealVM.Favourite);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.SetBackgroundColor(Color.ParseColor("#d50000"));
            SetActionBar(toolbar);
            toolbar.SetNavigationIcon(Resource.Mipmap.ic_arrow_back);



            //set the command property on navigation button.
            toolbar.SetCommand("NavigationOnClick", detailDealVM.GoBackCommand);

            //Set the command property on button.
            MFavourite.SetCommand("Click", detailDealVM.AddFavourite);

            //set the command for buy now.
            MBuyNow.SetCommand("Click", detailDealVM.ShowDoneCommand);

            //Bind the view with viewmodel data and notification.
            BindView();
        }