public GetFeaturedDetails ( int userId, DetailLevel detailLevel ) : IAsyncResult | ||
userId | int | the user id |
detailLevel | DetailLevel | the level of detail |
Результат | IAsyncResult |
public void GetFeaturedDetailsApiKeyInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IShopService shopsService = new ShopService(new EtsyContext("InvalidKey")); shopsService.GetFeaturedDetailsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetFeaturedDetails(NetsyData.TestUserId, DetailLevel.Low); bool signalled = waitEvent.WaitOne(Constants.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); } }
public void GetFeaturedDetailsLowDetailTest() { // ARANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IShopService shopsService = new ShopService(new EtsyContext(NetsyData.EtsyApiKey)); shopsService.GetFeaturedDetailsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetFeaturedDetails(NetsyData.TestUserId, DetailLevel.Low); bool signalled = waitEvent.WaitOne(Constants.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); // check the data TestHelpers.CheckResultSuccess(result); Assert.IsNotNull(result.ResultValue.Results, "Results"); Assert.IsTrue(result.ResultStatus.Success, "Success"); Assert.IsTrue(result.ResultValue.Count > 0, "Count"); } }
public void GetFeaturedSellersMissingApiKeyTest() { // ARRANGE ResultEventArgs<Listings> result = null; IShopService shopsService = new ShopService(new EtsyContext(string.Empty)); shopsService.GetFeaturedDetailsCompleted += (s, e) => result = e; // ACT shopsService.GetFeaturedDetails(NetsyData.TestUserId, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }