Пример #1
0
        public void AddingItemsWhenExpired_ThrowException()
        {
            // Arrange
            bool complete = false;
            ExpirableList <string> expirableList = new ExpirableList <string>(500, 3);

            expirableList.ListFinished += (sender, e) => { complete = e.IsListComplete; };
            expirableList.Add("item1");
            expirableList.Add("item2");

            // Execute
            System.Threading.Thread.Sleep(600);
            expirableList.Add("item3");
        }
Пример #2
0
        public void ExpireListBeforeComplete_RaiseFinishIncompletedEvent()
        {
            // Arrange
            bool raised = false;
            ExpirableList <string> expirableList = new ExpirableList <string>(500, 3);

            expirableList.ListFinished += (sender, e) =>
            {
                Assert.IsFalse(e.IsListComplete);
                Assert.AreEqual(2, e.Items.Count());
                raised = true;
            };

            expirableList.Add("item1");
            expirableList.Add("item2");

            // Execute
            System.Threading.Thread.Sleep(600);

            // Assert
            Assert.IsTrue(raised);
            Assert.IsTrue(expirableList.IsFinished);
        }