Beispiel #1
0
        public void CallReadyIndividualTokens()
        {
            var called      = false;
            var abortCalled = false;
            var instance    = new TestClass();

            var watcher = new WatchedValue <TestClass>();

            watcher
            .Ready()
            .OnSuccess(value =>
            {
                called = true;
            });
            watcher
            .Ready()
            .OnSuccess(value =>
            {
                abortCalled = true;
            })
            .Abort();

            watcher.Value = instance;

            Assert.IsTrue(called);
            Assert.IsFalse(abortCalled);
        }
Beispiel #2
0
        public void CallReadyError()
        {
            var called = false;

            var watcher = new WatchedValue <TestClass>();

            watcher
            .Ready()
            .OnFailure(_ => called = true);

            watcher.Fail(new Exception());

            Assert.IsTrue(called);
        }
Beispiel #3
0
        public void MissWatcherConstructor()
        {
            var called   = false;
            var instance = new TestClass();

            var watcher = new WatchedValue <TestClass>(instance);

            watcher.OnChanged += value =>
            {
                called = true;

                Assert.AreSame(instance, value);
            };

            Assert.IsFalse(called);
        }
Beispiel #4
0
        public void CallWatcherMultiple()
        {
            var numCalled = 0;

            var watcher = new WatchedValue <TestClass>();

            watcher.OnChanged += value =>
            {
                numCalled++;
            };

            watcher.Value = new TestClass();
            watcher.Value = new TestClass();
            watcher.Value = new TestClass();

            Assert.AreEqual(3, numCalled);
        }
Beispiel #5
0
        public void CallWatcher()
        {
            var called   = false;
            var instance = new TestClass();

            var watcher = new WatchedValue <TestClass>();

            watcher.OnChanged += value =>
            {
                called = true;

                Assert.AreSame(instance, value);
            };

            watcher.Value = instance;

            Assert.IsTrue(called);
        }
Beispiel #6
0
        public void IgnoreEqualValues()
        {
            var numCalled = 0;

            var watcher = new WatchedValue <TestClass>();

            watcher.OnChanged += value =>
            {
                numCalled++;
            };

            var instance = new TestClass();

            watcher.Value = instance;
            watcher.Value = instance;
            watcher.Value = instance;

            Assert.AreEqual(1, numCalled);
        }
Beispiel #7
0
        public void CallReadyConstructor()
        {
            var called   = false;
            var instance = new TestClass();

            var watcher = new WatchedValue <TestClass>();

            watcher.Value = instance;
            watcher
            .Ready()
            .OnSuccess(value =>
            {
                called = true;

                Assert.AreSame(instance, value);
            });

            Assert.IsTrue(called);
        }