public void GetFavoriteShopsOfUserByNameApiKeyInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IFavoritesService favoritesService = new FavoritesService(new EtsyContext("InvalidKey")); favoritesService.GetFavoriteShopsOfUserCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT favoritesService.GetFavoriteShopsOfUser(NetsyData.TestUserName, 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"); // 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 GetFavoriteShopsOfUserByNameMissingApiKeyTest() { // ARRANGE ResultEventArgs<Shops> result = null; IFavoritesService favoritesService = new FavoritesService(new EtsyContext(string.Empty)); favoritesService.GetFavoriteShopsOfUserCompleted += (s, e) => result = e; // ACT favoritesService.GetFavoriteShopsOfUser(NetsyData.TestUserName, 0, 10, DetailLevel.Low); // check the data TestHelpers.CheckResultFailure(result); }
/// <summary> /// Test GetFavoriteShopsOfUser by name at the given detail level /// </summary> /// <param name="detailLevel">the detail level</param> private static void TestGetFavoriteShopsOfUserByName(DetailLevel detailLevel) { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IFavoritesService favoritesService = new FavoritesService(new EtsyContext(NetsyData.EtsyApiKey)); favoritesService.GetFavoriteShopsOfUserCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT favoritesService.GetFavoriteShopsOfUser(NetsyData.TestUserName, 0, 10, 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 - should succeed 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 GetFavoriteShopsOfUserShopIdInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Shops> result = null; IFavoritesService favoritesService = new FavoritesService(new EtsyContext(NetsyData.EtsyApiKey)); favoritesService.GetFavoriteShopsOfUserCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT favoritesService.GetFavoriteShopsOfUser(NetsyData.TestBadUserId, 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 Assert.IsNotNull(result); Assert.IsNotNull(result.ResultStatus); // doesn't fail, returns zero count Assert.IsTrue(result.ResultStatus.Success); Assert.AreEqual(0, result.ResultValue.Count); //Assert.IsFalse(result.ResultStatus.Success); //Assert.AreEqual(WebExceptionStatus.ProtocolError, result.ResultStatus.WebStatus); } }