예제 #1
0
        public void Test_SessionFromToken()
        {
            var serverInfoMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
                                            ""version"": ""4.0.6"",
                                            ""features"": [
                                            ""seafile-basic"",
                                            ]}")
            };

            // From Token automatically checks the token using the CheckAccountInfo() command
            var message = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("{\"usage\": 26038531,\"total\": 104857600,\"email\": \"[email protected]\"}")
            };

            var mockedConnection = new MockedSeafConnection();

            mockedConnection.FakeResponseFor <GetServerInfoRequest>(serverInfoMessage);
            mockedConnection.FakeResponseFor <AccountInfoRequest>(message);
            var session = ExecuteSync(() => SeafSession.FromToken(mockedConnection, new Uri("http://www.example.com"), FakeToken));

            Assert.IsNotNull(session);
            Assert.AreEqual(FakeToken, session.AuthToken);
            Assert.AreEqual("*****@*****.**", session.Username);
        }
예제 #2
0
        public void Test_Sessionless_Ping()
        {
            var connection = new MockedSeafConnection();
            var message    = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("\"pong\"")
            };

            connection.FakeResponseFor <PingRequest>(message);

            var result = ExecuteSync(() => SeafSession.Ping(connection, new Uri("http://www.example.com")));

            Assert.IsTrue(result);
        }
예제 #3
0
        public void Test_GetServerInfo()
        {
            var connection = new MockedSeafConnection();
            var message    = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
                                            ""version"": ""4.0.6"",
                                            ""features"": [
                                            ""seafile-basic"",
                                            ]}")
            };

            connection.FakeResponseFor <GetServerInfoRequest>(message);

            var serverInfo = ExecuteSync(() => SeafSession.GetServerInfo(connection, new Uri("http://www.example.com")));

            Assert.AreEqual("4.0.6", serverInfo.Version);
            Assert.IsTrue(serverInfo.Features.Contains("seafile-basic"));
        }