private void DoneButton_Click(object sender, EventArgs e)
        {
            var searchModel = new SearchProductModel()
            {
                Brand     = this.BrandAutoCompleteTextView.Text,
                Price     = (this.PriceMinEditText.Text != "") ? (decimal?)decimal.Parse(this.PriceMinEditText.Text) : null,
                PriceTo   = (this.PriceMaxEditText.Text != "") ? (decimal?)decimal.Parse(this.PriceMaxEditText.Text) : null,
                RAM       = (this.RAMMinEditText.Text != "") ? (int?)int.Parse(this.RAMMinEditText.Text) : null,
                RAMTo     = (this.RAMMaxEditText.Text != "") ? (int?)int.Parse(this.RAMMaxEditText.Text) : null,
                Year      = (this.YearMinEditText.Text != "") ? (int?)int.Parse(this.YearMinEditText.Text) : null,
                YearTo    = (this.YearMaxEditText.Text != "") ? (int?)int.Parse(this.YearMaxEditText.Text) : null,
                Battery   = (this.BatteryMinEditText.Text != "") ? (int?)int.Parse(this.BatteryMinEditText.Text) : null,
                BatteryTo = (this.BatteryMaxEditText.Text != "") ? (int?)int.Parse(this.BatteryMaxEditText.Text) : null,
                Camera    = (this.CameraMinEditText.Text != "") ? (int?)int.Parse(this.CameraMinEditText.Text) : null,
                CameraTo  = (this.CameraMaxEditText.Text != "") ? (int?)int.Parse(this.CameraMaxEditText.Text) : null,
                Memory    = (this.MemoryMinEditText.Text != "") ? (int?)int.Parse(this.MemoryMinEditText.Text) : null,
                MemoryTo  = (this.MemoryMaxEditText.Text != "") ? (int?)int.Parse(this.MemoryMaxEditText.Text) : null,
            };

            try
            {
                var resource = ProductAPIController.SearchProduct(searchModel).Result;
                this.GridView.Adapter = new ProductsAdapter(this.context, resource, Resource.Layout.ProductAdapterItem);
            }
            catch (Exception)
            {
                throw;
            }

            this.Dismiss();
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            var view = inflater.Inflate(Resource.Layout.ProductFilterDialog, container, false);

            this.PriceMinEditText   = view.FindViewById <EditText>(Resource.Id.PriceMinEditText);
            this.PriceMaxEditText   = view.FindViewById <EditText>(Resource.Id.PriceMaxEditText);
            this.MemoryMinEditText  = view.FindViewById <EditText>(Resource.Id.MemoryMinEditText);
            this.MemoryMaxEditText  = view.FindViewById <EditText>(Resource.Id.MemoryMaxEditText);
            this.RAMMinEditText     = view.FindViewById <EditText>(Resource.Id.RAMMinEditText);
            this.RAMMaxEditText     = view.FindViewById <EditText>(Resource.Id.RAMMaxEditText);
            this.YearMinEditText    = view.FindViewById <EditText>(Resource.Id.YearMinEditText);
            this.YearMaxEditText    = view.FindViewById <EditText>(Resource.Id.YearMaxEditText);
            this.BatteryMinEditText = view.FindViewById <EditText>(Resource.Id.BatteryMinEditText);
            this.BatteryMaxEditText = view.FindViewById <EditText>(Resource.Id.BatteryMaxEditText);
            this.CameraMinEditText  = view.FindViewById <EditText>(Resource.Id.CameraMinEditText);
            this.CameraMaxEditText  = view.FindViewById <EditText>(Resource.Id.CameraMaxEditText);

            this.BrandAutoCompleteTextView = view.FindViewById <AutoCompleteTextView>(Resource.Id.BrandAutoCompleteTextView);
            var items   = ProductAPIController.GetBrands();
            var adapter = new ArrayAdapter(this.Context, Android.Resource.Layout.SimpleDropDownItem1Line, items);

            this.BrandAutoCompleteTextView.Adapter = adapter;

            this.DoneButton        = view.FindViewById <Button>(Resource.Id.DoneButton);
            this.DoneButton.Click += DoneButton_Click;
            return(view);
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            var GoTocartPageFloatingActionButton = FindViewById <FloatingActionButton>(Resource.Id.GoToCartPageButton);

            GoTocartPageFloatingActionButton.Click += GoToCartPage_Click;


            this.SearchView = FindViewById <SearchView>(Resource.Id.searchView);
            this.SearchView.QueryTextChange += SearchView_QueryTextChange;
            this.Products                    = ProductAPIController.GetProducts().Result;
            this.Adapter                     = new ProductsAdapter(this, this.Products, Resource.Layout.ProductAdapterItem);
            this.ProductsGridView            = FindViewById <GridView>(Resource.Id.ProductListView);
            this.ProductsGridView.ItemClick += ProductsGridView_ItemClick;
            this.FilterImageView             = FindViewById <ImageView>(Resource.Id.FilterImageView);
            this.FilterImageView.Click      += FilterImageView_Click;


            this.SortBySpiner               = FindViewById <Spinner>(Resource.Id.SortBySpiner);
            this.SortBySpiner.Adapter       = new ArrayAdapter(this, Android.Resource.Layout.SimpleExpandableListItem1, SearchByItems);
            this.SortBySpiner.ItemSelected += SortBySpiner_ItemSelected;



            this.ProductDescriptionActivityGenericTask = new Task <Intent>(() => new Intent(this, typeof(ProductDescriptionActivity)));
            this.ProductDescriptionActivityGenericTask.Start();
            this.CartActivityGenericTask = new Task <Intent>(() => new Intent(this, typeof(CartActivity)));
            this.CartActivityGenericTask.Start();
        }
        public void PutItem_ShouldFail_WhenDifferentID()
        {
            var controller = new ProductAPIController(new TestUnitTestMockingConext());

            var badresult = controller.PutItem(999, GetDemoItem());

            Assert.IsInstanceOfType(badresult, typeof(BadRequestResult));
        }
        public void GetAllData_ShouldCallGetAllData()
        {
            var mockRequest       = new Mock <IApiRequestSend <Product> >();
            var productController = new ProductAPIController(mockRequest.Object);

            var products = productController.GetAllProducts();

            mockRequest.Verify(m => m.GetAllData(), Times.Once());
        }
