예제 #1
0
        public void SimpleConnect()
        {
            var protocol = new FCP2Protocol("test-client");

            protocol.ClientHello();
            protocol.NodeHelloEvent += Protocol_NodeHelloEvent;

            int retry = 200;

            while (!_hello && --retry > 0)
            {
                System.Threading.Thread.Sleep(100);
            }

            Assert.IsTrue(_hello);

            Assert.AreEqual("2.0", simpleResult?.FcpVersion);
            Assert.AreEqual("Fred", simpleResult?.Node);

            protocol.Disconnect();
        }
예제 #2
0
        public void Test2()
        {
            var protocol = new FCP2Protocol("test-client");

            protocol.ClientHello();

            protocol.DataFoundEvent += Protocol_DataFoundEvent;
            protocol.AllDataEvent   += Protocol_AllDataEvent;

            const string TestIdentifier = "test-file";

            protocol.ClientGet("CHK@khy~PN5-P-Ze18SdPfb~eMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8/test.txt", TestIdentifier);

            int retry = 1000;

            while (--retry > 0 && !Ready())
            {
                System.Threading.Thread.Sleep(100);
            }

            const int    TestSize        = 16;
            const string TestContentType = "text/plain";
            const string TestData        = "this is a test\r\n";

            Assert.IsNotNull(allData);
            Assert.IsNotNull(dataFound);

            Assert.AreEqual(TestSize, dataFound.Datalength);
            Assert.AreEqual(TestIdentifier, dataFound.Identifier);
            Assert.IsFalse(dataFound.Global);
            Assert.AreEqual(TestContentType, dataFound.ContentType);

            Assert.IsTrue(allData.StartupTime <= allData.CompletionTime);

            Assert.AreEqual(TestSize, allData.Datalength);
            Assert.AreEqual(TestIdentifier, allData.Identifier);
            Assert.AreEqual(TestData, testData.ToString());

            protocol.Disconnect();
        }