public void CompletedEvent()
        {
            // Arrange
            bool premature = true;
            bool eventFired = false;
            OperationCounter ops = new OperationCounter();
            ops.Completed += (sender, eventArgs) =>
            {
                if (premature)
                {
                    Assert.True(false, "Event fired too early!");
                }
                if (eventFired)
                {
                    Assert.True(false, "Event fired multiple times.");
                }

                Assert.Equal(ops, sender);
                Assert.Equal(eventArgs, EventArgs.Empty);
                eventFired = true;
            };

            // Act & assert
            ops.Increment(); // should not fire event (will throw exception)
            premature = false;

            ops.Decrement(); // should fire event
            Assert.True(eventFired);

            ops.Increment(); // should not fire event (will throw exception)
        }
        public void CompletedEvent()
        {
            // Arrange
            bool             premature  = true;
            bool             eventFired = false;
            OperationCounter ops        = new OperationCounter();

            ops.Completed += (sender, eventArgs) =>
            {
                if (premature)
                {
                    Assert.True(false, "Event fired too early!");
                }
                if (eventFired)
                {
                    Assert.True(false, "Event fired multiple times.");
                }

                Assert.Equal(ops, sender);
                Assert.Equal(eventArgs, EventArgs.Empty);
                eventFired = true;
            };

            // Act & assert
            ops.Increment(); // should not fire event (will throw exception)
            premature = false;

            ops.Decrement(); // should fire event
            Assert.True(eventFired);

            ops.Increment(); // should not fire event (will throw exception)
        }
        public void DecrementWithNoArguments() {
            // Arrange
            OperationCounter ops = new OperationCounter();

            // Act
            int returned = ops.Decrement();
            int newCount = ops.Count;

            // Assert
            Assert.AreEqual(-1, returned);
            Assert.AreEqual(-1, newCount);
        }
        public void DecrementWithIntegerArgument()
        {
            // Arrange
            OperationCounter ops = new OperationCounter();

            // Act
            int returned = ops.Decrement(3);
            int newCount = ops.Count;

            // Assert
            Assert.Equal(-3, returned);
            Assert.Equal(-3, newCount);
        }
        public void DecrementWithNoArguments()
        {
            // Arrange
            OperationCounter ops = new OperationCounter();

            // Act
            int returned = ops.Decrement();
            int newCount = ops.Count;

            // Assert
            Assert.Equal(-1, returned);
            Assert.Equal(-1, newCount);
        }
Beispiel #6
0
        public void DecrementWithIntegerArgument()
        {
            // Arrange
            OperationCounter ops = new OperationCounter();

            // Act
            int returned = ops.Decrement(3);
            int newCount = ops.Count;

            // Assert
            Assert.AreEqual(-3, returned);
            Assert.AreEqual(-3, newCount);
        }