CopyItemToShoppingList() public method

public CopyItemToShoppingList ( Item item ) : void
item Item
return void
コード例 #1
0
        public void Copy_Item_To_Shopping_List()
        {
            // Arrange
            var shoppingService = new ShoppingService(_sqliteConnection);
            var vm = new PastPurchasesViewModel(shoppingService);
            var itemTitle = "item1";
            var item = new BoughtItem(itemTitle);
            vm.Add(item);

            // Act
            vm.CopyItemToShoppingList(item);

            // Assert
            Assert.Equal(1, shoppingService.Items.Count);
            Assert.Contains<Item>(shoppingService.Items, x => x.Title == itemTitle);
        }
コード例 #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            this._inflater = inflater;

            View view = inflater.Inflate(Resource.Layout.ic_tab_past_purchases, null);

            ViewModel = new PastPurchasesViewModel(ServiceRegistrar.ShoppingService(MainActivity.SqliteConnection));

            _pastPurchasesListView = view.FindViewById<ListView>(Resource.Id.PastPurchasesListView);

            _pastPurchasesListView.Adapter = ViewModel.Items.GetAdapter(GetItemView);

            _pastPurchasesListView.ItemClick += delegate (object sender, AdapterView.ItemClickEventArgs e)
            {
                ViewModel.CopyItemToShoppingList(this.ViewModel.Items.ElementAt(e.Position));
            };

            return view;
        }