Beispiel #1
0
        public void Deserialize_Should_Return_BrokenConnections(string fromNodeId, string fromPortId, string toNodeId, string toPortId)
        {
            var sgraph = new SGraph()
            {
                Type = typeof(GraphType).FullName
            };

            var snode1 = new SNode()
            {
                Id = "1", Type = typeof(NodeWithProperties).FullName, Properties = "{}"
            };
            var snode2 = new SNode()
            {
                Id = "2", Type = typeof(NodeWithProperties).FullName, Properties = "{}"
            };

            sgraph.AddNode(snode1);
            sgraph.AddNode(snode2);

            var sconnection = new SConnection()
            {
                FromNodeId = fromNodeId,
                FromPortId = fromPortId,
                ToNodeId   = toNodeId,
                ToPortId   = toPortId,
            };

            sgraph.AddConnection(sconnection);

            var brokenConnections = new List <SConnection>();

            var str = JsonConvert.SerializeObject(sgraph);

            GraphSerializer.Deserialize(str, brokenConnections);

            Assert.That(brokenConnections, Has.Count.EqualTo(1));

            var c = brokenConnections[0];

            Assert.That(c.FromNodeId, Is.EqualTo(sconnection.FromNodeId));
            Assert.That(c.FromPortId, Is.EqualTo(sconnection.FromPortId));
            Assert.That(c.ToNodeId, Is.EqualTo(sconnection.ToNodeId));
            Assert.That(c.ToPortId, Is.EqualTo(sconnection.ToPortId));
        }
Beispiel #2
0
        public void Deserialize_Should_Fix_ConnectionDirection()
        {
            var sgraph = new SGraph()
            {
                Type = typeof(GraphType).FullName
            };

            var snode1 = new SNode()
            {
                Id = "1", Type = typeof(NodeWithProperties).FullName, Properties = "{}"
            };
            var snode2 = new SNode()
            {
                Id = "2", Type = typeof(NodeWithProperties).FullName, Properties = "{}"
            };

            sgraph.AddNode(snode1);
            sgraph.AddNode(snode2);

            // this connection has inverted direction: In -> Out
            var sconnection = new SConnection()
            {
                FromNodeId = "2",
                FromPortId = "In",
                ToNodeId   = "1",
                ToPortId   = "Out",
            };

            sgraph.AddConnection(sconnection);

            var str   = JsonConvert.SerializeObject(sgraph);
            var graph = GraphSerializer.Deserialize(str);

            Assert.That(graph.Connections.Count, Is.EqualTo(1));

            var c = graph.Connections[0];

            Assert.That(c.From.Node.Id, Is.EqualTo("1"));
            Assert.That(c.From.Id, Is.EqualTo("Out"));
            Assert.That(c.To.Node.Id, Is.EqualTo("2"));
            Assert.That(c.To.Id, Is.EqualTo("In"));
        }
Beispiel #3
0
        void BeginAccept_Callback(IAsyncResult iar)
        {
            Socket sockServer = null;

            try
            {
                sockServer = (Socket)iar.AsyncState;

                SConnection Connection = new SConnection();
                Connection.ClientSocket = sockServer.EndAccept(iar);
                Connection.ClientStream = new SslStream(new NetworkStream(Connection.ClientSocket), false);

                Connection.ClientStream.BeginAuthenticateAsServer(m_SSLCertificate, false, SslProtocols.Tls, true, new AsyncCallback(SSL_BeginAuthenticateAsServer_Callback), Connection);
            }
            catch
            {
            }

            this.ConnectionAccepted.Set();
        }