Example #1
0
        public void CanConnectToWithNonExistingExportGroup()
        {
            var importingId = new GroupCompositionId();
            var exportingId = new GroupCompositionId();

            var importEngine = new Mock<IConnectGroups>();
            var graph = new Mock<ICompositionLayer>();
            {
                graph.Setup(g => g.Contains(It.IsAny<GroupCompositionId>()))
                    .Returns<GroupCompositionId>(id => !id.Equals(exportingId));
            }

            var selector = new GroupSelector(importEngine.Object, graph.Object);
            Assert.IsFalse(
                selector.CanConnectTo(
                    importingId,
                    GroupImportDefinition.CreateDefinition("myContract", new GroupRegistrationId("a"), null, null),
                    exportingId));
        }
Example #2
0
        public void MatchingGroupsWithSelectionCriteria()
        {
            var groups = new List <GroupDefinition>
            {
                new GroupDefinition("Group1"),
                new GroupDefinition("Group2"),
                new GroupDefinition("Group3"),
            };
            var importEngine = new Mock <IConnectGroups>();
            {
                importEngine.Setup(i => i.MatchingGroups(It.IsAny <GroupImportDefinition>(), It.IsAny <IDictionary <string, object> >()))
                .Returns(groups);
            }

            var selector       = new GroupSelector(importEngine.Object, new Mock <ICompositionLayer>().Object);
            var selectedGroups = selector.MatchingGroups(new Dictionary <string, object>());

            Assert.AreEqual(groups.Count, selectedGroups.Count());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetStorageProxy"/> class.
        /// </summary>
        /// <param name="connection">The object that stores the information used to connect with the actual dataset application.</param>
        /// <param name="selector">The object that handles the selection of part groups for the current dataset.</param>
        /// <param name="compositionLayer">The object that stores the composition of the part groups and parts in the dataset.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="connection"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="compositionLayer"/> is <see langword="null" />.
        /// </exception>
        public DatasetStorageProxy(
            DatasetOnlineInformation connection,
            GroupSelector selector,
            IProxyCompositionLayer compositionLayer)
        {
            {
                Lokad.Enforce.Argument(() => connection);
                Lokad.Enforce.Argument(() => selector);
                Lokad.Enforce.Argument(() => compositionLayer);
            }

            m_Selector = selector;
            m_CompositionLayer = compositionLayer;
            m_Connection = connection;
            m_Connection.OnTimelineUpdate +=
                (s, e) =>
                {
                    m_CompositionLayer.ReloadFromDataset();
                };
        }
Example #4
0
        public void CanConnectToWithNonExistingExportGroup()
        {
            var importingId = new GroupCompositionId();
            var exportingId = new GroupCompositionId();

            var importEngine = new Mock <IConnectGroups>();
            var graph        = new Mock <ICompositionLayer>();
            {
                graph.Setup(g => g.Contains(It.IsAny <GroupCompositionId>()))
                .Returns <GroupCompositionId>(id => !id.Equals(exportingId));
            }

            var selector = new GroupSelector(importEngine.Object, graph.Object);

            Assert.IsFalse(
                selector.CanConnectTo(
                    importingId,
                    GroupImportDefinition.CreateDefinition("myContract", new GroupRegistrationId("a"), null, null),
                    exportingId));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetStorageProxy"/> class.
        /// </summary>
        /// <param name="connection">The object that stores the information used to connect with the actual dataset application.</param>
        /// <param name="selector">The object that handles the selection of part groups for the current dataset.</param>
        /// <param name="compositionLayer">The object that stores the composition of the part groups and parts in the dataset.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="connection"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="compositionLayer"/> is <see langword="null" />.
        /// </exception>
        public DatasetStorageProxy(
            DatasetOnlineInformation connection,
            GroupSelector selector,
            IProxyCompositionLayer compositionLayer)
        {
            {
                Lokad.Enforce.Argument(() => connection);
                Lokad.Enforce.Argument(() => selector);
                Lokad.Enforce.Argument(() => compositionLayer);
            }

            m_Selector                     = selector;
            m_CompositionLayer             = compositionLayer;
            m_Connection                   = connection;
            m_Connection.OnTimelineUpdate +=
                (s, e) =>
            {
                m_CompositionLayer.ReloadFromDataset();
            };
        }
Example #6
0
        public void MatchingGroupsWithGroupImport()
        {
            var groups = new List <GroupDefinition>
            {
                new GroupDefinition("Group1"),
                new GroupDefinition("Group2"),
                new GroupDefinition("Group3"),
            };
            var importEngine = new Mock <IConnectGroups>();
            {
                importEngine.Setup(i => i.MatchingGroups(It.IsAny <GroupImportDefinition>(), It.IsAny <IDictionary <string, object> >()))
                .Returns(new List <GroupDefinition> {
                    groups[0], groups[1]
                });
            }

            var selector       = new GroupSelector(importEngine.Object, new Mock <ICompositionLayer>().Object);
            var selectedGroups = selector.MatchingGroups(GroupImportDefinition.CreateDefinition("myContract", groups[0].Id, null, null));

            Assert.AreEqual(2, selectedGroups.Count());
        }
Example #7
0
        public void CanConnectToWithNonmatchingGroups()
        {
            var groups = new List <GroupDefinition>
            {
                new GroupDefinition("Group1"),
                new GroupDefinition("Group2"),
                new GroupDefinition("Group3"),
            };
            var importEngine = new Mock <IConnectGroups>();
            {
                importEngine.Setup(i => i.Accepts(It.IsAny <GroupImportDefinition>(), It.IsAny <GroupExportDefinition>()))
                .Returns(false);
                importEngine.Setup(i => i.ExportPassesSelectionCriteria(It.IsAny <GroupExportDefinition>(), It.IsAny <IDictionary <string, object> >()))
                .Returns(true);
            }

            var selector = new GroupSelector(importEngine.Object, new Mock <ICompositionLayer>().Object);

            Assert.IsFalse(
                selector.CanConnectTo(
                    new GroupCompositionId(),
                    GroupImportDefinition.CreateDefinition("myContract", groups[0].Id, null, null),
                    new GroupCompositionId()));
        }
Example #8
0
        public void MatchingGroupsWithSelectionCriteria()
        {
            var groups = new List<GroupDefinition>
                {
                    new GroupDefinition("Group1"),
                    new GroupDefinition("Group2"),
                    new GroupDefinition("Group3"),
                };
            var importEngine = new Mock<IConnectGroups>();
            {
                importEngine.Setup(i => i.MatchingGroups(It.IsAny<GroupImportDefinition>(), It.IsAny<IDictionary<string, object>>()))
                    .Returns(groups);
            }

            var selector = new GroupSelector(importEngine.Object, new Mock<ICompositionLayer>().Object);
            var selectedGroups = selector.MatchingGroups(new Dictionary<string, object>());
            Assert.AreEqual(groups.Count, selectedGroups.Count());
        }
Example #9
0
        public void MatchingGroupsWithGroupImport()
        {
            var groups = new List<GroupDefinition>
                {
                    new GroupDefinition("Group1"),
                    new GroupDefinition("Group2"),
                    new GroupDefinition("Group3"),
                };
            var importEngine = new Mock<IConnectGroups>();
            {
                importEngine.Setup(i => i.MatchingGroups(It.IsAny<GroupImportDefinition>(), It.IsAny<IDictionary<string, object>>()))
                    .Returns(new List<GroupDefinition> { groups[0], groups[1] });
            }

            var selector = new GroupSelector(importEngine.Object, new Mock<ICompositionLayer>().Object);
            var selectedGroups = selector.MatchingGroups(GroupImportDefinition.CreateDefinition("myContract", groups[0].Id, null, null));
            Assert.AreEqual(2, selectedGroups.Count());
        }
Example #10
0
        public void CanConnectToWithNonmatchingGroups()
        {
            var groups = new List<GroupDefinition>
                {
                    new GroupDefinition("Group1"),
                    new GroupDefinition("Group2"),
                    new GroupDefinition("Group3"),
                };
            var importEngine = new Mock<IConnectGroups>();
            {
                importEngine.Setup(i => i.Accepts(It.IsAny<GroupImportDefinition>(), It.IsAny<GroupExportDefinition>()))
                    .Returns(false);
                importEngine.Setup(i => i.ExportPassesSelectionCriteria(It.IsAny<GroupExportDefinition>(), It.IsAny<IDictionary<string, object>>()))
                    .Returns(true);
            }

            var selector = new GroupSelector(importEngine.Object, new Mock<ICompositionLayer>().Object);
            Assert.IsFalse(
                selector.CanConnectTo(
                    new GroupCompositionId(),
                    GroupImportDefinition.CreateDefinition("myContract", groups[0].Id, null, null),
                    new GroupCompositionId()));
        }