示例#1
0
        public void GetData()
        {
            using (var partManagementRepository = new PartManagementRepository())
            {
                IEnumerable <Part> parts;
                if (CurrentPage > 0)
                {
                    parts = partManagementRepository.GetPartsByPartialSkuPaged(PartSearchTextBox.Text, CurrentPage, Constants.DeafultPageSize);
                }
                else
                {
                    parts = partManagementRepository.GetPartsByPartialSku(PartSearchTextBox.Text);
                }

                var partsEventArgs = new GenericEventArgs <IEnumerable <Part> >();
                partsEventArgs.PayLoad = parts;

                if (OnPartsFound != null)
                {
                    PartsFound(partsEventArgs);
                }
            }
        }
        public void GetPartsByPartialSku_ReturnsPartsStartingWithMatchingSku()
        {
            // Arrange
            var dataContext = new BDataContext <PartsSiteDataContext>();

            dataContext.SetEmpty();

            BEntityList <Part> partsList = dataContext.SetOne("Parts",
                                                              new Part {
                SKU = "sku0"
            },
                                                              new Part {
                SKU = "1sku1"
            },
                                                              new Part {
                SKU = "2sku"
            });

            var target = new PartManagementRepository(dataContext);
            var parts  = new List <Part>(target.GetPartsByPartialSku("sku"));

            Assert.AreEqual(1, parts.Count);
            Assert.AreEqual(partsList.Entities[0], parts[0]);
        }