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); }
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); }
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")); }