public void Price_With_Three_Criterias() { //Arrange decimal basePrice = 100m; decimal bonusPrice = 10m; _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Base_Price)).Returns(basePrice); _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Followers_Bonus_Price)).Returns(bonusPrice); _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Public_Repositories_Bonus_Price)).Returns(bonusPrice); _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Stars_Bonus_Price)).Returns(bonusPrice); //Act //sut means subject under test var sut = new PriceService(_mockPriceRepository.Object); PricingCriteria criteria = new PricingCriteria() { Followers = 15, Stars = 30, PublicRepositories = 10, }; decimal output = sut.CalculateDeveloperPrice(criteria); //Assert Assert.AreEqual(output, 650); }
public decimal CalculateDeveloperPrice(PricingCriteria criteria) { decimal totalPrice = _priceRepository.GetPrice(PriceKeys.Base_Price); totalPrice += criteria.Followers * _priceRepository.GetPrice(PriceKeys.Followers_Bonus_Price); totalPrice += criteria.Stars * _priceRepository.GetPrice(PriceKeys.Public_Repositories_Bonus_Price); totalPrice += criteria.PublicRepositories * _priceRepository.GetPrice(PriceKeys.Stars_Bonus_Price); return(totalPrice); }