Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public void InstallationId_CanBeOverridden()
        {
            var options = new DatasyncClientOptions {
                InstallationId = "hijack"
            };
            var client = new DatasyncClient(Endpoint, options);

            Assert.Equal("hijack", client.InstallationId);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
 public async Task InitializeOfflineStoreAsync_Throws_WhenNoStore()
 {
     var client = new DatasyncClient(Endpoint);
     await Assert.ThrowsAsync <InvalidOperationException>(() => client.InitializeOfflineStoreAsync());
 }
Ejemplo n.º 13
0
        public void GetOfflineTableOfT_Throws_WhenNoStore()
        {
            var client = new DatasyncClient(Endpoint);

            Assert.Throws <InvalidOperationException>(() => client.GetOfflineTable <ClientMovie>("movies"));
        }
Ejemplo n.º 14
0
        public void GetOfflineTableOfT_Throws_OnInvalidTableName()
        {
            var client = new DatasyncClient(Endpoint);

            Assert.Throws <ArgumentException>(() => client.GetOfflineTable <ClientMovie>("    "));
        }
Ejemplo n.º 15
0
        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);
 }
Ejemplo n.º 17
0
 protected BaseOperationTest()
 {
     client = GetMovieClient();
     table  = client.GetRemoteTable <ClientMovie>("movies");
     soft   = client.GetRemoteTable <ClientMovie>("soft");
 }
Ejemplo n.º 18
0
        public void InstallationId_IsValid()
        {
            var client = new DatasyncClient(Endpoint);

            Assert.NotEmpty(client.InstallationId);
        }
 protected BaseOperationIdGeneratorTest(ITestOutputHelper logger) : base(logger)
 {
     client = GetMovieClientWithIdGenerator(store: store);
 }
Ejemplo n.º 20
0
 /// <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>();
 }
Ejemplo n.º 21
0
 public Linq_Tests()
 {
     _client = GetMockClient();
     _table  = _client.GetRemoteTable <KitchenSink>("kitchensink") as RemoteTable <KitchenSink>;
     _query  = new TableQuery <KitchenSink>(_table);
 }
Ejemplo n.º 22
0
 /// <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;
 }
Ejemplo n.º 23
0
        public void GetRemoteTable_Throws_OnInvalidTableName()
        {
            var client = new DatasyncClient(Endpoint);

            Assert.Throws <ArgumentException>(() => client.GetRemoteTable("    "));
        }
Ejemplo n.º 24
0
 public WrappedRemoteTable(string path, DatasyncClient client) : base(path, client)
 {
 }
Ejemplo n.º 25
0
 public OperationBatch_Tests()
 {
     client  = GetMockClient();
     store   = new MockOfflineStore();
     context = new SyncContext(client, store);
 }