public async Task ShouldOAuthRequest() { await FHClient.Init(); //given ServiceFinder.RegisterType <IOAuthClientHandlerService, MockOAuthClient>(); var json = JObject.Parse(@"{ ""hosts"": {""host"": ""HOST""} }"); var config = new FHConfig(new MockDeviceService()); var props = new CloudProps(json, config); var authRequest = new FHAuthRequest(props); authRequest.SetAuthUser("gmail", "user", "password"); var mockHttpCLient = new MockHttpClient { Content = "{\"status\": \"ok\", \"url\": \"http://oauthurl.url\"}" }; FHHttpClientFactory.Get = () => mockHttpCLient; //when var response = await authRequest.ExecAsync(); //then Assert.IsNotNull(response); var responseParams = response.GetResponseAsDictionary(); Assert.IsNotNull(responseParams); Assert.AreEqual("token", responseParams["sessionToken"]); }
private static void RegisterServices() { ServiceFinder.RegisterType <IOAuthClientHandlerService, OAuthClientHandlerService> (); ServiceFinder.RegisterType <IDataService, DataService> (); ServiceFinder.RegisterType <IIOService, IOService> (); ServiceFinder.RegisterType <IDeviceService, DeviceService> (); ServiceFinder.RegisterType <IHashService, HashService> (); ServiceFinder.RegisterType <ILogService, LogService> (); ServiceFinder.RegisterType <IMonitorService, MonitorService> (); ServiceFinder.RegisterType <INetworkService, NetworkService> (); }
public MockResponseDataset(string datasetId) { DatasetId = datasetId; SyncConfig = new FHSyncConfig { SyncCloud = FHSyncConfig.SyncCloudType.Mbbas }; MetaData = new FHSyncMetaData(); QueryParams = new Dictionary <string, string>(); UidMapping = new Dictionary <string, string>(); dataRecords = new InMemoryDataStore <FHSyncDataRecord <T> > { PersistPath = GetPersistFilePathForDataset(SyncConfig, datasetId, DATA_PERSIST_FILE_NAME) }; pendingRecords = new InMemoryDataStore <FHSyncPendingRecord <T> > { PersistPath = GetPersistFilePathForDataset(SyncConfig, datasetId, PENDING_DATA_PERSIST_FILE_NAME) }; ServiceFinder.RegisterType <IHashService, TestHasher>(); Save(); }