コード例 #1
0
        public void EndpointQualifierTest()
        {
            var q = new EndpointQualifier(ProtocolType.Client, "identifier");

            Assert.That(q.Type, Is.EqualTo(ProtocolType.Client));
            Assert.That(q.Identifier, Is.EqualTo("identifier"));
            Assert.That(q.FactoryId, Is.EqualTo(0));
            Assert.That(q.ClassId, Is.EqualTo(17));

            Assert.That(q, Ish.Equatable(
                            new EndpointQualifier(ProtocolType.Client, "identifier"),
                            new EndpointQualifier(ProtocolType.MemCache, "identifier"),
                            new EndpointQualifier(ProtocolType.Client, "other")));

            Assert.That(q.GetHashCode(), Is.Not.Zero);

            Assert.Throws <ArgumentNullException>(() => q.WriteData(null));
            Assert.Throws <ArgumentNullException>(() => q.ReadData(null));

            var output = new ObjectDataOutput(1024, null, Endianness.BigEndian);

            q.WriteData(output);
            var input = new ObjectDataInput(output.ToByteArray(), null, Endianness.BigEndian);
            var r     = new EndpointQualifier(ProtocolType.Wan, "meh");

            r.ReadData(input);

            Assert.That(q, Is.EqualTo(r));
        }
コード例 #2
0
        public void DistributedObjectInfoTest()
        {
            var x = new DistributedObjectInfo("serviceName", "name");

            Console.WriteLine(x);

            Assert.That(x.ServiceName, Is.EqualTo("serviceName"));
            Assert.That(x.Name, Is.EqualTo("name"));

            Assert.That(x, Ish.Equatable(
                            new DistributedObjectInfo("serviceName", "name"),
                            new DistributedObjectInfo("serviceName", "other"),
                            new DistributedObjectInfo("other", "name")));

            var hash = x.GetHashCode();

            Assert.That(hash, Is.Not.Zero);
        }
コード例 #3
0
        public void MemberInfoTest()
        {
            var memberId = Guid.NewGuid();
            var address  = NetworkAddress.Parse("192.168.33.34:5569");
            var version  = new MemberVersion(4, 5, 6);


            var attributes = new Dictionary <string, string>
            {
                { "attribute", "value" }
            };
            var x = new MemberInfo(memberId, address, version, true, attributes);

            Console.WriteLine(x);

            Assert.That(x.Id, Is.EqualTo(memberId));
            Assert.That(x.Uuid, Is.EqualTo(memberId));
            Assert.That(x.Address, Is.SameAs(address));
            Assert.That(x.Version, Is.SameAs(version));
            Assert.That(x.IsLiteMember, Is.True);
            Assert.That(x.IsLiteMember, Is.True);
            var a = x.Attributes;

            Assert.That(a.Count, Is.EqualTo(1));
            Assert.That(a["attribute"], Is.EqualTo("value"));

            Assert.That(x, Ish.Equatable(
                            // weird indeed, but only the ID matters
                            new MemberInfo(memberId, x.Address, x.Version, x.IsLiteMember, attributes),
                            new MemberInfo(Guid.NewGuid(), x.Address, x.Version, x.IsLiteMember, attributes)
                            ));

            var y = new MemberInfo(address, memberId, attributes, true, version, false, null);

            var map = new Dictionary <EndpointQualifier, NetworkAddress>();
            var z   = new MemberInfo(address, memberId, attributes, true, version, true, map);
        }