Exemplo n.º 1
0
        public void GetAccountInfoExpected()
        {
            IDeserializer deserializer = null;

            var restMock = new Mock <IRestClient>(MockBehavior.Strict);

            restMock.SetupAllProperties();
            restMock.Setup(x => x.AddHandler("application/json", It.IsAny <IDeserializer>())).Callback <string, IDeserializer>((ct, d) => deserializer = d);

            restMock.Setup(x => x.Execute <ResponseSingle <AccountInfo> >(It.IsAny <IRestRequest>())).Returns <IRestRequest>(request =>
            {
                var responseMock = new Mock <IRestResponse <ResponseSingle <AccountInfo> > >(MockBehavior.Strict);
                responseMock.SetupAllProperties();

                responseMock.Object.Content = Properties.Resources.AccountStatusResponse;
                responseMock.Object.Request = request;
                responseMock.Object.Data    = deserializer.Deserialize <ResponseSingle <AccountInfo> >(responseMock.Object);

                return(responseMock.Object);
            });

            var client = new BitsoClient(restMock.Object, ServiceUrlMock, ApiKeyMock, ApiSecretMock);

            var res = client.GetAccountInfo();

            Assert.IsNotNull(res);
            Assert.IsFalse(string.IsNullOrEmpty(res.ClientId));
            Assert.AreNotEqual <decimal>(0M, res.DailyLimit);
            Assert.AreNotEqual <decimal>(0M, res.MonthlyLimit);
            Assert.AreNotEqual <decimal>(0M, res.DailyRemaining);
            Assert.IsFalse(string.IsNullOrEmpty(res.Email));
            Assert.IsFalse(string.IsNullOrEmpty(res.FirstName));
            Assert.IsFalse(string.IsNullOrEmpty(res.LastName));
            Assert.AreNotEqual <AccountStatus>(AccountStatus.None, res.Status);
        }
Exemplo n.º 2
0
        public void GetAccountInfoExpected()
        {
            using (var client = new BitsoClient(this.TestingServerUrl, this.ApiKey, this.ApiSecret))
            {
                try
                {
                    var res = client.GetAccountInfo();

                    Assert.IsNotNull(res);
                    Assert.IsFalse(string.IsNullOrEmpty(res.ClientId));
                    Assert.AreNotEqual <decimal>(0M, res.DailyLimit);
                    Assert.AreNotEqual <decimal>(0M, res.MonthlyLimit);
                    Assert.AreNotEqual <decimal>(0M, res.DailyRemaining);
                    Assert.IsFalse(string.IsNullOrEmpty(res.Email));
                    Assert.IsFalse(string.IsNullOrEmpty(res.FirstName));
                    Assert.IsFalse(string.IsNullOrEmpty(res.LastName));
                    Assert.AreNotEqual <AccountStatus>(AccountStatus.None, res.Status);
                }
                catch (BitsoException ex)
                {
                    this.TestContext.WriteLine(ex.Header);
                    throw;
                }
            }
        }