Exemple #1
0
        public void TestChangeOrder(int[] orders, int oldOrder, int nowOrder, int[] movingOrders, int[] newOrder)
        {
            try
            {
                var objects = orders?.Select(x => new TestOrderObject {
                    Order = x
                }).ToArray();

                // record order index change step.
                var movingStepResult = new List <int>();

                // This utils only change order property.
                OrderUtils.ChangeOrder(objects, oldOrder, nowOrder, (_, o, _) =>
                {
                    movingStepResult.Add(o);
                });

                // change order result.
                var result = objects?.Select(x => x.Order).ToArray();
                Assert.AreEqual(result, newOrder);

                // should check moving order step also.
                Assert.AreEqual(movingStepResult.ToArray(), movingOrders);
            }
            catch
            {
                Assert.IsNull(newOrder);
            }
        }
Exemple #2
0
        public void ChangeLyricOrder(Lyric lyric, int newIndex)
        {
            var oldOrder = lyric.Order;
            var newOrder = newIndex + 1; // order is start from 1

            OrderUtils.ChangeOrder(Lyrics.ToArray(), oldOrder, newOrder, (switchSinger, oldOrder, newOrder) =>
            {
                // todo : not really sure should call update?
            });
        }