initial
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5855a87ce97ace049915c17c1ba0c9ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "AfterHours.Tests",
|
||||
"rootNamespace": "AfterHours.Tests",
|
||||
"references": [
|
||||
"AfterHours.Runtime",
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner"
|
||||
],
|
||||
"includePlatforms": ["Editor"],
|
||||
"precompiledReferences": ["nunit.framework.dll"],
|
||||
"defineConstraints": ["UNITY_INCLUDE_TESTS"],
|
||||
"autoReferenced": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 576e5e4dc99f32e4eaebf1eb76385743
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using AfterHours.Customers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AfterHours.Tests
|
||||
{
|
||||
public sealed class ComfortModelTests
|
||||
{
|
||||
[Test]
|
||||
public void EmptyStore_LeavesCustomerFullyComfortable()
|
||||
{
|
||||
float comfort = ComfortModel.EvaluateTarget(0.5f, 0.8f, 0, false, false);
|
||||
Assert.AreEqual(1f, comfort, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CrowdingReducesComfort()
|
||||
{
|
||||
float alone = ComfortModel.EvaluateTarget(0.5f, 0.8f, 0, false, false);
|
||||
float crowded = ComfortModel.EvaluateTarget(0.5f, 0.8f, 4, false, false);
|
||||
Assert.Less(crowded, alone);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToleranceCushionsTheSameSituation()
|
||||
{
|
||||
float shy = ComfortModel.EvaluateTarget(0.1f, 0.9f, 3, true, false);
|
||||
float bold = ComfortModel.EvaluateTarget(0.9f, 0.9f, 3, true, false);
|
||||
Assert.Greater(bold, shy);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HarmlessProductIsUnaffectedByCrowding()
|
||||
{
|
||||
float comfort = ComfortModel.EvaluateTarget(0.5f, 0f, 6, true, true);
|
||||
Assert.AreEqual(1f, comfort, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorstCaseTriggersAbandonment()
|
||||
{
|
||||
float comfort = ComfortModel.EvaluateTarget(0f, 1f, 5, true, true);
|
||||
Assert.IsTrue(ComfortModel.ShouldAbandon(comfort), $"Komfort war {comfort}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecoveryIsGradual_DiscomfortIsImmediate()
|
||||
{
|
||||
Assert.AreEqual(0.3f, ComfortModel.Step(1f, 0.3f, 0.25f), 0.0001f); // sofort
|
||||
Assert.Less(ComfortModel.Step(0.3f, 1f, 0.25f), 1f); // träge
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee90a53056bfe9c42bf72d0e7ee60e8a
|
||||
@@ -0,0 +1,55 @@
|
||||
using AfterHours.Economy;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AfterHours.Tests
|
||||
{
|
||||
public sealed class PricingServiceTests
|
||||
{
|
||||
[Test]
|
||||
public void AtOrBelowRecommendedPrice_EveryoneBuys()
|
||||
{
|
||||
Assert.AreEqual(1f, PricingService.PurchaseProbability(10f, 12f), 0.0001f);
|
||||
Assert.AreEqual(1f, PricingService.PurchaseProbability(12f, 12f), 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtRejectionThreshold_NobodyBuys()
|
||||
{
|
||||
float price = 12f * PricingService.RejectionThreshold;
|
||||
Assert.AreEqual(0f, PricingService.PurchaseProbability(price, 12f), 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DemandFallsMonotonically()
|
||||
{
|
||||
float previous = 1f;
|
||||
for (float price = 12f; price < 21f; price += 0.5f)
|
||||
{
|
||||
float current = PricingService.PurchaseProbability(price, 12f);
|
||||
Assert.LessOrEqual(current, previous);
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SmallMarkupHurtsLessThanLargeOne()
|
||||
{
|
||||
float small = 1f - PricingService.PurchaseProbability(13f, 12f);
|
||||
float large = 1f - PricingService.PurchaseProbability(19f, 12f);
|
||||
Assert.Less(small, large * 0.5f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExpectedProfitPeaksAboveWholesale()
|
||||
{
|
||||
float best = 0f, bestPrice = 0f;
|
||||
for (float price = 5f; price < 21f; price += 0.25f)
|
||||
{
|
||||
float profit = PricingService.ExpectedProfitPerUnit(price, 12f, 5f);
|
||||
if (profit > best) { best = profit; bestPrice = price; }
|
||||
}
|
||||
Assert.Greater(bestPrice, 5f);
|
||||
Assert.Greater(best, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53f7a9ae1e6213b4db8d1f200e402334
|
||||
Reference in New Issue
Block a user