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

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

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

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

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

            var group = storage.GroupProvisionsFor(subject);

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

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

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

            storage.RegisterNotificationForRequiredSubjectGroup(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.Commands.Length);
            Assert.AreEqual(1, group.Notifications.Length);
            Assert.IsTrue(
                group.Notifications[0].IsPartialMatch(
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                type.FullName,
                                type.Assembly.GetName()),
                            new Version(1, 0)))));
        }