public void When_Campaign_Create_IsActive_Return_True() { var campaign = new CampaignEntity("C1", "P1", 10, 10, 10, 0); var isActive = campaign.IsActive(4); Assert.True(isActive); }
public void When_Campaign_Expired_IsActive_Must_Be_Return_False() { var campaign = new CampaignEntity("C1", "P1", 10, 10, 10, 0); var isActive = campaign.IsActive(10); Assert.False(isActive); }
public decimal CalculateDiscountedPrice(CampaignEntity campaign, decimal listingPrice, int currentTime) { if (listingPrice <= 0) { throw new ValueMustBeBiggerThanZeroException(nameof(listingPrice), listingPrice); } if (campaign == null || !campaign.IsActive(currentTime)) { return(listingPrice); } var manipulationPercentageByHour = campaign.PriceManipulationLimit / campaign.Duration; var discountPercentage = manipulationPercentageByHour * (currentTime - campaign.CreatedTime + 1); //saat 0 oldugunda hesaplama hatasi olmamasi icin +1 ekleniyor return(listingPrice - listingPrice / 100 * discountPercentage); }