예제 #1
0
        public void Create()
        {
            Guid id = new Guid();
            Type expectedType = typeof(IdentNodeCoresElement);
            IElementDefinition defType = new ElementDefinition(Guid.NewGuid());

            IdentNodeCoresElFactory fac = new IdentNodeCoresElFactory();
            IdentNodeCoresElement el = fac.Create(id, defType);

            Assert.NotNull(el);
            Assert.IsType(expectedType, el);
            Assert.NotNull(el.ParamMgr);
            Assert.NotNull(el.ParamMgr.Bag);
            Assert.NotNull(el.ParamMgr.ParamVarMapper);
            Assert.NotNull(el.InPortMgr);
            Assert.Equal(1, el.InPortMgr.Count);
            Assert.IsType(typeof(BlueSpider.Common.Ports.IInputNetworkPort), el.InPortMgr[0]);
            Assert.NotNull(el.OutPortMgr);
            Assert.Equal(1, el.OutPortMgr.Count);
            Assert.IsType(typeof(BlueSpider.Common.Ports.IOutputNetworkPort), el.OutPortMgr[0]);
            Assert.NotNull(el.SettingsMgr);
            Assert.NotNull(el.OptionsMgr);
            Assert.Equal(el.TypeId, defType.ElementTypeId);
            Assert.Equal(el.Id, id);
        }
        public void Create_JoinerForNetworkPropertiesElement()
        {
            var _fac = new SecondaryViewJoinerFactory();
            Guid id = new Guid();
            Type expectedType = typeof(NetworkPropertiesElementJoiner);
            IElementDefinition defType = new ElementDefinition(Guid.NewGuid());

            Standard.Info.NetworkProperties.NetworkPropertiesElement el = new Standard.Info.NetworkProperties.NetworkPropertiesElement(id, defType);
            ISecondaryViewJoiner joiner = _fac.Create(el);
            Assert.NotNull(joiner);
            Assert.IsType(expectedType, joiner);
        }
예제 #3
0
        public void Create_ByTicket()
        {
            Guid typeId = new Guid();
            Type expectedType = typeof(IdentNodeCoresElement);
            IElementDefinition defType = new ElementDefinition(typeId);

            BlueSpider.Common.Persistance.ElementTicket ticket = new BlueSpider.Common.Persistance.ElementTicket();
            ticket.ElementId = Guid.NewGuid();
            ticket.TypeId = typeId;
            ticket.FxId = Guid.NewGuid();
            ticket.ParamMgrId = Guid.NewGuid();
            ticket.InputPortMgrId = Guid.NewGuid();
            ticket.OutputPortMgrId = Guid.NewGuid();
            ticket.InputPortIds = new Guid[] { Guid.NewGuid() };
            ticket.OutputPortIds = new Guid[] { Guid.NewGuid()};

            IdentNodeCoresElFactory fac = new IdentNodeCoresElFactory();
            IdentNodeCoresElement el = fac.Create(ticket, defType);

            Assert.NotNull(el);
            Assert.IsType(expectedType, el);
            Assert.NotNull(el.ParamMgr);
            Assert.NotNull(el.ParamMgr.Bag);
            Assert.NotNull(el.ParamMgr.ParamVarMapper);
            Assert.NotNull(el.InPortMgr);
            Assert.Equal(1, el.InPortMgr.Count);
            Assert.IsType(typeof(BlueSpider.Common.Ports.IInputNetworkPort), el.InPortMgr[0]);
            Assert.NotNull(el.OutPortMgr);
            Assert.Equal(1, el.OutPortMgr.Count);
            Assert.IsType(typeof(BlueSpider.Common.Ports.IOutputNetworkPort), el.OutPortMgr[0]);
            Assert.NotNull(el.SettingsMgr);
            Assert.NotNull(el.OptionsMgr);

            Assert.Equal(defType.ElementTypeId, el.TypeId);
            Assert.Equal(ticket.ElementId, el.Id);
            Assert.Equal(ticket.ParamMgrId, el.MyParamMgr.Id);
            Assert.Equal(ticket.FxId, el.IdentNodeCoresFx.Id);
            Assert.Equal(ticket.InputPortIds[0], el.InPortMgr[0].Id);
            Assert.Equal(ticket.OutputPortIds[0], el.OutPortMgr[0].Id);
        }
        public void Create_ByTicket()
        {
            Guid typeId = new Guid();
            Type expectedType = typeof(DataPropertiesElement);
            IElementDefinition defType = new ElementDefinition(typeId);

            BlueSpider.Common.Persistance.ElementTicket ticket = new BlueSpider.Common.Persistance.ElementTicket();
            ticket.ElementId = Guid.NewGuid();
            ticket.TypeId = typeId;
            ticket.FxId = Guid.NewGuid();
            ticket.ParamMgrId = Guid.NewGuid();
            ticket.InputPortMgrId = Guid.NewGuid();
            ticket.OutputPortMgrId = Guid.NewGuid();
            ticket.InputPortIds = new Guid[] { Guid.NewGuid() };
            ticket.OutputPortIds = new Guid[] { };

            DataPropertiesElementFactory fac = new DataPropertiesElementFactory();
            DataPropertiesElement el = fac.Create(ticket, defType);

            Assert.NotNull(el);
            Assert.IsType(expectedType, el);
            Assert.NotNull(el.ParamMgr);
            Assert.NotNull(el.ParamMgr.Bag);
            Assert.NotNull(el.ParamMgr.ParamVarMapper);
            Assert.NotNull(el.InPortMgr);
            Assert.Equal(1, el.InPortMgr.Count);
            Assert.True(el.InPortMgr[0] is IInputDataPort);
            Assert.NotNull(el.OutPortMgr);
            Assert.Equal(0, el.OutPortMgr.Count);
            Assert.NotNull(el.SettingsMgr);
            Assert.NotNull(el.OptionsMgr);

            Assert.Equal(defType.ElementTypeId, el.TypeId);
            Assert.Equal(ticket.ElementId, el.Id);
            Assert.Equal(ticket.ParamMgrId, el.ParamMgr.Id);
            Assert.Equal(ticket.FxId, el.Fx.Id);
            Assert.Equal(ticket.InputPortIds[0], el.InPortMgr[0].Id);
        }
