public void BeforeRegister(MServer server, ManagedObjectName name)
        {
            Assertion.AssertNotNull(server);
            Assertion.AssertNotNull(name);

            beforeRegisterCalled = state++;
        }
        public void TestCreation()
        {
            ManagedObjectName name = new ManagedObjectName("domain.org");
            ManagedInstance instance1 = new ManagedInstance("typename", name);

            AssertEquals( "typename", instance1.TypeName );
            AssertEquals( name, instance1.Name );
        }
        public void TestCreation()
        {
            ManagedObjectName name1 = new ManagedObjectName("domain.net");
            AssertEquals( "domain.net", name1.Domain );
            AssertEquals( String.Empty, name1.LiteralProperties );

            ManagedObjectName name2 = new ManagedObjectName("domain.org:name=SomeService,type=aware");
            AssertEquals( "domain.org", name2.Domain );
            AssertEquals( "type=aware,name=SomeService", name2.LiteralProperties );
        }
        public void TestEquality2()
        {
            ManagedObjectName name1 = new ManagedObjectName("domain.net:name=SomeService,type=aware");
            ManagedObjectName name2 = new ManagedObjectName("domain.net:name=SomeService,type=aware");

            Assert( name1.GetHashCode() == name2.GetHashCode() );
            Assert( name1.Equals( name2 ) );

            ManagedObjectName name3 = new ManagedObjectName("domain.net:name=SomeService,type=unaware");
            Assert( name1.GetHashCode() != name3.GetHashCode() );
            Assert( !name1.Equals( name3 ) );
        }
        public void TestEquality1()
        {
            ManagedObjectName name1 = new ManagedObjectName("domain.net");
            ManagedObjectName name2 = new ManagedObjectName("domain.net");

            Assert( name1.GetHashCode() == name2.GetHashCode() );
            Assert( name1.Equals( name2 ) );

            ManagedObjectName name3 = new ManagedObjectName("domain.org");
            Assert( name1.GetHashCode() != name3.GetHashCode() );
            Assert( !name1.Equals( name3 ) );
        }
        /// <summary>
        /// Creates a ManagedInstance instance.
        /// </summary>
        /// <param name="typeName">Full qualified name of the type</param>
        /// <param name="name"><see cref="ManagedObjectName"/> of instance.</param>
        public ManagedInstance(String typeName, ManagedObjectName name)
        {
            if (typeName == null)
            {
                throw new ArgumentNullException("typeName");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            this.name = name;
            this.typeName = typeName;
        }
        public void TestSerialization()
        {
            MemoryStream stream = new MemoryStream();

            ManagedObjectName name1 = new ManagedObjectName("domain.net:name=SomeService,type=aware");

            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, name1);

            stream.Position = 0;

            ManagedObjectName name2 = (ManagedObjectName) formatter.Deserialize(stream);

            Assert( name1.GetHashCode() == name2.GetHashCode() );
            Assert( name1.Equals( name2 ) );
        }
        public void TestServerCreation()
        {
            MConnectorServer serverConn =
                       MConnectorServerFactory.CreateServer( "provider:http:binary:test.rem", null, null );

            AssertNotNull( serverConn );

            ManagedObjectName name = new ManagedObjectName("connector.http:formatter=binary");
            server.RegisterManagedObject( serverConn, name );

            AssertEquals( name, serverConn.ManagedObjectName );

            AppDomain child = null;

            try
            {
                child = AppDomain.CreateDomain(
                    "Child",
                    new System.Security.Policy.Evidence(AppDomain.CurrentDomain.Evidence),
                    AppDomain.CurrentDomain.SetupInformation);

                RemoteClient client = (RemoteClient)
                    child.CreateInstanceAndUnwrap( typeof(RemoteClient).Assembly.FullName, typeof(RemoteClient).FullName );

                AssertNotNull( client.TestClientCreation() );
            }
            finally
            {
                server.UnregisterManagedObject( name );

                if (child != null)
                {
                    AppDomain.Unload(child);
                }
            }
        }