Exemplo n.º 1
0
        public async Task CalculateImpactOfBaseRateChange_BaseRateServiceMethodGetBaseRateShouldBeCalledTwice()
        {
            var user = new User
            {
                Id         = 67812203006,
                Name       = "Goras Trusevičius",
                Agreements = new List <Agreement>()
                {
                    new Agreement
                    {
                        Id                = 1,
                        Amount            = 12000,
                        BaseRateCodeId    = BaseRateCodeEnum.VILIBOR3m,
                        Margin            = 1.6M,
                        AgreementDuration = 60
                    }
                }
            };

            this.SetupUserRepositoryGetToReturn(user);
            var service = new InterestRateService(this.uowMock.Object, this.baseRateServiceMock.Object);

            await service.CalculateImpactOfBaseRateChange(67812203006, 1, BaseRateCodeEnum.VILIBOR1m);

            this.baseRateServiceMock.Verify(x => x.GetBaseRate(BaseRateCodeEnum.VILIBOR1m), Times.Once);
            this.baseRateServiceMock.Verify(x => x.GetBaseRate(BaseRateCodeEnum.VILIBOR3m), Times.Once);
        }
Exemplo n.º 2
0
        public async Task CalculateImpactOfBaseRateChange_WhenBaseRateCodesAreTheSame_DifferenceShouldBe0()
        {
            var baseRateCode = BaseRateCodeEnum.VILIBOR3m;
            var user         = new User
            {
                Id         = 67812203006,
                Name       = "Goras Trusevičius",
                Agreements = new List <Agreement>()
                {
                    new Agreement
                    {
                        Id                = 1,
                        Amount            = 12000,
                        BaseRateCodeId    = baseRateCode,
                        Margin            = 1.6M,
                        AgreementDuration = 60
                    }
                }
            };

            this.SetupUserRepositoryGetToReturn(user);
            var service = new InterestRateService(this.uowMock.Object, this.baseRateServiceMock.Object);

            var impact = await service.CalculateImpactOfBaseRateChange(67812203006, 1, baseRateCode);

            Assert.AreEqual(impact.InterestRateDifference, 0m);
        }
Exemplo n.º 3
0
        public void CalculateImpactOfBaseRateChange_WhenUserWithAgreementIsNotFound_ShoulThrowAnException()
        {
            this.SetupUserRepositoryGetToReturn(null);
            var service = new InterestRateService(this.uowMock.Object, this.baseRateServiceMock.Object);

            Assert.ThrowsAsync <EntityNotFoundException>(
                async() => await service.CalculateImpactOfBaseRateChange(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <BaseRateCodeEnum>())
                );
        }