Пример #1
0
        public void A_Invoke_Parameters()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            ee.Invoke("SetName", "Test");

            // Assert
            Assert.AreEqual("Test", a.Name);
        }
Пример #2
0
        public async Task A_Invoke_Async_Parameters()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            await ee.InvokeAsync("SetName", "Test");

            // Assert
            Assert.AreEqual("Test", a.Name);
        }
Пример #3
0
        public async Task A_Invoke_Async()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            await ee.InvokeAsync("Update");

            // Assert
            Assert.IsTrue(a.Enabled);
            Assert.AreEqual(1, a.UpdateCalled);
        }
Пример #4
0
        public void A_Invoke()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            ee.Invoke("Update");

            // Assert
            Assert.IsTrue(a.Enabled);
            Assert.AreEqual(1, a.UpdateCalled);
        }
Пример #5
0
        public async Task A_Acquire_Async()
        {
            // Arrange
            var ee = new EventHandler();

            new A(ee);

            // Act
            var result = await ee.AcquireAsync("Update");

            // Assert
            CollectionAssert.AreEqual(result.ToArray(), new object[] { null });
        }
Пример #6
0
        public void B_Invoke()
        {
            // Arrange
            var ee = new EventHandler();
            var b  = new B(ee);

            // Act
            ee.Invoke("Update");

            // Assert
            Assert.IsTrue(b.Enabled);
            Assert.AreEqual(10, b.UpdateCalled);
        }
Пример #7
0
        public void A_Invoke_Static()
        {
            // Arrange
            var ee = new EventHandler();

            new A(ee);

            // Act
            var result = ee.Acquire <bool>("StaticUpdate");

            // Assert
            CollectionAssert.AreNotEqual(new[] { true }, result.ToArray());
        }
Пример #8
0
        public void A_Invoke_Disabled()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee, false);

            // Act
            ee.Invoke("Update");

            // Assert
            Assert.IsFalse(a.Enabled);
            Assert.AreEqual(0, a.UpdateCalled);
        }
Пример #9
0
        public void A_Acquire()
        {
            // Arrange
            var ee = new EventHandler();

            new A(ee);

            // Act
            var result = ee.Acquire("Update");

            // Assert
            CollectionAssert.AreEqual(result.ToArray(), new object[] { null });
        }
Пример #10
0
        public void AB_Invoke_EndEarly()
        {
            // Arrange
            var ee = new EventHandler();
            var b  = new B(ee);
            var a  = new A(ee);

            // Act
            ee.Invoke("PartialUpdate");

            // Assert
            Assert.AreEqual(0, a.UpdateCalled);
            Assert.AreEqual(10, b.UpdateCalled);
        }
Пример #11
0
        public void A_Invoke_Property()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            ee.Invoke("Update");
            var result = ee.Acquire("UpdateCalled");

            // Assert
            Assert.AreEqual(1, a.UpdateCalled);
            CollectionAssert.AreNotEqual(new[] { true }, result.ToArray());
        }
Пример #12
0
        public void A_Acquire_T()
        {
            // Arrange
            var ee = new EventHandler();

            new A(ee);

            // Act
            ee.Invoke("Update");
            var result1 = ee.Acquire <bool>("GetUpdate");
            var result2 = ee.Acquire <int>("GetUpdate");

            // Assert
            CollectionAssert.AreEqual(result1.ToArray(), new bool[] { });
            CollectionAssert.AreEqual(result2.ToArray(), new int[] { 1 });
        }
Пример #13
0
        public void A_Invoke_InScope()
        {
            // Arrange
            var ee = new EventHandler();
            var a  = new A(ee);

            // Act
            using (a)
            {
                ee.Invoke("Update");
            }
            ee.Invoke("Update");

            // Assert
            Assert.IsFalse(a.Enabled);
            Assert.AreEqual(1, a.UpdateCalled);
        }
Пример #14
0
        public async Task A_Acquire_T_Async()
        {
            // Arrange
            var ee = new EventHandler();

            new A(ee);

            // Act
            await ee.InvokeAsync("Update");

            var result1 = await ee.AcquireAsync <bool>("GetUpdate");

            var result2 = await ee.AcquireAsync <int>("GetUpdate");

            // Assert
            CollectionAssert.AreEqual(result1.ToArray(), new bool[] { });
            CollectionAssert.AreEqual(result2.ToArray(), new int[] { 1 });
        }