Beispiel #1
0
        public void getReceptaclesTest2()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            ReceptacleDescription[] actual = target.getReceptacles();
            Assert.AreEqual(0, actual.Length);
        }
        public void buildTest1()
        {
            ComponentId      componetId = new ComponentId("Test1", 1, 0, 0, ".Net FrameWork 3.5");
            ComponentContext expected   = new DefaultComponentContext(componetId);

            String             name          = "IComponent_1";
            String             interfaceName = "IDL:scs/core/IComponent:1.0";
            MarshalByRefObject servant       = new IComponentServant(expected);

            expected.AddFacet(name, interfaceName, servant);
            name          = "IComponent_2";
            interfaceName = "IDL:scs/core/IComponent:1.0";
            servant       = new IComponentServant(expected);
            expected.AddFacet(name, interfaceName, servant);
            name          = "IMetaInterface_3";
            interfaceName = "IDL:scs/core/IMetaInterface:1.0";
            servant       = new IMetaInterfaceServant(expected);
            expected.AddFacet(name, interfaceName, servant);

            String              componentModel       = Resources.Component1;
            TextReader          file                 = new StringReader(componentModel);
            XmlTextReader       componentInformation = new XmlTextReader(file);
            XmlComponentBuilder target               = new XmlComponentBuilder(componentInformation);
            ComponentContext    actual               = target.build();

            Assert.IsTrue(expected.Equals(actual));
        }
Beispiel #3
0
        public void AddFacetTest3()
        {
            string icomponentName = typeof(IComponent).Name;
            Facet  expected       = context.GetFacetByName(icomponentName);

            string             interfaceName = Repository.GetRepositoryID(typeof(IMetaInterface));
            MarshalByRefObject servant       = new IMetaInterfaceServant(context);

            context.AddFacet(icomponentName, interfaceName, servant);
        }
Beispiel #4
0
        public void getFacetsTest()
        {
            IMetaInterfaceServant       target   = new IMetaInterfaceServant(context);
            IDictionary <String, Facet> expected = context.GetFacets();

            FacetDescription[] actual = target.getFacets();
            Assert.AreEqual(expected.Count, actual.Length);
            for (int i = 0; i < actual.Length; i++)
            {
                Assert.IsTrue(expected.ContainsKey(actual[i].name));
            }
        }
        public void connectTest1()
        {
            IReceptaclesServant target       = new IReceptaclesServant(context);
            string             name          = "SimpleReceptacle";
            string             interfaceName = Repository.GetRepositoryID(typeof(IMetaInterface));
            MarshalByRefObject servant       = new IMetaInterfaceServant(context);

            context.AddReceptacle(name, interfaceName, false);

            target.connect(name, servant);
            target.connect(name, servant);
        }
Beispiel #6
0
        public void UpdateFacet1()
        {
            string             name         = typeof(IMetaInterface).Name;
            MarshalByRefObject servant      = new IMetaInterfaceServant(context);
            MarshalByRefObject oldReference = context.GetFacetByName(name).Reference;

            context.UpdateFacet(name, servant);
            Facet actual = context.GetFacetByName(name);

            string expected = context.GetFacetByName(name).Name;

            Assert.AreEqual(expected, actual.Name);
            Assert.AreEqual(servant, actual.Reference);
            Assert.AreNotEqual(oldReference, actual.Reference);
        }
Beispiel #7
0
        public void getFacetsByNameTest2()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            string[] names = new string[3];
            names[0] = typeof(IComponent).Name;
            names[1] = "InvalidName";
            names[2] = typeof(IMetaInterface).Name;
            FacetDescription[] actual = target.getFacetsByName(names);
            Assert.AreEqual(names.Length - 1, actual.Length);
            foreach (var facet in actual)
            {
                Facet expected = context.GetFacetByName(facet.name);
                Assert.IsNotNull(expected);
            }
        }
