Ejemplo n.º 1
0
        // ReSharper disable once InconsistentNaming
        public async void Controller_can_not_PUT_update_a_Fake_Asset_with_a_bad_AccountType()
        {
            // Arrange 
            _ctrl = new AssetController(_mockRepo.Object, _mockIdentitySvc.Object, _mockRepoInvestor.Object, _mockRepoAssetClass.Object, _mockRepoProfile.Object, _mockRepoAcctType.Object, _mockRepoPosition.Object, _mockRepoIncome.Object)
                                                {
                                                    Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/PIMS.Web.Api/api/Asset/VNR") },
                                                    Configuration = new HttpConfiguration()
                                                };

            // AccountTypePreEdit value initialized by server and sent unmodified by the client.
            var editedAsset = new AssetSummaryVm {AccountTypePreEdit  = "IRRA", AccountTypePostEdit = ""};
            //var debugTest = TestHelpers.ObjectToJson(editedAsset);

            // Act 
            //var debugTest = TestHelpers.ObjectToJson(editedAsset);
            var updatedAsset = await _ctrl.UpdateByTicker(editedAsset, "VNR") as BadRequestResult;


            // Assert
            Assert.IsTrue(updatedAsset == null);
        }
Ejemplo n.º 2
0
        // ReSharper disable once InconsistentNaming
        public async void Controller_Can_PUT_update_a_Fake_Asset_with_AccountType_and_Quantity_and_DateRecvd_changes()
        {
            // Asset - Summary:
            // Selected Asset data for all Assets may be viewed and updated via each AssetSummaryVM grid record; each grid row 
            // represents data elements from various aggregate child objects comprising an Asset aggregate root.

            // Arrange - "assetViewModel" maps to http content, while ticker maps to "existingTicker" in ctrl.
            var dateRecvd = DateTime.UtcNow;
            _ctrl = new AssetController(_mockRepo.Object, _mockIdentitySvc.Object, _mockRepoInvestor.Object, _mockRepoAssetClass.Object, _mockRepoProfile.Object, _mockRepoAcctType.Object, _mockRepoPosition.Object, _mockRepoIncome.Object)
                                                {
                                                    Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/PIMS.Web.Api/api/Asset/VNR") },
                                                    Configuration = new HttpConfiguration()
                                                };

            var editedAssetSummary = new AssetSummaryVm
                                      {
                                          AccountTypePreEdit = "ML-CMA",
                                          AccountTypePostEdit = "Roth-IRA",
                                          Quantity = 500,
                                          DateRecvd = dateRecvd.AddDays(2)
                                      };
            var debugTest = TestHelpers.ObjectToJson(editedAssetSummary);

            // Act - "UpdateByTicker()" allows for PUT/PATCH updates.
            var updatedAsset = await _ctrl.UpdateByTicker(editedAssetSummary, "VNR") as OkNegotiatedContentResult<Asset>;


            // Assert
            Assert.IsTrue(updatedAsset != null);
            Assert.That(editedAssetSummary.Quantity, Is.EqualTo(updatedAsset.Content.Positions.First().Quantity));
            Assert.That(updatedAsset.Content.Positions.First().Account.AccountTypeDesc.ToUpper(), Is.EqualTo("ROTH-IRA"));
            Assert.That(updatedAsset.Content.Revenue.First().DateRecvd, Is.EqualTo(editedAssetSummary.DateRecvd));
            Assert.That(updatedAsset.Content.Positions.First().Quantity, Is.EqualTo(editedAssetSummary.Quantity));
        }