public void Value()
        {
            {
                var actual = new OrderControlElement <string?>();
                actual.Value.IsNull();

                actual.Value = "hello world";
                actual.Value.Is("hello world");

                actual.Value = "tokeiya3";
                actual.Value.Is("tokeiya3");

                actual.Value = default;
                actual.Value.IsNull();
            }

            {
                var actual = new OrderControlElement <string>();
                actual.Value.IsNull();

                actual.Value = "42";
                actual.Value.Is("42");

                actual.Value = "114514";
                actual.Value.Is("114514");
            }
        }
        public void InitialState()
        {
            var actual = new OrderControlElement <string>();

            actual.Value.Is(default(string));
            actual.AheadElement.IsNull();
            actual.BehindElement.IsNull();
        }
        public void MoveToAhead(OrderControlElement <T> pivot)
        {
            //Remove
            AheadElement !.BehindElement = BehindElement;
            if (!(BehindElement is null))
            {
                BehindElement.AheadElement = AheadElement;
            }

            //Insert
            if (!(pivot.AheadElement is null))
            {
                pivot.AheadElement.BehindElement = this;
            }
            AheadElement       = pivot.AheadElement;
            BehindElement      = pivot;
            pivot.AheadElement = this;
        }
        public void AddToBehind()
        {
            var actual = new OrderControlElement <string> {
                Value = "42"
            };
            var pivot = new OrderControlElement <string> {
                Value = "114514"
            };

            actual.AddToBehind(pivot);

            pivot.BehindElement.IsSameReferenceAs(actual);
            pivot.AheadElement.IsNull();

            actual.BehindElement.IsNull();
            actual.AheadElement.IsSameReferenceAs(pivot);

            var ary = Enumerable.Range(1, 4).Select(i => new OrderControlElement <string> {
                Value = i.ToString()
            })
                      .ToArray();

            for (int i = 0; i < ary.Length - 1; i++)
            {
                ary[i].AddToBehind(ary[i + 1]);
            }

            for (int i = 1; i < ary.Length - 1; i++)
            {
                ary[i].AheadElement.IsSameReferenceAs(ary[i + 1]);
                ary[i].BehindElement.IsSameReferenceAs(ary[i - 1]);
            }

            ary[0].AheadElement.IsSameReferenceAs(ary[1]);
            ary[0].BehindElement.IsNull();

            ary[3].AheadElement.IsNull();
            ary[3].BehindElement.IsSameReferenceAs(ary[2]);
        }
 public void AddToBehind(OrderControlElement <T> pivot)
 {
     pivot.BehindElement = this;
     AheadElement        = pivot;
 }
 static void Verify <T>(OrderControlElement <T> ahead, OrderControlElement <T> behind) where T : class
 {
     ahead.BehindElement.IsSameReferenceAs(behind);
     behind.AheadElement.IsSameReferenceAs(ahead);
 }