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()
|
|
|
|
{
|
2022-01-24 18:59:58 +08:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 14:45:06 +08:00
|
|
|
{
|
2022-02-16 16:13:51 +08:00
|
|
|
var rulesets = new RealmRulesetStore(realm, storage);
|
2021-10-11 14:45:06 +08:00
|
|
|
|
|
|
|
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
|
2022-01-24 18:59:58 +08:00
|
|
|
Assert.AreEqual(4, realm.Realm.All<RulesetInfo>().Count());
|
2021-10-11 14:45:06 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCreateStoreTwiceDoesntAddRulesetsAgain()
|
|
|
|
{
|
2022-01-24 18:59:58 +08:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 14:45:06 +08:00
|
|
|
{
|
2022-02-16 16:13:51 +08:00
|
|
|
var rulesets = new RealmRulesetStore(realm, storage);
|
|
|
|
var rulesets2 = new RealmRulesetStore(realm, 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());
|
2022-01-24 18:59:58 +08:00
|
|
|
Assert.AreEqual(4, realm.Realm.All<RulesetInfo>().Count());
|
2021-10-11 14:45:06 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRetrievedRulesetsAreDetached()
|
|
|
|
{
|
2022-01-24 18:59:58 +08:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 14:45:06 +08:00
|
|
|
{
|
2022-02-16 16:13:51 +08:00
|
|
|
var rulesets = new RealmRulesetStore(realm, 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
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|