public void GetAddressBalance_AddressNotExisted_ReturnNotFound()
        {
            AddressService.ResetCalls();

            var  address  = "hgktb865fjygf";
            long clientId = 1;

            AddressService.Setup(x => x.GetAddressBalance(clientId, address)).Returns((decimal?)null);

            var controller = new AddressController(AddressService.Object, Logger.Object)
            {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };

            controller.ControllerContext.HttpContext.Items.Add("clientId", clientId);

            var actionResult = controller.GetAddressBalance(address);
            var result       = actionResult as OkObjectResult;
            var result1      = actionResult as NotFoundResult;

            AddressService.Verify(x => x.GetAddressBalance(clientId, address), Times.Once);
            Assert.IsTrue(result == null);
            Assert.IsTrue(result1 != null);
        }
        public void GetAddressBalance_ServiceReturnException_ReturnInternalServerError()
        {
            AddressService.ResetCalls();

            var  address          = "hgktb865fjygf";
            long clientId         = 1;
            var  exceptionMessage = "some exception message";

            AddressService.Setup(x => x.GetAddressBalance(clientId, address)).Throws(new Exception(exceptionMessage));

            var controller = new AddressController(AddressService.Object, Logger.Object)
            {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };

            controller.ControllerContext.HttpContext.Items.Add("clientId", clientId);

            var actionResult = controller.GetAddressBalance(address);
            var result       = actionResult as OkObjectResult;
            var result1      = actionResult as ObjectResult;

            AddressService.Verify(x => x.GetAddressBalance(clientId, address), Times.Once);
            Assert.AreEqual(result, null);
            Assert.IsTrue(result == null);
            Assert.IsTrue(result1 != null);
            Assert.AreEqual(result1.StatusCode, 500);
            Assert.AreEqual(result1.Value, exceptionMessage);
        }
        public void GetAddressBalance_AddressExisted_ReturnOk()
        {
            AddressService.ResetCalls();

            var  address  = "hgktb865fjygf";
            long clientId = 1;
            var  balance  = 456.1245m;

            AddressService.Setup(x => x.GetAddressBalance(clientId, address)).Returns(balance);

            var controller = new AddressController(AddressService.Object, Logger.Object)
            {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };

            controller.ControllerContext.HttpContext.Items.Add("clientId", clientId);

            var actionResult = controller.GetAddressBalance(address);
            var result       = actionResult as OkObjectResult;

            AddressService.Verify(x => x.GetAddressBalance(clientId, address), Times.Once);
            Assert.AreEqual(result.StatusCode, 200);
            Assert.AreEqual(result.Value, balance);
        }