示例#1
0
        public void RemovesListItemMessageNotification()
        {
            BaseClassMockWithChildren obj = ObjectUtilities.CreateInstanceWithRandomValues <BaseClassMockWithChildren>();

            obj.ChangeMessage();

            MessengerMonitor <BaseClassMockWithChildren> monitor = new MessengerMonitor <BaseClassMockWithChildren>(obj);

            while (obj.ChildCollection.Count > 0)
            {
                BaseClassMock child = obj.ChildCollection.Last();
                obj.ChildCollection.Remove(child);

                child.ChangeMessage(RandomUtilities.GetRandomString(obj.Message));

                Assert.AreNotEqual(child.Message, obj.Message);
                monitor.AssertMessageCount(0, false);
            }

            while (obj.ChildCollectionReadOnly.Count > 0)
            {
                BaseClassMock child = obj.ChildCollectionReadOnly.Last();
                obj.ChildCollectionReadOnly.Remove(child);

                child.ChangeMessage(RandomUtilities.GetRandomString(obj.Message));

                Assert.AreNotEqual(child.Message, obj.Message);
                monitor.AssertMessageCount(0, false);
            }
        }
示例#2
0
        public void GeneratesRandomString()
        {
            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string v1 = RandomUtilities.GetRandomString();
                Assert.IsFalse(string.IsNullOrEmpty(v1));

                string v2 = RandomUtilities.GetRandomString(v1);
                Assert.IsFalse(string.IsNullOrEmpty(v2));
                Assert.AreNotEqual(v1, v2);

                v1 = RandomUtilities.GetRandom <string>();
                Assert.IsFalse(string.IsNullOrEmpty(v1));

                v2 = RandomUtilities.GetRandom(v1);
                Assert.IsFalse(string.IsNullOrEmpty(v2));
                Assert.IsInstanceOfType(v2, typeof(string));
                Assert.AreNotEqual(v1, v2);

                v1 = RandomUtilities.GetRandom(typeof(string));
                Assert.IsFalse(string.IsNullOrEmpty(v1));
                Assert.IsInstanceOfType(v1, typeof(string));

                v2 = RandomUtilities.GetRandom(typeof(string), v1);
                Assert.IsFalse(string.IsNullOrEmpty(v2));
                Assert.IsInstanceOfType(v2, typeof(string));
                Assert.AreNotEqual(v1, v2);
            }
        }
示例#3
0
        public void RaisesListItemMessages()
        {
            BaseClassMockWithChildren obj = ObjectUtilities.CreateInstanceWithRandomValues <BaseClassMockWithChildren>();
            MessengerMonitor <BaseClassMockWithChildren> monitor = new MessengerMonitor <BaseClassMockWithChildren>(obj);

            int count = 0;

            foreach (BaseClassMock item in obj.ChildCollection)
            {
                string message = RandomUtilities.GetRandomString(item.Message);
                item.ChangeMessage(message);

                count++;

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(count, false);
            }

            monitor.ClearNotifications();
            count = 0;

            foreach (BaseClassMock item in obj.ChildCollectionReadOnly)
            {
                string message = RandomUtilities.GetRandomString(item.Message);
                item.ChangeMessage(message);

                count++;

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(count, false);
            }
        }
示例#4
0
        public void HasNoMessageWhenDeserialized()
        {
            BaseClassMockWithChildren obj = ObjectUtilities.CreateInstanceWithRandomValues <BaseClassMockWithChildren>();

            obj.ChangeMessage(RandomUtilities.GetRandomString());

            Assert.IsTrue(string.IsNullOrEmpty(ObjectUtilities.GetSerializedCopyOfObject(obj).Message));
        }
示例#5
0
        public void RaisesMessages()
        {
            BaseClassMockWithChildren obj = new BaseClassMockWithChildren();
            MessengerMonitor <BaseClassMockWithChildren> monitor = new MessengerMonitor <BaseClassMockWithChildren>(obj);

            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string message = RandomUtilities.GetRandomString(obj.Message);
                obj.ChangeMessage(message);

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(i + 1, false);
            }
        }
示例#6
0
        public void RemovesChildMessageNotification()
        {
            BaseClassMockWithChildren obj = ObjectUtilities.CreateInstanceWithRandomValues <BaseClassMockWithChildren>();

            obj.ChangeMessage();

            MessengerMonitor <BaseClassMockWithChildren> monitor = new MessengerMonitor <BaseClassMockWithChildren>(obj);

            BaseClassMock child = obj.Child;

            obj.Child = new BaseClassMock();

            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string message = RandomUtilities.GetRandomString(obj.Message);
                child.ChangeMessage(message);

                Assert.AreNotEqual(message, obj.Message);
            }

            monitor.AssertMessageCount(0, false);
        }
示例#7
0
        public void RaisesChildMessages()
        {
            BaseClassMockWithChildren obj = ObjectUtilities.CreateInstanceWithRandomValues <BaseClassMockWithChildren>();
            MessengerMonitor <BaseClassMockWithChildren> monitor = new MessengerMonitor <BaseClassMockWithChildren>(obj);

            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string message = RandomUtilities.GetRandomString(obj.Child.Message);
                obj.Child.ChangeMessage(message);

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(i + 1, false);
            }

            monitor.ClearNotifications();

            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string message = RandomUtilities.GetRandomString(obj.ChildReadOnly.Message);
                obj.ChildReadOnly.ChangeMessage(message);

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(i + 1, false);
            }

            monitor.ClearNotifications();

            for (int i = 0; i < new Random().Next(5, 20); i++)
            {
                string message = RandomUtilities.GetRandomString(obj.Message);

                obj.Child.ChangeMessage(message);
                obj.ChildReadOnly.ChangeMessage(message);

                monitor.AssertMessageNotification(message, false);
                monitor.AssertMessageCount(i + 1, false);
            }
        }