Beispiel #8
0
        public void getReceptaclesByNameTest()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            foreach (var name in receptacleNames)
            {
                context.AddReceptacle(name, interfaceName, false);
            }

            string[] names = receptacleNames.ToArray();
            ReceptacleDescription[] actual = target.getReceptaclesByName(names);
            Assert.AreEqual(receptacleNames.Count, actual.Length);
            foreach (var receptacle in actual)
            {
                Receptacle expected = context.GetReceptacleByName(receptacle.name);
                Assert.IsNotNull(expected);
            }
        }
Beispiel #9
0
        public void getReceptaclesTest()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            foreach (var name in receptacleNames)
            {
                context.AddReceptacle(name, interfaceName, false);
            }

            IDictionary <String, Receptacle> expected = context.GetReceptacles();

            ReceptacleDescription[] actual = target.getReceptacles();
            Assert.AreEqual(expected.Count, actual.Length);
            for (int i = 0; i < actual.Length; i++)
            {
                Assert.IsTrue(expected.ContainsKey(actual[i].name));
            }
        }
Beispiel #10
0
        public void getReceptaclesByNameTest2()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            foreach (var name in receptacleNames)
            {
                context.AddReceptacle(name, interfaceName, false);
            }

            string[] names = receptacleNames.ToArray();
            // Alterando o último nome para um nome inválido.
            names[names.Length - 1] = "InvalidName";
            ReceptacleDescription[] actual = target.getReceptaclesByName(names);
            Assert.AreEqual(names.Length - 1, actual.Length);
            foreach (var receptacle in actual)
            {
                Receptacle expected = context.GetReceptacleByName(receptacle.name);
                Assert.IsNotNull(expected);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Adiciona as facetas básicas à lista de Facetas criadas pelo usuário.
        /// </summary>
        private void AddBasicFacets()
        {
            Type   icomponentType          = typeof(IComponent);
            string icomponentName          = icomponentType.Name;
            string icomponentInterfaceName = IiopNetUtil.GetRepositoryId(icomponentType);

            if (!facets.ContainsKey(icomponentName))
            {
                IComponent         icomponent        = new IComponentServant(this);
                MarshalByRefObject icomponentServant = icomponent as MarshalByRefObject;
                AddFacet(icomponentName, icomponentInterfaceName, icomponentServant);
                logger.DebugFormat("Faceta '{0}' adicionada com sucesso", icomponentName);
            }

            Type   ireceptacleType          = typeof(IReceptacles);
            string ireceptacleName          = ireceptacleType.Name;
            string ireceptacleInterfaceName = IiopNetUtil.GetRepositoryId(ireceptacleType);

            if (!facets.ContainsKey(ireceptacleName))
            {
                IReceptacles       receptacle        = new IReceptaclesServant(this);
                MarshalByRefObject receptacleServant = receptacle as MarshalByRefObject;
                AddFacet(ireceptacleName, ireceptacleInterfaceName, receptacleServant);
                logger.DebugFormat("Faceta '{0}' adicionada com sucesso", ireceptacleName);
            }

            Type   imetaInterfaceType          = typeof(IMetaInterface);
            string imetaInterfaceName          = imetaInterfaceType.Name;
            string imetaInterfaceInterfaceName = IiopNetUtil.GetRepositoryId(imetaInterfaceType);

            if (!facets.ContainsKey(imetaInterfaceName))
            {
                IMetaInterface     metaInterface        = new IMetaInterfaceServant(this);
                MarshalByRefObject metaInterfaceServant = metaInterface as MarshalByRefObject;
                AddFacet(imetaInterfaceName, imetaInterfaceInterfaceName, metaInterfaceServant);
                logger.DebugFormat("Faceta '{0}' adicionada com sucesso", imetaInterfaceName);
            }
        }
Beispiel #12
0
 public void IMetaInterfaceServantConstructorTest2()
 {
     IMetaInterfaceServant target = new IMetaInterfaceServant(null);
 }
Beispiel #13
0
        public void IMetaInterfaceServantConstructorTest1()
        {
            IMetaInterfaceServant target = new IMetaInterfaceServant(context);

            Assert.IsNotNull(target);
        }
Beispiel #14
0
        public void UpdateFacet2()
        {
            MarshalByRefObject servant = new IMetaInterfaceServant(context);

            context.UpdateFacet("invalidFacetName", servant);
        }