/// <summary> /// Creates a new <see cref="RemoteTable"/> instance to perform /// untyped (JSON) requests to a remote table. /// </summary> /// <param name="tableName">The name of the table.</param> /// <param name="serviceClient">The service client that created this table.</param> internal RemoteTable(string tableName, DatasyncClient serviceClient) { Arguments.IsValidTableName(tableName, nameof(tableName)); Arguments.IsNotNull(serviceClient, nameof(serviceClient)); ServiceClient = serviceClient; TableName = tableName; }
public void CtorString_Valid_SetsEndpoint(EndpointTestCase testcase) { var client = new DatasyncClient(testcase.BaseEndpoint); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); Assert.NotNull(client.HttpClient); }
public void GetRemoteTableOfT_String_ProducesTable() { var client = new DatasyncClient(Endpoint); var table = client.GetRemoteTable <ClientMovie>("movies"); Assert.IsAssignableFrom <IRemoteTable <ClientMovie> >(table); Assert.Same(client, table.ServiceClient); Assert.Equal("movies", table.TableName); }
public void CtorUriOptions_Valid_SetsEndpoint(EndpointTestCase testcase) { var options = new DatasyncClientOptions(); var client = new DatasyncClient(new Uri(testcase.BaseEndpoint), options); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.Same(options, client.ClientOptions); Assert.NotNull(client.HttpClient); }
public void GetOfflineTableOfT_String_OnNullTableName() { var client = new DatasyncClient(Endpoint, clientOptions); var table = client.GetOfflineTable <ClientMovie>(null); Assert.IsAssignableFrom <IOfflineTable <ClientMovie> >(table); Assert.Same(client, table.ServiceClient); Assert.Equal("clientmovie", table.TableName); }
public void GetOfflineTable_ProducesTable() { var client = new DatasyncClient(Endpoint, clientOptions); var table = client.GetOfflineTable("movies"); Assert.IsAssignableFrom <IOfflineTable>(table); Assert.Same(client, table.ServiceClient); Assert.Equal("movies", table.TableName); }
public void InstallationId_CanBeOverridden() { var options = new DatasyncClientOptions { InstallationId = "hijack" }; var client = new DatasyncClient(Endpoint, options); Assert.Equal("hijack", client.InstallationId); }
public void CtorUriAuth_Valid_SetsEndpoint(EndpointTestCase testcase) { var authProvider = new GenericAuthenticationProvider(() => Task.FromResult(ValidAuthenticationToken), "X-ZUMO-AUTH"); var client = new DatasyncClient(new Uri(testcase.BaseEndpoint), authProvider); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); Assert.NotNull(client.HttpClient); }
public async Task InitializedOfflineStoreAsync_CallsInit_WhenStore() { var store = new MockOfflineStore(); var client = new DatasyncClient(Endpoint, new DatasyncClientOptions { OfflineStore = store }); await client.InitializeOfflineStoreAsync(); Assert.True(client.SyncContext.IsInitialized); }
public void Ctor_CreateTable_WhenArgsCorrect() { var store = new MockOfflineStore(); var options = new DatasyncClientOptions { OfflineStore = store }; var client = new DatasyncClient(Endpoint, options); var table = new OfflineTable("movies", client); Assert.Same(client, table.ServiceClient); Assert.Equal("movies", table.TableName); }
public void SerializerSettings_CopiedToSerializer() { var settings = new DatasyncSerializerSettings { CamelCasePropertyNames = true }; var options = new DatasyncClientOptions { SerializerSettings = settings }; var client = new DatasyncClient(Endpoint, options); Assert.Same(settings, client.Serializer.SerializerSettings); }
public async Task InitializeOfflineStoreAsync_Throws_WhenNoStore() { var client = new DatasyncClient(Endpoint); await Assert.ThrowsAsync <InvalidOperationException>(() => client.InitializeOfflineStoreAsync()); }
public void GetOfflineTableOfT_Throws_WhenNoStore() { var client = new DatasyncClient(Endpoint); Assert.Throws <InvalidOperationException>(() => client.GetOfflineTable <ClientMovie>("movies")); }
public void GetOfflineTableOfT_Throws_OnInvalidTableName() { var client = new DatasyncClient(Endpoint); Assert.Throws <ArgumentException>(() => client.GetOfflineTable <ClientMovie>(" ")); }
public void GetOfflineTable_Throws_OnNullTableName() { var client = new DatasyncClient(Endpoint); Assert.Throws <ArgumentNullException>(() => client.GetOfflineTable(null)); }
public OfflineTable_generic_Tests() : base() { store = new MockOfflineStore(); client = GetMockClient(null, store); }
protected BaseOperationTest() { client = GetMovieClient(); table = client.GetRemoteTable <ClientMovie>("movies"); soft = client.GetRemoteTable <ClientMovie>("soft"); }
public void InstallationId_IsValid() { var client = new DatasyncClient(Endpoint); Assert.NotEmpty(client.InstallationId); }
protected BaseOperationIdGeneratorTest(ITestOutputHelper logger) : base(logger) { client = GetMovieClientWithIdGenerator(store: store); }
/// <summary> /// Creates a new <see cref="RemoteTable{T}"/> instance to perform /// typed requests to a remote table. /// </summary> /// <param name="tableName">The name of the table.</param> /// <param name="serviceClient">The service client that created this table.</param> internal RemoteTable(string tableName, DatasyncClient serviceClient) : base(tableName, serviceClient) { // ResolveTableName has a side effect of initializing the contract in the contract resolver, // so call it here to ensure initialization. serviceClient.Serializer.ResolveTableName <T>(); }
public Linq_Tests() { _client = GetMockClient(); _table = _client.GetRemoteTable <KitchenSink>("kitchensink") as RemoteTable <KitchenSink>; _query = new TableQuery <KitchenSink>(_table); }
/// <summary> /// Creates a new <see cref="OfflineTable{T}"/> instance to perform /// typed requests to an offline table. /// </summary> /// <param name="tableName">The name of the table.</param> /// <param name="serviceClient">The service client that created this table.</param> public OfflineTable(string tableName, DatasyncClient serviceClient) : base(tableName, serviceClient) { RemoteTable = ServiceClient.GetRemoteTable <T>(tableName); Serializer = ServiceClient.Serializer; }
public void GetRemoteTable_Throws_OnInvalidTableName() { var client = new DatasyncClient(Endpoint); Assert.Throws <ArgumentException>(() => client.GetRemoteTable(" ")); }
public WrappedRemoteTable(string path, DatasyncClient client) : base(path, client) { }
public OperationBatch_Tests() { client = GetMockClient(); store = new MockOfflineStore(); context = new SyncContext(client, store); }