Пример #1
0
        public RandomNetworkGenElement Create(Guid id, IElementDefinition defType)
        {
            RandomNetworkGenElement el = new RandomNetworkGenElement(id, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IRandomNetGenParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IRandomNetworkGenFx fx = CreateMyFx(fxId, id);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Пример #2
0
        public DataPropertiesElement Create(Guid id, IElementDefinition defType)
        {
            DataPropertiesElement el = new DataPropertiesElement(id, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IDataPropertiesElementParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IDataPropertiesElementFx fx = CreateMyFx(fxId, id);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ICompoundSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ICompoundOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Пример #3
0
        public ExtractKthCoreElement Create(Guid elementId, IElementDefinition defType)
        {
            ExtractKthCoreElement el = new ExtractKthCoreElement(elementId, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IExtractKthCoreParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IExtractKthCoreFx fx = CreateMyFx(fxId, elementId);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Пример #4
0
        public void CreateSettingsMgr_For_SimpleEl()
        {
            //Arrange
            var fac = new SettingsMgrFactory();
            ISimpleElement el = DummyFactory.CreateDummySimpleEl(Guid.NewGuid());

            //Act
            ISettingsMgr mgr = fac.CreateSettingsMgr(el);

            //Assert
            Assert.NotNull(mgr);
            Assert.IsType(typeof(SimpleSettingsMgr), mgr);
        }
Пример #5
0
        public INeutralPipe CreateNeutralPipe(Guid id)
        {
            NeutralPipe pipe = new NeutralPipe(id);
            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                pipe.SettingsMgr = fac.CreateSettingsMgr(pipe);
            }

            using (Providers.OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                pipe.OptionsMgr = fac.CreateOptionsMgr(pipe);
            }

            return pipe;
        }
Пример #6
0
        public void CreateSettingsMgr_For_Network_Pipe()
        {
            //Arrange
            var pfac = new PipeFactory();
            INetworkPipe pipe = pfac.CreateNetworkPipe();

            var fac = new SettingsMgrFactory();

            //Act
            IPipeSettingsMgr mgr = fac.CreateSettingsMgr(pipe);

            //Assert
            Assert.NotNull(mgr);
            Assert.IsType(typeof(PipeSettingsMgr), mgr);
        }
Пример #7
0
        public IApp Create(Guid id)
        {
            IAppSettingsMgr sMgr = null;
            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                sMgr = fac.CreateAppSettingsMgr();
            }

            IAppOptionsMgr oMgr = null;
            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                oMgr = fac.CreateAppOptionsMgr();
            }

            // TODO  use a DI framework for this
            IApp app = null;
            using (WorkSpaceFactory fac = new WorkSpaceFactory())
            {
                app = new App.AppCore(Guid.NewGuid(), oMgr, sMgr);
            }

            return app;
        }
Пример #8
0
        public DataPropertiesElement Create(IElementTicket ticket, IElementDefinition defType)
        {
            if (ticket.TypeId != defType.ElementTypeId)
            {
                // TODO
                throw new InvalidOperationException(Properties.Resources.MssgTicketTypeIdDoesNotMatchDefTypeIdFormat(ticket.TypeId, defType.ElementTypeId));
            }

            DataPropertiesElement el = new DataPropertiesElement(ticket.ElementId, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el, ticket.InputPortMgrId, ticket.InputPortIds[0]);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IDataPropertiesElementParamMgr paramMgr = CreateParamMgr(ticket.ParamMgrId);
            el.ParamMgr = paramMgr;

            IDataPropertiesElementFx fx = CreateMyFx(ticket.FxId, ticket.ElementId);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ICompoundSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ICompoundOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Пример #9
0
        //[Theory]
        //[InlineData("<WorkSpace id=\"41e9137f-d51a-4e83-bbcb-6e73c7467004\" mode=\"Single\"><Settings /><Options /><Variables /><Elements /><Pipes /></WorkSpace>" , 0, 0, "41e9137f-d51a-4e83-bbcb-6e73c7467004")]
        //public void Unpersist_ByFragment(string inputStr, int elementCount, int pipeCount, string guidStr0)
        //{
        //    var upMgr = new UnpersistMgr(null);
        //    // cant test
        //    Guid initId = Guid.NewGuid();
        //    IWorkSpace ws = CreateWorkSpaceCore(initId);
        //    Assert.NotNull(ws);
        //    var reader = new XmlTextReader(new StringReader(inputStr));
        //    upMgr.Reader = reader;
        //    upMgr.Format = WorkSpaceFormats.Default;
        //    upMgr.WorkSpace = ws;
        //    upMgr.Unpersist();
        //    Guid expectedId = new Guid(guidStr0);
        //    Assert.Equal(expectedId, ws.Id);
        //    Assert.NotNull(ws.SettingsMgr);
        //    Assert.NotNull(ws.OptionsMgr);
        //    Assert.NotNull(ws.VarMgr);
        //    Assert.NotNull(ws.ElementsMgr);
        //    Assert.NotNull(ws.PipesMgr);
        //    Assert.Equal(elementCount, ws.ElementsMgr.Count);
        //    Assert.Equal(pipeCount, ws.PipesMgr.Count);
        //}
        //[Theory]
        //[InlineData(@"J:\_bsa\source\TestData\wkSpaceTest_0_0.wks", 0, 0, "41e9137f-d51a-4e83-bbcb-6e73c7467004", new string[] { }, new string[] { })]
        //[InlineData(@"J:\_bsa\source\TestData\wkSpaceTest_1_0.wks", 1, 0, "cd1546cc-4177-4e53-bc99-0f757e94e8eb", new string[] { }, new string[] { })]
        //[InlineData(@"J:\_bsa\source\TestData\wkSpaceTest_2_0.wks", 2, 0, "636566ff-e696-407d-81da-c518ec3dc9e4", new string[] { }, new string[] { })]
        //[InlineData(@"J:\_bsa\source\TestData\wkSpaceTest_2_1.wks", 2, 1, "40a9f35f-8bb2-495e-8761-e414414ae03f", new string[] { }, new string[] { })]
        //public void Unpersist_ByFileInput(string fileName, int elementCount, int pipeCount, string guidStr0, string [] elGuidStrs, string [] pipeGuidStrs)
        //{
        //    var upMgr = new UnpersistMgr();
        //    // by mocking
        //    var mockWS = new Mock<IWorkSpace>();
        //    var mockWsUnpersister = new Mock<IWorkSpaceUnpersister>();
        //    using (RecordExpectations recorder = RecorderManager.StartRecording())
        //    {
        //        WorkSpaceUnpersisterProvider wpp = new WorkSpaceUnpersisterProvider();
        //        recorder.ExpectAndReturn(wpp.Create(null, WorkSpaceFormats.Default), mockWsUnpersister);
        //        mockWsUnpersister.UnpersistProgressChanged += null;
        //        mockWsUnpersister.UnpersistCompleted += null;
        //        mockWsUnpersister.UnpersistWorkSpace(mockWS, _reader);
        //        mockWsUnpersister.UnpersistProgressChanged -= null;
        //        mockWsUnpersister.UnpersistCompleted -= null;
        //        mockWsUnpersister.Dispose();
        //    }
        //    upMgr.Reader = _reader;
        //    upMgr.WorkSpace = mockWS;
        //    upMgr.Format = WorkSpaceFormats.Default;
        //    upMgr.FileName = fileName;
        //    upMgr.Unpersist();
        //    MockManager.Verify();
        //}
        //[Theory]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_0_0.wks", 0, 0, "41e9137f-d51a-4e83-bbcb-6e73c7467004", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_1_0.wks", 1, 0, "cd1546cc-4177-4e53-bc99-0f757e94e8eb", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_2_0.wks", 2, 0, "636566ff-e696-407d-81da-c518ec3dc9e4", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_2_1.wks", 2, 1, "40a9f35f-8bb2-495e-8761-e414414ae03f", new string[] { }, new string[] { })]
        //[MbUnit.Framework.Ignore("Tests with MySimpleEl will fail as that has not been build for deployment.")]
        //public void Unpersist_ByFileInput_Real(string fileName, int elementCount, int pipeCount, string guidStr0, string [] elGuidStrs, string [] pipeGuidStrs)
        //{
        //    var upMgr = new UnpersistMgr();
        //    Guid initId = Guid.NewGuid();
        //    IWorkSpace ws = CreateWorkSpaceCore(initId);
        //    Assert.NotNull(ws);
        //    upMgr.Format = WorkSpaceFormats.Default;
        //    upMgr.WorkSpace = ws;
        //    upMgr.FileName = fileName;
        //    upMgr.Unpersist();
        //    Guid expectedId = new Guid(guidStr0);
        //    Assert.Equal(expectedId, ws.Id);
        //    Assert.NotNull(ws.SettingsMgr);
        //    Assert.NotNull(ws.OptionsMgr);
        //    Assert.NotNull(ws.VarMgr);
        //    Assert.NotNull(ws.ElementsMgr);
        //    Assert.NotNull(ws.PipesMgr);
        //    Assert.Equal(elementCount, ws.ElementsMgr.Count);
        //    Assert.Equal(pipeCount, ws.PipesMgr.Count);
        //}
        //[Theory]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_0_0.wks", 0, 0, "41e9137f-d51a-4e83-bbcb-6e73c7467004", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_1_0.wks", 1, 0, "cd1546cc-4177-4e53-bc99-0f757e94e8eb", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_2_0.wks", 2, 0, "636566ff-e696-407d-81da-c518ec3dc9e4", new string[] { }, new string[] { })]
        //[InlineData(@"C:\_bsa\dump\wkSpaceTest_2_1.wks", 2, 1, "40a9f35f-8bb2-495e-8761-e414414ae03f", new string[] { }, new string[] { })]
        //[MbUnit.Framework.Ignore("Tests with MySimpleEl will fail as that has not been build for deployment." )]
        //public void Unpersist_ByFileInput_ReturnsPipeTickets_Real(string fileName, int elementCount, int pipeCount, string guidStr0, string[] elGuidStrs, string[] pipeGuidStrs)
        //{
        //    var upMgr = new UnpersistMgr();
        //    Guid initId = Guid.NewGuid();
        //    IWorkSpace ws = CreateWorkSpaceCore(initId);
        //    Assert.NotNull(ws);
        //    IPipeTicket[] pipeTickets = null;
        //    upMgr.Format = WorkSpaceFormats.Default;
        //    upMgr.WorkSpace = ws;
        //    upMgr.FileName = fileName;
        //    upMgr.Unpersist(out pipeTickets);
        //    Guid expectedId = new Guid(guidStr0);
        //    Assert.Equal(expectedId, ws.Id);
        //    Assert.NotNull(ws.SettingsMgr);
        //    Assert.NotNull(ws.OptionsMgr);
        //    Assert.NotNull(ws.VarMgr);
        //    Assert.NotNull(ws.ElementsMgr);
        //    Assert.NotNull(ws.PipesMgr);
        //    Assert.Equal(elementCount, ws.ElementsMgr.Count);
        //    Assert.Equal(pipeCount, ws.PipesMgr.Count);
        //    Assert.NotNull(pipeTickets);
        //    Assert.Equal(pipeCount, pipeTickets.Length);
        //}
        //Helpers
        public IWorkSpace CreateWorkSpaceCore(Guid id)
        {
            IElements elMgr = new BlueSpider.Common.WorkSpace.Elements();
            IPipes pipeMgr = new BlueSpider.Common.WorkSpace.Pipes();

            IVarMgr vMgr = null;
            using (VarMgrFactory fac = new VarMgrFactory())
            {
                vMgr = fac.Create();
            }

            IWorkSpaceSettingsMgr sMgr = null;
            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                sMgr = fac.CreateWorkSpaceSettingsMgr();
            }

            IWorkSpaceOptionsMgr oMgr = null;
            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                oMgr = fac.CreateWorkSpaceOptionsMgr();
            }

            // TODO  use a DI framework for this
            IWorkSpace ws = null;
            using (WorkSpaceFactory fac = new WorkSpaceFactory())
            {
                ws = fac.Create(id, vMgr, elMgr, pipeMgr, oMgr, sMgr);
            }

            return ws;
        }
Пример #10
0
        public ExportNetworkElement Create(IElementTicket ticket, IElementDefinition defType)
        {
            if (ticket.TypeId != defType.ElementTypeId)
            {
                // TODO
                throw new InvalidOperationException(String.Format(Resources.MssgTicketTypeIdDoesNotMatchDefTypeId, ticket.TypeId, defType.ElementTypeId));
            }

            ExportNetworkElement el = new ExportNetworkElement(ticket.ElementId, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el, ticket.InputPortMgrId, ticket.InputPortIds[0]);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IExportNetworkParamMgr paramMgr = CreateParamMgr(ticket.ParamMgrId);
            el.ParamMgr = paramMgr;

            IExportNetworkFx fx = CreateMyFx(ticket.FxId, ticket.ElementId);
            el.Fx = fx;

            using (var fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (var fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }