public void RegisterNotificationForRequiredSubjectGroupForSecondGroup()
        {
            var storage = new InteractionSubjectGroupStorage();

            var subject      = new CommunicationSubject("a");
            var firstType    = typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler);
            var firstVersion = new Version(1, 0);
            var firstGroupId = "group1";

            storage.RegisterNotificationForRequiredSubjectGroup(subject, firstType, firstVersion, firstGroupId);

            var secondType    = typeof(InteractionExtensionsTest.IMockNotificationSetWithTypedEventHandler);
            var secondVersion = new Version(1, 0);
            var secondGroupId = "group2";

            storage.RegisterNotificationForRequiredSubjectGroup(subject, secondType, secondVersion, secondGroupId);
            Assert.IsTrue(storage.RequiredSubjects().Any(s => s.Equals(subject)));
            Assert.IsTrue(storage.Subjects().Any(s => s.Equals(subject)));
            Assert.IsTrue(storage.ContainsGroupRequirementsForSubject(subject));
            Assert.IsFalse(storage.ContainsGroupProvisionsForSubject(subject));

            var group = storage.GroupRequirementsFor(subject);

            Assert.AreSame(subject, group.Subject);
            Assert.AreEqual(0, group.Commands.Length);
            Assert.AreEqual(2, group.Notifications.Length);
            Assert.IsTrue(
                group.Notifications[0].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                firstType.FullName,
                                firstType.Assembly.GetName()),
                            new Version(1, 0)))));
            Assert.IsFalse(
                group.Notifications[0].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                secondType.FullName,
                                secondType.Assembly.GetName()),
                            new Version(1, 0)))));

            Assert.IsTrue(
                group.Notifications[1].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                secondType.FullName,
                                secondType.Assembly.GetName()),
                            new Version(1, 0)))));
            Assert.IsFalse(
                group.Notifications[1].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                firstType.FullName,
                                firstType.Assembly.GetName()),
                            new Version(1, 0)))));
        }
        public void RegisterCommandForRequiredSubjectGroupWithFirstCommand()
        {
            var storage = new InteractionSubjectGroupStorage();

            var subject = new CommunicationSubject("a");
            var type    = typeof(InteractionExtensionsTest.IMockCommandSetWithTaskReturn);
            var version = new Version(1, 0);
            var groupId = "group1";

            storage.RegisterCommandForRequiredSubjectGroup(subject, type, version, groupId);
            Assert.IsTrue(storage.RequiredSubjects().Any(s => s.Equals(subject)));
            Assert.IsTrue(storage.Subjects().Any(s => s.Equals(subject)));
            Assert.IsTrue(storage.ContainsGroupRequirementsForSubject(subject));
            Assert.IsFalse(storage.ContainsGroupProvisionsForSubject(subject));

            var group = storage.GroupRequirementsFor(subject);

            Assert.AreSame(subject, group.Subject);
            Assert.AreEqual(0, group.Notifications.Length);
            Assert.AreEqual(1, group.Commands.Length);
            Assert.IsTrue(
                group.Commands[0].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                type.FullName,
                                type.Assembly.GetName()),
                            new Version(1, 0)))));
        }