public void GetShopsByNameLowDetailRetrievalTest() { // ARANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IShopService shopsService = new ShopService(new EtsyContext(NetsyData.EtsyApiKey)); shopsService.GetShopsByNameCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetShopsByName("fred", SortOrder.Up, 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 TestHelpers.CheckResultSuccess(result); Assert.IsNotNull(result.ResultValue.Results); Assert.IsTrue(result.ResultStatus.Success); Assert.IsTrue(result.ResultValue.Count > 0); } }
public void GetShopDetailsTest() { EtsyContext etsyContext = new EtsyContext(Constants.DummyEtsyApiKey); MockFixedDataRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(GetShopDetailsRawResults); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); IShopService etsyShopsService = new ShopService(etsyContext, dataRetriever); using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; etsyShopsService.GetShopDetailsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyShopsService.GetShopDetails(Constants.TestId, 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); } }
public void GetShopsByNameApiKeyInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IShopService shopsService = new ShopService(new EtsyContext("InvalidKey")); shopsService.GetShopsByNameCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetShopsByName("fred", SortOrder.Up, 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); } }
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 CreateWithMockRequestTest() { EtsyContext etsyContext = new EtsyContext(string.Empty); IRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(string.Empty); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); IShopService service = new ShopService(etsyContext, dataRetriever); Assert.IsNotNull(service); }
public void GetFeaturedSellersMissingApiKeyTest() { // ARRANGE ResultEventArgs<Shops> result = null; IShopService shopsService = new ShopService(new EtsyContext(string.Empty)); shopsService.GetFeaturedSellersCompleted += (s, e) => result = e; // ACT shopsService.GetFeaturedSellers(0, 10, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }
public void GetShopListingsByIdMissingApiKeyTest() { // ARRANGE ResultEventArgs<Listings> result = null; IShopService shopsService = new ShopService(new EtsyContext(string.Empty)); shopsService.GetShopListingsCompleted += (s, e) => result = e; // ACT shopsService.GetShopListings(NetsyData.TestUserId, SortField.Created, SortOrder.Up, 0, 0, 10, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }
public void GetShopsByNameMissingApiKeyTest() { // ARRANGE ResultEventArgs<Shops> result = null; IShopService shopsService = new ShopService(new EtsyContext(string.Empty)); shopsService.GetShopsByNameCompleted += (s, e) => result = e; // ACT shopsService.GetShopsByName("fred", SortOrder.Up, 0, 10, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }
/// <summary> /// Tets getting shop details with various detail levels /// </summary> /// <param name="detailLevel">the detail level to use</param> private static void TestGetShopDetails(DetailLevel detailLevel) { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IShopService shopsService = new ShopService(new EtsyContext(NetsyData.EtsyApiKey)); shopsService.GetShopDetailsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetShopDetails(NetsyData.TestUserName, detailLevel); 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.Params); Assert.IsNotNull(result.ResultValue.Results); Assert.AreEqual(1, result.ResultValue.Count); } }
/// <summary> /// Test retrieving shop listings at the given detail level /// </summary> /// <param name="detailLevel">the given detail level</param> private static void TestGetShopListingsByName(DetailLevel detailLevel) { // ARANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; IShopService shopsService = new ShopService(new EtsyContext(NetsyData.EtsyApiKey)); shopsService.GetShopListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT shopsService.GetShopListings(NetsyData.TestUserName, SortField.Created, SortOrder.Down, 0, 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 TestHelpers.CheckResultSuccess(result); Assert.IsNotNull(result.ResultValue.Results); Assert.IsTrue(result.ResultStatus.Success); Assert.IsTrue(result.ResultValue.Count > 0); } }