Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created May 9, 2025 11:58
Show Gist options
  • Save trikitrok/095c39b86e6fa8484ff28078a7e9bc31 to your computer and use it in GitHub Desktop.
Save trikitrok/095c39b86e6fa8484ff28078a7e9bc31 to your computer and use it in GitHub Desktop.
Argent Rose super lite tests with 100% coverage but some mutants surviving no Wine
using NUnit.Framework;
namespace ArgentRose.Tests;
public class ArgentRoseStoreTest
{
private const int MIN_QUALITY = 0;
private const int MAX_QUALITY = 50;
private const int SELLIN_LAST_DAY = 0;
private const int EXPIRED = -1;
private ArgentRoseStore store;
[SetUp]
public void Setup()
{
store = new ArgentRoseStore();
}
[Test]
public void RegularProductDecreasesQualityByTwo()
{
var regular = CreateRegular(5, 10);
store.Add(regular);
store.Update();
Assert.That(regular, Is.EqualTo(CreateRegular(4, 8)));
}
[Test]
public void ExpiredRegularProductDecreasesQualityTwiceAsFast()
{
var regular = CreateRegular(SELLIN_LAST_DAY, 10);
store.Add(regular);
store.Update();
Assert.That(regular, Is.EqualTo(CreateRegular(EXPIRED, 6)));
}
[Test]
public void TheatrePassesIncreaseQualityByOneWhenSellInIsFarAway()
{
var theatrePasses = CreateTheatrePasses(9, 12);
store.Add(theatrePasses);
store.Update();
Assert.That(theatrePasses, Is.EqualTo(CreateTheatrePasses(8, 13)));
}
[Test]
public void TheatrePassesIncreaseQualityByThreeWhenSellInIsNear()
{
var theatrePasses = CreateTheatrePasses(3, 12);
store.Add(theatrePasses);
store.Update();
Assert.That(theatrePasses, Is.EqualTo(CreateTheatrePasses(2, 15)));
}
[Test]
public void ExpiredTheatrePassesDropQualityToZero()
{
var theatrePasses = CreateTheatrePasses(SELLIN_LAST_DAY, 5);
store.Add(theatrePasses);
store.Update();
Assert.That(theatrePasses, Is.EqualTo(CreateTheatrePasses(EXPIRED, MIN_QUALITY)));
}
[Test]
public void RegularProductQualityIsNeverBelowTheMinimumQuality()
{
var regular = CreateRegular(2, 1);
store.Add(regular);
store.Update();
Assert.That(regular, Is.EqualTo(CreateRegular(1, MIN_QUALITY)));
}
[Test]
public void ExpiredRegularProductQualityIsNeverBelowTheMinimumQuality()
{
var regular = CreateRegular(SELLIN_LAST_DAY, 3);
store.Add(regular);
store.Update();
Assert.That(regular, Is.EqualTo(CreateRegular(EXPIRED, MIN_QUALITY)));
}
[Test]
public void TheatrePassQualityWhenSellInIsFarAwayNeverIncreasesOverTheMaximumQuality()
{
var theatrePasses = CreateTheatrePasses(2, MAX_QUALITY);
store.Add(theatrePasses);
store.Update();
Assert.That(theatrePasses, Is.EqualTo(CreateTheatrePasses(1, MAX_QUALITY)));
}
[Test]
public void TheatrePassQualityWhenSellInIsNearNeverIncreasesOverTheMaximumQuality()
{
var theatrePasses = CreateTheatrePasses(2, 48);
store.Add(theatrePasses);
store.Update();
Assert.That(theatrePasses, Is.EqualTo(CreateTheatrePasses(1, MAX_QUALITY)));
}
[Test]
public void UpdatingMultipleProducts()
{
var regular1 = CreateRegular(10, 4);
var regular2 = CreateRegular(3, 5);
store.Add(regular1, regular2);
store.Update();
Assert.That(regular1, Is.EqualTo(CreateRegular(9, 2)));
Assert.That(regular2, Is.EqualTo(CreateRegular(2, 3)));
}
private Product CreateRegular(int sellIn, int quality)
{
return new Product("Regular", sellIn, quality);
}
private Product CreateTheatrePasses(int sellIn, int quality)
{
return new Product("Theatre Passes", sellIn, quality);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment