示例#1
0
        public void BadId()
        {
            String [] dirtyStrings =
            {
                null,
                String.Empty,
                "",
                "12345678901a",
                "123456789012a",
                "a123456789012",
                "itm/123456789012a",
            };

            foreach (var dirtyString in dirtyStrings)
            {
                var id = new eBayItemIdCleaner(dirtyString);
                Assert.False(id.IsValid, dirtyString);
                Assert.True(id.Value == String.Empty, dirtyString);
            }
        }
示例#2
0
        public string Index(string msg)
        {
            eBayItemIdCleaner eBayItemId = new eBayItemIdCleaner(msg);

            if (eBayItemId.IsValid)
            {
                eBayItemDataHelper eBayItem = new eBayItemDataHelper(eBayItemId.Value);
                eBayItem.GeteBayItemDataHelperAsync();
                Item item = new Item(eBayItem);
                context.Item.Add(item);
                context.SaveChanges();
                Pulse newPulse = new Pulse(eBayItem, item);
                context.Pulse.Add(newPulse);
                context.SaveChanges();
                return(item.Id + ";" + item.Name + ";" + item.Pulses.LastOrDefault().Unix_Time.ConvertFromUnixTimestamp() + ";" + item.Pulses.LastOrDefault().Views.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
示例#3
0
        public void RightId()
        {
            const String rigthId = "123456789012";

            String [] dirtyStrings =
            {
                "123456789012",
                "https://www.ebay.com/itm/123456789012",
                "itm/123456789012",
                "https://www.ebay.com/itm/123456789012?_trksid=p2050601.m570.l5999&_trkparms=gh1g%3DI231988476336.N36.S1.R1.TR1",
                "itm/123456789012?_trksid=p2050601.m570.l5999",
                "https://www.ebay.com/itm/VELO-FAT-BIKE-26-x-4-00-ALUMINIUM-SHIMANO-21V-DOUBLE-DISQUE/123456789012?hash=item1c89f4727b:m:mnqC4Qyb9o4pxerFIjYZwrA",
                "https://www.ebay.co.uk/itm/CLASSIC-Heritage-Ladies-26-Wheel-7-Speed-Traditional-Bike-Bicycle-White/123456789012?hash=item48a20806b0:m:mLOeYl6dDTt_7zC2OL15_cQ",
                "https://www.ebay.com/p/Bicycle-Bike-Wall-Mount-Hanger-Hook-Storage-Steel-Holder-Garage-Rack-Stand-Black/1973734742?iid=123456789012&_trkparms=aid%3D555018%26algo%3DPL.SIM%26ao%3D2%26asc%3D50543%26meid%3D2c3fb513835342548b618f8d5983938e%26pid%3D100005%26rk%3D3%26rkt%3D12%26sd%3D332588994136%26itm%3D142765676766&_trksid=p2047675.c100005.m1851",
            };

            foreach (var dirtyString in dirtyStrings)
            {
                var    id           = new eBayItemIdCleaner(dirtyString);
                String errorMessage = String.Format("string: \"{0}\" id: \"{1}\"", dirtyString, id.Value);
                Assert.True(id.IsValid, "is not valid " + errorMessage);
                Assert.True(id.Value == rigthId, errorMessage);
            }
        }