2021-10-11 06:45:06 +00: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 10:07:21 +00:00
|
|
|
using osu.Game.Rulesets;
|
2021-10-11 06:45:06 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Database
|
|
|
|
{
|
|
|
|
public class RulesetStoreTests : RealmTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestCreateStore()
|
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 06:45:06 +00:00
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
var rulesets = new RulesetStore(realm, storage);
|
2021-10-11 06:45:06 +00:00
|
|
|
|
|
|
|
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
|
2022-01-24 10:59:58 +00:00
|
|
|
Assert.AreEqual(4, realm.Realm.All<RulesetInfo>().Count());
|
2021-10-11 06:45:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCreateStoreTwiceDoesntAddRulesetsAgain()
|
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 06:45:06 +00:00
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
var rulesets = new RulesetStore(realm, storage);
|
|
|
|
var rulesets2 = new RulesetStore(realm, storage);
|
2021-10-11 06:45:06 +00:00
|
|
|
|
|
|
|
Assert.AreEqual(4, rulesets.AvailableRulesets.Count());
|
|
|
|
Assert.AreEqual(4, rulesets2.AvailableRulesets.Count());
|
|
|
|
|
|
|
|
Assert.AreEqual(rulesets.AvailableRulesets.First(), rulesets2.AvailableRulesets.First());
|
2022-01-24 10:59:58 +00:00
|
|
|
Assert.AreEqual(4, realm.Realm.All<RulesetInfo>().Count());
|
2021-10-11 06:45:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRetrievedRulesetsAreDetached()
|
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
RunTestWithRealm((realm, storage) =>
|
2021-10-11 06:45:06 +00:00
|
|
|
{
|
2022-01-24 10:59:58 +00:00
|
|
|
var rulesets = new RulesetStore(realm, storage);
|
2021-10-11 06:45:06 +00:00
|
|
|
|
2021-12-04 13:42:01 +00:00
|
|
|
Assert.IsFalse(rulesets.AvailableRulesets.First().IsManaged);
|
|
|
|
Assert.IsFalse(rulesets.GetRuleset(0)?.IsManaged);
|
|
|
|
Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged);
|
2021-10-11 06:45:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|