public void send_howdy() { howdy h = new howdy(protocol.clientID, protocol.server, protocol.recovery_timeout, protocol.heartbeat, protocol.filetransfer); if (protocol.channel_listing) h.channel_listing = true; if (protocol.recovery) h.recovery = true; if (protocol.headers != null) h.headers = protocol.headers; protocol.SocketSend(h.ToString()); }
public void howdy() { string session_id = Guid.NewGuid().ToString(); // test default howdy howdy h = new howdy(session_id); string expected = "[3,\"" + session_id + "\",1,\"\",[-1,-1,false],[0,false,false,false,\"0\",\"0\"],false,false,0]"; string result = h.ToString(); Assert.AreEqual(expected, result); // test documentation howdy h = new howdy(session_id, "Example 0.9.6", 120, new Heartbeat(30, 60, true), new Filetransfer(1)); h.filetransfer.allow_pausing = true; h.filetransfer.force_chunk_integrity = true; h.filetransfer.force_file_integrity = true; h.filetransfer.max_chunk_size = "250K"; h.filetransfer.max_file_size = "50M"; h.recovery = true; h.channel_listing = true; fake_headers headers = new fake_headers(); h.headers = headers.ToString(); expected = "[3,\"" + session_id + "\",1,\"Example 0.9.6\",[30,60,true],[1,true,true,true,\"250K\",\"50M\"],true,true,120,{\"api_day_quota\":1000,\"api_day_reset\":41268740,\"api_day_used\":153,\"api_hour_quota\":100,\"api_hour_reset\":41267360,\"api_hour_used\":15,\"sample_feature_1\":true,\"sample_feature_2\":false}]"; result = h.ToString(); Assert.AreEqual(expected, result); // check the shorthand file sizes h.filetransfer.max_chunk_size = "250"; Assert.AreEqual(h.filetransfer.max_chunk_size_real, 250); h.filetransfer.max_chunk_size = "250K"; Assert.AreEqual(h.filetransfer.max_chunk_size_real, 256000); h.filetransfer.max_chunk_size = "250M"; Assert.AreEqual(h.filetransfer.max_chunk_size_real, 262144000); h.filetransfer.max_chunk_size = "250G"; Assert.AreEqual(h.filetransfer.max_chunk_size_real, 268435456000); h.filetransfer.max_chunk_size = "250T"; Assert.AreEqual(h.filetransfer.max_chunk_size_real, 274877906944000); }