GetServerEpoch() public method

Get server time, in epoch seconds notation.
public GetServerEpoch ( ) : IAsyncResult
return IAsyncResult
Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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);
        }