コード例 #1
0
        public async Task ConvertsCurrency()
        {
            // Arrange
            var grpcClientMock = TestMocks.GrpcClientMock();

            // Act
            var currencyConverter = new CurrencyConverter(grpcClientMock);

            const double expectedTotalRoi  = 750;
            const double expectedTotalFees = 75;

            var roiResult = new RoiCalculationResult()
            {
                Currency = TestConstants.BaseCurrency,
                Total    = 1000,
                Fees     = 100,
            };


            await currencyConverter.Convert(roiResult, TestConstants.BaseCurrency, TestConstants.TargetCurrency);

            // Assert
            Assert.AreEqual(roiResult.Total, expectedTotalRoi);
            Assert.AreEqual(roiResult.Fees, expectedTotalFees);
        }
コード例 #2
0
        public void CanBeInstantiated()
        {
            // Arrange
            var grpcClientMock = TestMocks.GrpcClientMock();

            // Act
            var currencyConverter = new CurrencyConverter(grpcClientMock);

            // Assert
            Assert.Pass();
        }
コード例 #3
0
        public async Task RoiCalculationTest()
        {
            // Arrange
            var          currencyConverter = new CurrencyConverter(TestMocks.GrpcClientMock());
            var          businessRules     = GetTestBusinessRules();
            const double investmentAmount  = 100000;
            var          calculator        = new RoiCalculator(currencyConverter, businessRules);

            // This is "House market"
            var optionId = businessRules.InvestmentBusinessRules.First().Id;

            // Invest 100% in the house market;
            var investionAllocation = new List <InvestmentOptionBase>()
            {
                new InvestmentOption()
                {
                    Id = optionId,
                    AllocatedProportion = 1
                }
            };
            var calculationRequest = new RoiCalculationRequest()
            {
                BaseCurrency      = TestConstants.BaseCurrency,
                InvestmentAmount  = investmentAmount,
                InvestmentOptions = investionAllocation
            };


            // Act
            var calculationResult = await calculator.Calculate(calculationRequest);

            // Assert
            // We expect a 20% ROI and just the base FEE, becuase house market doesn't have fee.
            const double expectedRoi  = investmentAmount * 0.2 * TestConstants.AudUsdConversionRate;
            const double expectedFees = TestConstants.BaseFee * TestConstants.AudUsdConversionRate;

            Assert.AreEqual(calculationResult.Currency, TestConstants.TargetCurrency);
            Assert.AreEqual(calculationResult.Total, expectedRoi);
            Assert.AreEqual(calculationResult.Fees, expectedFees);
        }