2021-10-11 14:45:06 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2021-11-19 18:07:21 +08:00
|
|
|
using osu.Game.Rulesets;
|
2021-10-11 14:45:06 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Database
|
|
|
|
{
|
|
|
|
public class RulesetStoreTests : RealmTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestCreateStore()
|
|
|
|
{
|
|
|
|
RunTestWithRealm((realmFactory, storage) =>
|
|
|
|
{
|
2021-11-23 12:00:33 +08:00
|
|
|
var rulesets = new RulesetStore(realmFactory, storage);
|
2021-10-11 14:45:06 +08:00
|
|
|
|
|
|
|
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
|
2021-11-19 18:07:21 +08:00
|
|
|
Assert.AreEqual(4, realmFactory.Context.All<RulesetInfo>().Count());
|
2021-10-11 14:45:06 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCreateStoreTwiceDoesntAddRulesetsAgain()
|
|
|
|
{
|
|
|
|
RunTestWithRealm((realmFactory, storage) =>
|
|
|
|
{
|
2021-11-23 12:00:33 +08:00
|
|
|
var rulesets = new RulesetStore(realmFactory, storage);
|
|
|
|
var rulesets2 = new RulesetStore(realmFactory, storage);
|
2021-10-11 14:45:06 +08:00
|
|
|
|
|
|
|
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
|
|
|
|
Assert.AreEqual(4, rulesets2.AvailableRulesets.Count());
|
|
|
|
|
|
|
|
Assert.AreEqual(rulesets.AvailableRulesets.First(), rulesets2.AvailableRulesets.First());
|
2021-11-19 18:07:21 +08:00
|
|
|
Assert.AreEqual(4, realmFactory.Context.All<RulesetInfo>().Count());
|
2021-10-11 14:45:06 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRetrievedRulesetsAreDetached()
|
|
|
|
{
|
|
|
|
RunTestWithRealm((realmFactory, storage) =>
|
|
|
|
{
|
2021-11-23 12:00:33 +08:00
|
|
|
var rulesets = new RulesetStore(realmFactory, storage);
|
2021-10-11 14:45:06 +08:00
|
|
|
|
2021-12-04 21:42:01 +08:00
|
|
|
Assert.IsFalse(rulesets.AvailableRulesets.First().IsManaged);
|
|
|
|
Assert.IsFalse(rulesets.GetRuleset(0)?.IsManaged);
|
|
|
|
Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged);
|
2021-10-11 14:45:06 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|