public GetGiftGuideListings ( int guideId, int offset, int limit, DetailLevel detailLevel ) : IAsyncResult | ||
guideId | int | Specify the numeric ID of a Gift Guide |
offset | int | To page through large result sets, set offset to a multiple of limit |
limit | int | Specify the number of results to return |
detailLevel | DetailLevel | Control how much information to return |
return | IAsyncResult |
public void GetGiftGuideListingsTest() { EtsyContext etsyContext = new EtsyContext(Constants.DummyEtsyApiKey); MockFixedDataRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(GetGiftGuidesRawResults); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); IGiftService etsyGiftService = new GiftService(etsyContext, dataRetriever); using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; etsyGiftService.GetGiftGuideListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyGiftService.GetGiftGuideListings(Constants.TestId, 0, 10, DetailLevel.Low); bool signalled = waitEvent.WaitOne(Constants.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); TestHelpers.CheckResultSuccess(result); } }
public void GetGiftGuideListingsBadGuideIdTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IGiftService giftService = new GiftService(new EtsyContext(NetsyData.EtsyApiKey)); giftService.GetGiftGuideListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT giftService.GetGiftGuideListings(NetsyData.TestBadGiftGuideId, 0, 10, DetailLevel.Low); bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); // check the data - should suceed without results Assert.IsNotNull(result); Assert.IsNotNull(result.ResultStatus); Assert.IsTrue(result.ResultStatus.Success); Assert.AreEqual(0, result.ResultValue.Count); } }
public void GetGiftGuidesMissingApiKeyTest() { // ARRANGE ResultEventArgs<Listings> result = null; IGiftService giftService = new GiftService(new EtsyContext(string.Empty)); giftService.GetGiftGuideListingsCompleted += (s, e) => result = e; // ACT giftService.GetGiftGuideListings(NetsyData.TestGiftGuideId, 0, 10, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }
/// <summary> /// Test gift guide retrieval at the given detail level /// </summary> /// <param name="detailLevel">the detail level</param> private static void TestGetGiftGuideListings(DetailLevel detailLevel) { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IGiftService giftService = new GiftService(new EtsyContext(NetsyData.EtsyApiKey)); giftService.GetGiftGuideListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT giftService.GetGiftGuideListings(NetsyData.TestGiftGuideId, 0, 10, detailLevel); bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); // check the data Assert.IsNotNull(result); TestHelpers.CheckResultSuccess(result); Assert.IsTrue(result.ResultValue.Count > 1); Assert.AreEqual(10, result.ResultValue.Results.Length); Assert.IsNotNull(result.ResultValue.Params); } }
public void GetGiftGuidesApiKeyInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IGiftService giftService = new GiftService(new EtsyContext("InvalidKey")); giftService.GetGiftGuideListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT giftService.GetGiftGuideListings(NetsyData.TestGiftGuideId, 0, 10, DetailLevel.Low); bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); // check the data - should fail Assert.IsNotNull(result); Assert.IsNotNull(result.ResultStatus); Assert.IsFalse(result.ResultStatus.Success); Assert.AreEqual(WebExceptionStatus.ProtocolError, result.ResultStatus.WebStatus); } }