예제 #5
0
        public void Create_ReturnsAnInstanceOfTheElement()
        {
            Guid id = new Guid();
            Type expectedType = typeof(ImportNetworkElement);
            IElementDefinition defType = new ElementDefinition(Guid.NewGuid());

            ImportNetworkElementFactory fac = new ImportNetworkElementFactory();
            ImportNetworkElement el = fac.Create(id, defType);

            Assert.NotNull(el);
            Assert.IsType(expectedType, el);
            Assert.NotNull(el.ParamMgr);
            Assert.NotNull(el.ParamMgr.Bag);
            Assert.NotNull(el.ParamMgr.ParamVarMapper);
            Assert.NotNull(el.InPortMgr);
            Assert.Equal(0, el.InPortMgr.Count);
            Assert.NotNull(el.OutPortMgr);
            Assert.Equal(1, el.OutPortMgr.Count);
            Assert.True(el.OutPortMgr[0] is BlueSpider.Common.Ports.IOutputNetworkPort);
            Assert.NotNull(el.SettingsMgr);
            Assert.NotNull(el.OptionsMgr);
            Assert.Equal(el.TypeId, defType.ElementTypeId);
            Assert.Equal(el.Id, id);
        }
        public void Create()
        {
            Guid id = new Guid();
            Type expectedType = typeof(DataPropertiesElement);
            IElementDefinition defType = new ElementDefinition(Guid.NewGuid());

            DataPropertiesElementFactory fac = new DataPropertiesElementFactory();
            DataPropertiesElement el = fac.Create(id, defType);

            Assert.NotNull(el);
            Assert.IsType(expectedType, el);
            Assert.NotNull(el.ParamMgr);
            Assert.NotNull(el.ParamMgr.Bag);
            Assert.NotNull(el.ParamMgr.ParamVarMapper);
            Assert.NotNull(el.InPortMgr);
            Assert.Equal(1, el.InPortMgr.Count);
            Assert.True(el.InPortMgr[0] is IInputDataPort);
            Assert.NotNull(el.OutPortMgr);
            Assert.Equal(0, el.OutPortMgr.Count);
            Assert.NotNull(el.SettingsMgr);
            Assert.NotNull(el.OptionsMgr);
            Assert.Equal(el.TypeId, defType.ElementTypeId);
            Assert.Equal(el.Id, id);
        }
예제 #7
0
        private IList<IElementDefinition> GetAllDefinitions()
        {
            IList<IElementDefinition> list = null;
            ElementDefinition [] defs = null;

            Assembly ass = Assembly.GetCallingAssembly();

            ResourceManager rm = new ResourceManager(Properties.Resources.ResourceFullName, ass);
            String xmlData = rm.GetString("ElementDefinitions");

            try
            {
                using (StringReader strReader = new StringReader(xmlData))
                {
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(strReader))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(ElementDefinition[]));

                        //serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
                        //serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);
                        defs = (ElementDefinition[])serializer.Deserialize(reader);
                    }
                }
            }
            catch (Exception ex)
            {
                _Logger.Fatal(ex.Message, ex);

                throw;
            }
            if (defs == null)
                defs = new ElementDefinition[0];

            // Deserialization returns null when no ports, just create empty arrays
            for (int i = 0; i < defs.Length; i++)
            {
                if (defs[i].InputPortTypes == null)
                {
                    defs[i].InputPortTypes = new BlueSpider.Common.BlobType[0];
                }
                if (defs[i].OutputPortTypes == null)
                {
                    defs[i].OutputPortTypes = new BlueSpider.Common.BlobType[0];
                }
            }

            list = new List<IElementDefinition>(defs);

            return list;
        }