예제 #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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #7
0
        public void InstallationId_CanBeOverridden()
        {
            var options = new DatasyncClientOptions {
                InstallationId = "hijack"
            };
            var client = new DatasyncClient(Endpoint, options);

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

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

            Assert.Throws <ArgumentException>(() => client.GetOfflineTable <ClientMovie>("    "));
        }
예제 #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);
 }
예제 #17
0
 protected BaseOperationTest()
 {
     client = GetMovieClient();
     table  = client.GetRemoteTable <ClientMovie>("movies");
     soft   = client.GetRemoteTable <ClientMovie>("soft");
 }
예제 #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);
 }
예제 #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>();
 }
예제 #21
0
 public Linq_Tests()
 {
     _client = GetMockClient();
     _table  = _client.GetRemoteTable <KitchenSink>("kitchensink") as RemoteTable <KitchenSink>;
     _query  = new TableQuery <KitchenSink>(_table);
 }
예제 #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;
 }
예제 #23
0
        public void GetRemoteTable_Throws_OnInvalidTableName()
        {
            var client = new DatasyncClient(Endpoint);

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