67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
using HSchool.Content;
|
|
|
|
namespace HSchool.Content.Tests;
|
|
|
|
public class AppropriatenessTests
|
|
{
|
|
[Fact]
|
|
public void NoBright_RejectsBrightTag()
|
|
{
|
|
var catalog = LoadCatalog();
|
|
var rules = new DressRulePair(FormPolicies.Regular, ColorPolicies.NoBright);
|
|
Assert.False(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["TShirt"], "Red"));
|
|
Assert.True(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["TShirt"], "Blue"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ShortForm_YoungPupil_UsesRegularEffectiveForm()
|
|
{
|
|
var catalog = LoadCatalog();
|
|
var rules = new DressRulePair(FormPolicies.Short, ColorPolicies.Free);
|
|
var context = new ApparelContext(
|
|
Female: true,
|
|
Age: 7,
|
|
IsStudent: true,
|
|
rules,
|
|
ApparelMode.Everyday,
|
|
OutdoorTemperatureC: 15f,
|
|
catalog.BehaviorRules);
|
|
Assert.Equal(FormPolicies.Regular, Appropriateness.EffectiveForm(context));
|
|
Assert.False(Appropriateness.SkirtLengthFits(context, catalog.Things["ShortSkirt"]));
|
|
}
|
|
|
|
[Fact]
|
|
public void ShortForm_OlderPupil_AllowsShortSkirt()
|
|
{
|
|
var catalog = LoadCatalog();
|
|
var rules = new DressRulePair(FormPolicies.Short, ColorPolicies.Free);
|
|
var context = new ApparelContext(
|
|
Female: true,
|
|
Age: 15,
|
|
IsStudent: true,
|
|
rules,
|
|
ApparelMode.Everyday,
|
|
OutdoorTemperatureC: 15f,
|
|
catalog.BehaviorRules);
|
|
Assert.True(Appropriateness.SkirtLengthFits(context, catalog.Things["ShortSkirt"]));
|
|
}
|
|
|
|
[Fact]
|
|
public void WhiteTopBlackBottom_RejectsWrongTopOrBottom()
|
|
{
|
|
var catalog = LoadCatalog();
|
|
var rules = new DressRulePair(FormPolicies.Regular, ColorPolicies.WhiteTopBlackBottom);
|
|
Assert.False(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["Shirt"], "Gray"));
|
|
Assert.True(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["Shirt"], "White"));
|
|
Assert.False(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["Jeans"], "Blue"));
|
|
Assert.True(Appropriateness.ColorAllowed(catalog, rules, catalog.Things["Jeans"], "Black"));
|
|
}
|
|
|
|
private static DefCatalog LoadCatalog()
|
|
{
|
|
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
|
var documents = PackDocuments.FromDirectory(CatalogLoader.CorePackId, root);
|
|
return new CatalogLoader().Load([CatalogLoader.CorePackId], documents);
|
|
}
|
|
}
|