예제 #1
0
        public void Invoke()
        {
            var value = 0;
            var once  = new OnceAction(() => value++);
            var tasks = new[]
            {
                Task.Run(() => once.Invoke()),
                Task.Run(() => once.Invoke()),
                Task.Run(() => once.Invoke()),
            };

            Task.WaitAll(tasks);
            Assert.That(value, Is.EqualTo(1));
        }
예제 #2
0
        public void Invoke(string obj)
        {
            var value = "";
            var once  = new OnceAction <string>(s => value += s);
            var tasks = new[]
            {
                Task.Run(() => once.Invoke(obj)),
                Task.Run(() => once.Invoke(obj)),
                Task.Run(() => once.Invoke(obj)),
            };

            Task.WaitAll(tasks);
            Assert.That(value, Is.EqualTo(obj));
        }
예제 #3
0
        public void Content()
        {
            onceBeforeContent.Invoke();

            // Do not resize in render, otherwise the queued up Image has an invalid binding id
            var offset = GetCursorScreenPos();
            var size   = GetContentRegionAvail();

            if (Framebuffer.Width != (uint)size.X || Framebuffer.Height != (uint)size.Y)
            {
                Resize(size);
            }

            Vector4 normalColor;

            unsafe { normalColor = *GetStyleColorVec4(ImGuiCol.Button); }
            PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
            PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
            PushStyleColor(ImGuiCol.ButtonActive, normalColor);
            PushStyleColor(ImGuiCol.ButtonHovered, normalColor);
            Image(bindingHandle, size);
            PopStyleColor(2);
            PopStyleVar(2);

            ImGuizmoNET.ImGuizmo.SetRect(offset.X, offset.Y, size.X, size.Y);
        }
예제 #4
0
        public void Invoke_Twice() => Assert.That(() =>
        {
            var dummy = 0;
            var once  = new OnceAction(() => dummy++)
            {
                IgnoreTwice = false
            };
            var tasks = new[]
            {
                Task.Run(() => once.Invoke()),
                Task.Run(() => once.Invoke()),
                Task.Run(() => once.Invoke()),
            };

            Task.WaitAll(tasks);
        },
                                                  Throws.TypeOf <AggregateException>().And.InnerException.TypeOf <TwiceException>());
예제 #5
0
        public void Invoke()
        {
            var dest  = 0;
            var once  = new OnceAction(() => dest++);
            var tasks = 5.Make(i => Task.Run(() => once.Invoke()));

            Task.WaitAll(tasks.ToArray());
            Assert.That(once.Invoked, Is.True);
            Assert.That(dest, Is.EqualTo(1));
        }
예제 #6
0
        public void Invoke_Generics()
        {
            var src   = "once";
            var dest  = "";
            var once  = new OnceAction <string>(s => dest += s);
            var tasks = 5.Make(i => Task.Run(() => once.Invoke(src)));

            Task.WaitAll(tasks.ToArray());
            Assert.That(once.Invoked, Is.True);
            Assert.That(dest, Is.EqualTo(src));
        }
예제 #7
0
        public void Invoke_Twice()
        {
            var dest = 0;
            var once = new OnceAction(() => dest++)
            {
                IgnoreTwice = false
            };
            var tasks = 5.Make(i => Task.Run(() => once.Invoke()));

            Assert.That(() => Task.WaitAll(tasks.ToArray()),
                        Throws.TypeOf <AggregateException>().And.InnerException
                        .TypeOf <TwiceException>());
            Assert.That(dest, Is.EqualTo(1));
        }
예제 #8
0
        public void Invoke_Generics_Twice()
        {
            var src  = "twice";
            var dest = "";
            var once = new OnceAction <string>(s => dest += s)
            {
                IgnoreTwice = false
            };
            var tasks = 5.Make(i => Task.Run(() => once.Invoke(src)));

            Assert.That(() => Task.WaitAll(tasks.ToArray()),
                        Throws.TypeOf <AggregateException>().And.InnerException
                        .TypeOf <TwiceException>());
            Assert.That(dest, Is.EqualTo(src));
        }