コード例 #1
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // ReSharper disable once InconsistentNaming
        public async Task Controller_Can_DELETE_a_Fake_Asset_for_an_investor() {

            // Arrange - see above business rules
            _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/AAPL") },
                    Configuration = new HttpConfiguration()
            };

            // Act 
            var response = await _ctrl.DeleteAsset("AAPL") as OkNegotiatedContentResult<IQueryable<Asset>>;
            

            // Assert
            Assert.IsNotNull(response);


        }
コード例 #2
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // 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);
        }
コード例 #3
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // ReSharper disable once InconsistentNaming
        public async Task Controller_Can_GET_summary_info_for_All_Fake_Assets_for_an_investor() {

            // 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?displayType=summary") },
                            Configuration = new HttpConfiguration()
                        }; 
            
            // Act 
            var assetListing = await _ctrl.GetAll("summary") as OkNegotiatedContentResult<IQueryable<AssetSummaryVm>>;
            

            // Assert
            Assert.IsNotNull(assetListing);
            Assert.That(assetListing.Content.Count(), Is.GreaterThanOrEqualTo(2));
            Assert.IsTrue(assetListing.Content.ElementAt(0).CurrentInvestor == _mockIdentitySvc.Object.CurrentUser);
            Assert.IsTrue(assetListing.Content.ElementAt(1).CurrentInvestor == _mockIdentitySvc.Object.CurrentUser);
           
        }
コード例 #4
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // 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));
        }
コード例 #5
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // ReSharper disable once InconsistentNaming
        public async Task Controller_Can_not_GET_a_single_Fake_Asset_for_an_investor_using_an_invalid_ticker_symbol() {

            // 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/VNRX") },
                    Configuration = new HttpConfiguration()
            };

            // Act 
            //var assetListing = await _ctrl.GetByTicker("VNR") as OkNegotiatedContentResult<IQueryable<Asset>>;
            var assetListing = await _ctrl.DeleteAsset("VNRX") as OkNegotiatedContentResult<IQueryable<AssetSummaryVm>>;

            // Assert
            Assert.IsNull(assetListing);
        }
コード例 #6
0
ファイル: VerifyAsset.cs プロジェクト: RichardPAsch/PIMS
        // ReSharper disable once InconsistentNaming
        public async Task Controller_Can_GET_fake_detail_ticker_info_for_an_investor_with_verification_of_revenue_and_positions() 
        {
            // Arrange - default displayType = detail.
            _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/IBM") },
                Configuration = new HttpConfiguration()
            };

            // Act 
            var assetListing = await _ctrl.GetByTicker("IBM") as OkNegotiatedContentResult<IQueryable<Asset>>;


            // Assert
            Assert.IsNotNull(assetListing);
            Assert.That(assetListing.Content.Count(), Is.EqualTo(1));
            Assert.That(assetListing.Content.First().Positions.Count, Is.GreaterThanOrEqualTo(2));
            Assert.That(assetListing.Content.First().Revenue.Count, Is.GreaterThanOrEqualTo(3));
            Assert.IsTrue(assetListing.Content.ElementAt(0).Investor.LastName == _mockIdentitySvc.Object.CurrentUser);
            
        }