示例#6
0
        public void Delete()
        {
            // Arrange
            ProductAPIController controller = new ProductAPIController();

            // Act
            controller.Delete(5);

            // Assert
        }
示例#7
0
        public void Put()
        {
            // Arrange
            ProductAPIController controller = new ProductAPIController();

            // Act
            controller.Put(5, "value");

            // Assert
        }
示例#8
0
        public void GetById()
        {
            // Arrange
            ProductAPIController controller = new ProductAPIController();

            // Act
            ProductVM result = controller.Get(6);

            // Assert
            Assert.AreEqual("Product 1", result.Name);
        }
示例#9
0
        public void Get()
        {
            // Arrange
            ProductAPIController controller = new ProductAPIController();

            // Act
            IEnumerable <ProductVM> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(10, result.Count());
        }
        public void GetItem_ShouldReturnItemWithSameID()
        {
            var context = new TestUnitTestMockingConext();

            context.Items.Add(GetDemoProduct());

            var controller = new ProductAPIController(context);

            var result = controller.Get(3) as OkNegotiatedContentResult <Product>;

            Assert.IsNotNull(result);

            Assert.AreEqual(3, result.Content.ID);
        }
        public void PutItem_ShouldReturnStatusCode()
        {
            var controller = new ProductAPIController(new TestUnitTestMockingConext());

            var item = GetDemoProduct();

            var result = controller.Put(item.Id, item) as StatusCodeResult;

            Assert.IsNotNull(result);

            Assert.IsInstanceOfType(result, typeof(StatusCodeResult));

            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
        public void DeleteItem_ShouldReturnOK()
        {
            var context = new TestUnitTestMockingConext();

            var item = GetDemoProduct();

            context.Items.Add(item);

            var controller = new ProductAPIController(context);

            var result = controller.Delete(3) as OkNegotiatedContentResult <Product>;

            Assert.IsNotNull(result);

            Assert.AreEqual(item.ID, result.Content.Id);
        }
        public void GetItems_ShouldReturnAllItems()
        {
            var context = new TestUnitTestMockingConext();

            context.Items.Add(new Product {
                Id = 1, Name = "Demo1", Price = 20
            });

            context.Items.Add(new Product {
                Id = 2, Name = "Demo2", Price = 30
            });

            context.Items.Add(new Product {
                Id = 3, Name = "Demo3", Price = 40
            });

            var controller = new ProductAPIController(context);

            var result = controller.Get() as TestItemDbSet;

            Assert.IsNotNull(result);

            Assert.AreEqual(3, result.Local.Count);
        }