試験の土台を追加する
このコミットが含まれているのは:
2ファイル変更
+133
検索条件に一致するファイルはありません
@@ -0,0 +1,129 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using YukkuriMovieMaker.UndoRedo;
|
||||
|
||||
namespace UndoTree.Tests;
|
||||
|
||||
public sealed class Part : UndoRedoable
|
||||
{
|
||||
int value;
|
||||
|
||||
public Part(string label) => Label = label;
|
||||
|
||||
public string Label { get; }
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => value;
|
||||
set => Set(ref this.value, value);
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Label}:{Value}";
|
||||
}
|
||||
|
||||
public sealed class Document : UndoRedoable
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
public Document() => SubscribeObservableCollectionChangedAndChild(Parts);
|
||||
|
||||
public int X
|
||||
{
|
||||
get => x;
|
||||
set => Set(ref x, value);
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get => y;
|
||||
set => Set(ref y, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<Part> Parts { get; } = [];
|
||||
|
||||
public string Snapshot() => $"X={X} Y={Y} Parts=[{string.Join(",", Parts)}]";
|
||||
}
|
||||
|
||||
public sealed class Sheet : UndoRedoable
|
||||
{
|
||||
ImmutableList<Part> parts = [];
|
||||
int x;
|
||||
|
||||
public int X
|
||||
{
|
||||
get => x;
|
||||
set => Set(ref x, value);
|
||||
}
|
||||
|
||||
public ImmutableList<Part> Parts
|
||||
{
|
||||
get => parts;
|
||||
set => Set(ref parts, value);
|
||||
}
|
||||
|
||||
public void Seed(ImmutableList<Part> seeded) => parts = seeded;
|
||||
|
||||
public string Snapshot() => $"X={X} Parts=[{string.Join(",", Parts.Select(part => part.Label))}]";
|
||||
}
|
||||
|
||||
public sealed class Group : UndoRedoable
|
||||
{
|
||||
Document? child;
|
||||
|
||||
public Document? Child
|
||||
{
|
||||
get => child;
|
||||
set => Set(ref child, value);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Labelled : UndoRedoable
|
||||
{
|
||||
int amount;
|
||||
int broken;
|
||||
|
||||
[Display(Name = "Visible name")]
|
||||
public int Amount
|
||||
{
|
||||
get => amount;
|
||||
set => Set(ref amount, value);
|
||||
}
|
||||
|
||||
[Display(Name = "Missing", ResourceType = typeof(Texts))]
|
||||
public int Broken
|
||||
{
|
||||
get => broken;
|
||||
set => Set(ref broken, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Histories
|
||||
{
|
||||
public static (UndoRedoManager Manager, Document Document) NewDocument(params string[] partLabels)
|
||||
{
|
||||
var document = new Document();
|
||||
foreach (var label in partLabels)
|
||||
document.Parts.Add(new Part(label));
|
||||
|
||||
var manager = new UndoRedoManager();
|
||||
manager.Subscribe(document);
|
||||
return (manager, document);
|
||||
}
|
||||
|
||||
public static (UndoRedoManager Manager, Sheet Sheet) NewSheet(params string[] partLabels)
|
||||
{
|
||||
var sheet = new Sheet();
|
||||
sheet.Seed([.. partLabels.Select(label => new Part(label))]);
|
||||
var manager = new UndoRedoManager();
|
||||
manager.Subscribe(sheet);
|
||||
return (manager, sheet);
|
||||
}
|
||||
|
||||
public static void Edit(UndoRedoManager manager, Action change)
|
||||
{
|
||||
change();
|
||||
manager.Record();
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,10 @@
|
||||
<HintPath>$(YMM4DirPath)Vortice.Mathematics.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="YukkuriMovieMaker">
|
||||
<HintPath>$(YMM4DirPath)YukkuriMovieMaker.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="YukkuriMovieMaker.Controls">
|
||||
<HintPath>$(YMM4DirPath)YukkuriMovieMaker.Controls.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする