Exemple #1
0
        private void CreateTestTransfers()
        {
            var transferItem  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem2 = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));

            var detail = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem, transferItem2
            });

            var proxy    = new ItemTransferProxy();
            var response = proxy.InsertItemTransfer(detail);

            _testTransfer = proxy.GetItemTransfer(response.DataObject.InsertedEntityId).DataObject;

            var transferItem3  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem4  = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));
            var detailToDelete = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem3, transferItem4
            });

            response = proxy.InsertItemTransfer(detailToDelete);

            _testTransferToDeleteId = proxy.InsertItemTransfer(detailToDelete).DataObject.InsertedEntityId;
        }
Exemple #2
0
        public void ShouldGetItemTransfersFilterOnDate()
        {
            var proxy    = new ItemTransferProxy();
            var proxyGet = new ItemTransfersProxy();

            var testDate = new DateTime(2016, 12, 1);

            var transferItem  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem2 = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));

            var detail = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem, transferItem2
            }, testDate);

            var insertTransfer = proxy.InsertItemTransfer(detail);

            var response = proxyGet.GetItemTransfers(fromDate: testDate, toDate: testDate);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.IsSuccessfull);
            Assert.IsNotNull(response.DataObject);
            Assert.IsNotNull(response.DataObject.Transfers);
            Assert.IsTrue(response.DataObject.Transfers.Count > 0);
            Assert.IsNull(response.DataObject.Transfers.Where(t => t.Date < testDate).SingleOrDefault());
            Assert.IsNull(response.DataObject.Transfers.Where(t => t.Date > testDate).SingleOrDefault());
            Assert.NotNull(response.DataObject.Transfers.Where(t => t.Id == insertTransfer.DataObject.InsertedEntityId));
        }
Exemple #3
0
        public void ShouldFailOnInsertWithNoItems()
        {
            var proxy = new ItemTransferProxy();

            var detail   = _transferHelper.GetTransferDetail(new List <TransferItem>());
            var response = proxy.InsertItemTransfer(detail);

            Assert.IsFalse(response.IsSuccessfull);
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsNull(response.DataObject);
            Assert.IsTrue(response.RawResponse.Contains("Please specify TransferItems for this transaction."));
        }
Exemple #4
0
        public void ShouldInsertItemTransfer()
        {
            var transferItem  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem2 = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));

            var detail = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem, transferItem2
            });

            var proxy    = new ItemTransferProxy();
            var response = proxy.InsertItemTransfer(detail);

            Assert.IsTrue(response.IsSuccessfull);
            Assert.IsNotNull(response.DataObject);
            Assert.IsTrue(response.DataObject.InsertedEntityId > 0);
            Assert.GreaterOrEqual(response.DataObject.UtcLastModified, DateTime.Today.AddMinutes(-10).ToUniversalTime());
        }