<commit_before>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RedPencil.Test
{
    [TestClass]
    public class RedPencilTests
    {
        [TestMethod]
        public void PromotionTakesEffectAt5PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1.0d;
            product.SalePrice = 0.95d;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(true, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotTakeEffectOver30PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .65;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotEffectBelow5PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .96;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionTakesEffectIfPriceHasNotChangedFor30Days()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now.Subtract(TimeSpan.FromDays(30));

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(true, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotTakeEffectWithin30DaysOfPreviousPriceChange()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void PromotionCanNotLastMoreThan30Days()
        {
            RedPencil promotion = new RedPencil();
            promotion.StartDate = DateTime.Now.Subtract(TimeSpan.FromDays(31));
            promotion.EndDate = DateTime.Now;

            promotion.Begin(new Product());
        }

        [TestMethod]
        public void PromotionCanLastUpTo30Days()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now.Subtract(TimeSpan.FromDays(30));
            
            RedPencil promotion = new RedPencil();
            promotion.Begin(product);
        }
    }
}<commit_msg>Added price reduction during promotion test<commit_after>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RedPencil.Test
{
    [TestClass]
    public class RedPencilTests
    {
        [TestMethod]
        public void PromotionTakesEffectAt5PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1.0d;
            product.SalePrice = 0.95d;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(true, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotTakeEffectOver30PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .65;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotEffectBelow5PercentDiscount()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .96;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionTakesEffectIfPriceHasNotChangedFor30Days()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now.Subtract(TimeSpan.FromDays(30));

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(true, promotion.IsEligible(product));
        }

        [TestMethod]
        public void PromotionDoesNotTakeEffectWithin30DaysOfPreviousPriceChange()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now;

            RedPencil promotion = new RedPencil();
            Assert.AreEqual(false, promotion.IsEligible(product));
        }

        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void PromotionCanNotLastMoreThan30Days()
        {
            RedPencil promotion = new RedPencil();
            promotion.StartDate = DateTime.Now.Subtract(TimeSpan.FromDays(31));
            promotion.EndDate = DateTime.Now;

            promotion.Begin(new Product());
        }

        [TestMethod]
        public void PromotionCanLastUpTo30Days()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now.Subtract(TimeSpan.FromDays(30));
            
            RedPencil promotion = new RedPencil();
            promotion.Begin(product);
        }

        [TestMethod]
        public void PriceReductionDuringPromotionDoesNotProlongIt()
        {
            Product product = new Product();
            product.MSRP = 1;
            product.SalePrice = .9;
            product.PreviousPriceChangeOccurredAt = DateTime.Now.Subtract(TimeSpan.FromDays(30));

            RedPencil promotion = new RedPencil();
            var promotionLength = promotion.EndDate - promotion.StartDate;
            promotion.Begin(product);
            product.SalePrice = .8;

            Assert.AreEqual(promotionLength, promotion.EndDate - promotion.StartDate);
        }
    }
}
{'fraction_non_alphanumeric': 0.08620145247868645, 'fraction_numerical': 0.011840858856962426, 'mean_word_length': 1.9981069569332703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7535113', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1622, 'n_words': 309}