-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1490 from andy840119/apply-deep-clone-in-some-hit…
…-object Implement `IDeepCloneable<T>` for some hit-object for better copy experience.
- Loading branch information
Showing
7 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using NUnit.Framework; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Rulesets.Karaoke.Objects.Types; | ||
using osu.Game.Rulesets.Karaoke.Tests.Asserts; | ||
using osu.Game.Rulesets.Karaoke.Tests.Helper; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Objects | ||
{ | ||
public class LyricTest | ||
{ | ||
[TestCase] | ||
public void TestClone() | ||
{ | ||
var referencedLyric = new Lyric(); | ||
|
||
var lyric = new Lyric | ||
{ | ||
ID = 1, | ||
Text = "カラオケ", | ||
TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }), | ||
RubyTags = TestCaseTagHelper.ParseRubyTags(new[] { "[0,1]:か", "[1,2]:ら", "[2,3]:お", "[3,4]:け" }), | ||
RomajiTags = TestCaseTagHelper.ParseRomajiTags(new[] { "[0,2]:ka", "[2,4]:ra", "[4,5]:o", "[5,7]:ke" }), | ||
StartTime = 1000, | ||
Duration = 4000, | ||
Singers = new[] { 1, 2 }, | ||
Translates = new Dictionary<CultureInfo, string> | ||
{ | ||
{ new CultureInfo("en-US"), "karaoke" } | ||
}, | ||
Language = new CultureInfo("ja-JP"), | ||
Order = 1, | ||
Lock = LockState.None, | ||
ReferenceLyric = referencedLyric | ||
}; | ||
|
||
var clonedLyric = lyric.DeepClone(); | ||
|
||
Assert.AreEqual(clonedLyric.ID, lyric.ID); | ||
|
||
Assert.AreNotSame(clonedLyric.TextBindable, lyric.TextBindable); | ||
Assert.AreEqual(clonedLyric.Text, lyric.Text); | ||
|
||
Assert.AreNotSame(clonedLyric.TimeTagsVersion, lyric.TimeTagsVersion); | ||
Assert.AreNotSame(clonedLyric.TimeTagsBindable, lyric.TimeTagsBindable); | ||
TimeTagAssert.ArePropertyEqual(clonedLyric.TimeTags, lyric.TimeTags); | ||
|
||
Assert.AreNotSame(clonedLyric.RubyTagsVersion, lyric.RubyTagsVersion); | ||
Assert.AreNotSame(clonedLyric.RubyTagsBindable, lyric.RubyTagsBindable); | ||
TextTagAssert.ArePropertyEqual(clonedLyric.RubyTags, lyric.RubyTags); | ||
|
||
Assert.AreNotSame(clonedLyric.RomajiTagsVersion, lyric.RomajiTagsVersion); | ||
Assert.AreNotSame(clonedLyric.RomajiTagsBindable, lyric.RomajiTagsBindable); | ||
TextTagAssert.ArePropertyEqual(clonedLyric.RomajiTags, lyric.RomajiTags); | ||
|
||
Assert.AreNotSame(clonedLyric.StartTimeBindable, lyric.StartTimeBindable); | ||
Assert.AreEqual(clonedLyric.StartTime, lyric.StartTime); | ||
|
||
Assert.AreEqual(clonedLyric.Duration, lyric.Duration); | ||
|
||
Assert.AreNotSame(clonedLyric.SingersBindable, lyric.SingersBindable); | ||
CollectionAssert.AreEquivalent(clonedLyric.Singers, lyric.Singers); | ||
|
||
Assert.AreNotSame(clonedLyric.TranslateTextBindable, lyric.TranslateTextBindable); | ||
CollectionAssert.AreEquivalent(clonedLyric.Translates, lyric.Translates); | ||
|
||
Assert.AreNotSame(clonedLyric.LanguageBindable, lyric.LanguageBindable); | ||
Assert.AreEqual(clonedLyric.Language, lyric.Language); | ||
|
||
Assert.AreNotSame(clonedLyric.OrderBindable, lyric.OrderBindable); | ||
Assert.AreEqual(clonedLyric.Order, lyric.Order); | ||
|
||
Assert.AreNotSame(clonedLyric.LockBindable, lyric.LockBindable); | ||
Assert.AreEqual(clonedLyric.Lock, lyric.Lock); | ||
|
||
Assert.AreNotSame(clonedLyric.ReferenceLyricBindable, lyric.ReferenceLyricBindable); | ||
Assert.AreSame(clonedLyric.ReferenceLyric, lyric.ReferenceLyric); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using NUnit.Framework; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Objects | ||
{ | ||
public class NoteTest | ||
{ | ||
[TestCase] | ||
public void TestClone() | ||
{ | ||
var parentLyric = new Lyric(); | ||
|
||
var note = new Note | ||
{ | ||
Text = "ノート", | ||
RubyText = "Note", | ||
Display = true, | ||
StartTime = 1000, | ||
Duration = 500, | ||
ParentLyric = parentLyric | ||
}; | ||
|
||
var clonedNote = note.DeepClone(); | ||
|
||
Assert.AreNotSame(clonedNote.TextBindable, note.TextBindable); | ||
Assert.AreEqual(clonedNote.Text, note.Text); | ||
|
||
Assert.AreNotSame(clonedNote.RubyTextBindable, note.RubyTextBindable); | ||
Assert.AreEqual(clonedNote.RubyText, note.RubyText); | ||
|
||
Assert.AreNotSame(clonedNote.DisplayBindable, note.DisplayBindable); | ||
Assert.AreEqual(clonedNote.Display, note.Display); | ||
|
||
Assert.AreNotSame(clonedNote.ToneBindable, note.ToneBindable); | ||
Assert.AreEqual(clonedNote.Tone, note.Tone); | ||
|
||
Assert.AreNotSame(clonedNote.StartTimeBindable, note.StartTimeBindable); | ||
Assert.AreEqual(clonedNote.StartTime, note.StartTime); | ||
|
||
Assert.AreEqual(clonedNote.Duration, note.Duration); | ||
|
||
Assert.AreEqual(clonedNote.StartIndex, note.StartIndex); | ||
|
||
Assert.AreEqual(clonedNote.EndIndex, note.EndIndex); | ||
|
||
Assert.AreSame(clonedNote.ParentLyric, note.ParentLyric); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters