public void GetServerEpochApiKeyInvalidTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<ServerEpoch> result = null; IServerService etsyServer = new ServerService(new EtsyContext("InvalidKey")); etsyServer.GetServerEpochCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyServer.GetServerEpoch(); 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 GetServerEpochCallTest() { // ARRANGE using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<ServerEpoch> result = null; IServerService etsyServer = new ServerService(new EtsyContext(NetsyData.EtsyApiKey)); etsyServer.GetServerEpochCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyServer.GetServerEpoch(); 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 Assert.IsNotNull(result); TestHelpers.CheckResultSuccess(result); Assert.IsNotNull(result); Assert.IsNotNull(result.ResultStatus); Assert.IsTrue(result.ResultStatus.Success); Assert.IsNotNull(result.ResultValue); Assert.AreEqual(1, result.ResultValue.Count); Assert.AreEqual(1, result.ResultValue.Results.Length); Assert.IsTrue(result.ResultValue.Results[0] > 0); Assert.IsNull(result.ResultValue.Params); } }
public void GetServerEpochApiKeyMissingTest() { // ARRANGE ResultEventArgs<ServerEpoch> result = null; IServerService etsyServer = new ServerService(new EtsyContext(string.Empty)); etsyServer.GetServerEpochCompleted += (s, e) => result = e; // ACT etsyServer.GetServerEpoch(); // check the data TestHelpers.CheckResultFailure(result); }