using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using KernelPanic.Core; using KernelPanic.Data; using KernelPanic.Meta; using KernelPanic.UI; using NUnit.Framework; using UnityEditor; using UnityEngine; using UnityEngine.TestTools; using UnityEngine.UIElements; using Random = UnityEngine.Random; public class GachaRevealTests { private bool _motion; private UITextSize _textSize; [SetUp] public void SetUp() { _motion = UIPreferences.ReducedMotion; _textSize = UIPreferences.TextSize; UIPreferences.ReducedMotion = false; UIPreferences.TextSize = UITextSize.Standard; } [TearDown] public void TearDown() { UIPreferences.ReducedMotion = _motion; UIPreferences.TextSize = _textSize; } [TestCase(false, false, 3)] [TestCase(false, true, 3)] [TestCase(false, false, 4)] [TestCase(false, true, 5)] [TestCase(true, false, 4)] [TestCase(true, true, 4)] [TestCase(true, false, 5)] [TestCase(true, true, 5)] public void SingleRewardsShowActualIdentityAndExactConversion(bool distro, bool duplicate, int stars) { var reward = Reward(1, distro, duplicate, stars); var root = new VisualElement(); using var view = new GachaRevealView(root, Receipt(reward), () => { }); view.RevealAll(); Assert.That(view.IsComplete, Is.True); Assert.That(view.SelectedIndex, Is.Zero); var detail = root.Q("PullRewardDetail"); Assert.That(detail.Q(className: distro ? "distribution-detail" : "package-detail"), Is.Not.Null); Assert.That(detail.Q(className: distro ? "package-detail" : "distribution-detail"), Is.Null); string text = Copy(detail); if (duplicate) { Assert.That(text, Does.Contain("DUPLICATE CONVERTED")); Assert.That(text, Does.Contain("137 " + (distro ? "Merges" : "Cache")), "Use receipt values, not tuning constants."); } else Assert.That(text, Does.Contain("Added to your collection.")); if (distro) { Assert.That(detail.Q