Ejemplo n.º 1
0
        public async Task DateKinds()
        {
            IMobileServiceTable <DateExample> table = GetClient().GetTable <DateExample>();

            DateTime    original = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);
            DateExample instance = new DateExample {
                Date = original
            };

            Log("Start Kind: {0}", instance.Date.Kind);
            await table.InsertAsync(instance);

            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);
            Assert.AreEqual(original, instance.Date);

            Log("Change to UTC");
            instance.Date = new DateTime(2010, 5, 21, 0, 0, 0, 0, DateTimeKind.Utc);
            await table.UpdateAsync(instance);

            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);

            Log("Change to Local");
            instance.Date = new DateTime(2010, 5, 21, 0, 0, 0, 0, DateTimeKind.Local);
            await table.UpdateAsync(instance);

            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);
        }
Ejemplo n.º 2
0
        public async Task InsertAndQuery()
        {
            IMobileServiceTable<DateExample> table = GetClient().GetTable<DateExample>();

            DateTime date = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);
            Log("Start: {0}", date);

            Log("Inserting instance");
            DateExample instance = new DateExample { Date = date };
            await table.InsertAsync(instance);
            Assert.AreEqual(date, instance.Date);

            Log("Querying for instance");
            List<DateExample> items = await table.Where(i => i.Date == date).Where(i => i.Id >= instance.Id).ToListAsync();
            Assert.AreEqual(1, items.Count);
            Assert.AreEqual(date, items[0].Date);

            Log("Finish: {0}", items[0].Date);
        }
Ejemplo n.º 3
0
        public async Task ChangeCulture()
        {
            IMobileServiceTable <DateExample> table = GetClient().GetTable <DateExample>();

            CultureInfo threadCulture   = CultureInfo.DefaultThreadCurrentCulture;
            CultureInfo threadUICulture = CultureInfo.DefaultThreadCurrentUICulture;

            DateTime    original = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);
            DateExample instance = new DateExample {
                Date = original
            };
            await table.InsertAsync(instance);

            Log("Change culture to ar-EG");
            CultureInfo arabic = new CultureInfo("ar-EG");

            CultureInfo.DefaultThreadCurrentCulture   = arabic;
            CultureInfo.DefaultThreadCurrentUICulture = arabic;
            DateExample arInstance = await table.LookupAsync(instance.Id);

            Assert.AreEqual(original, arInstance.Date);

            Log("Change culture to zh-CHS");
            CultureInfo chinese = new CultureInfo("zh-CHS");

            CultureInfo.DefaultThreadCurrentCulture   = chinese;
            CultureInfo.DefaultThreadCurrentUICulture = chinese;
            DateExample zhInstance = await table.LookupAsync(instance.Id);

            Assert.AreEqual(original, zhInstance.Date);

            Log("Change culture to ru-RU");
            CultureInfo russian = new CultureInfo("ru-RU");

            CultureInfo.DefaultThreadCurrentCulture   = russian;
            CultureInfo.DefaultThreadCurrentUICulture = russian;
            DateExample ruInstance = await table.LookupAsync(instance.Id);

            Assert.AreEqual(original, ruInstance.Date);

            CultureInfo.DefaultThreadCurrentCulture   = threadCulture;
            CultureInfo.DefaultThreadCurrentUICulture = threadUICulture;
        }
Ejemplo n.º 4
0
        public async Task InsertAndQuery()
        {
            IMobileServiceTable <DateExample> table = GetClient().GetTable <DateExample>();

            DateTime date = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);

            Log("Start: {0}", date);

            Log("Inserting instance");
            DateExample instance = new DateExample {
                Date = date
            };
            await table.InsertAsync(instance);

            Assert.AreEqual(date, instance.Date);

            Log("Querying for instance");
            List <DateExample> items = await table.Where(i => i.Date == date).Where(i => i.Id >= instance.Id).ToListAsync();

            Assert.AreEqual(1, items.Count);
            Assert.AreEqual(date, items[0].Date);

            Log("Finish: {0}", items[0].Date);
        }
Ejemplo n.º 5
0
        public async Task ChangeCulture()
        {
            IMobileServiceTable<DateExample> table = GetClient().GetTable<DateExample>();

            CultureInfo threadCulture = CultureInfo.DefaultThreadCurrentCulture;
            CultureInfo threadUICulture = CultureInfo.DefaultThreadCurrentUICulture;

            DateTime original = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);
            DateExample instance = new DateExample { Date = original };
            await table.InsertAsync(instance);
            
            Log("Change culture to ar-EG");
            CultureInfo arabic = new CultureInfo("ar-EG");
            CultureInfo.DefaultThreadCurrentCulture = arabic;
            CultureInfo.DefaultThreadCurrentUICulture = arabic;
            DateExample arInstance = await table.LookupAsync(instance.Id);
            Assert.AreEqual(original, arInstance.Date);

            Log("Change culture to zh-CHS");
            CultureInfo chinese = new CultureInfo("zh-CHS");
            CultureInfo.DefaultThreadCurrentCulture = chinese;
            CultureInfo.DefaultThreadCurrentUICulture = chinese;
            DateExample zhInstance = await table.LookupAsync(instance.Id);
            Assert.AreEqual(original, zhInstance.Date);

            Log("Change culture to ru-RU");
            CultureInfo russian = new CultureInfo("ru-RU");
            CultureInfo.DefaultThreadCurrentCulture = russian;
            CultureInfo.DefaultThreadCurrentUICulture = russian;
            DateExample ruInstance = await table.LookupAsync(instance.Id);
            Assert.AreEqual(original, ruInstance.Date);

            CultureInfo.DefaultThreadCurrentCulture = threadCulture;
            CultureInfo.DefaultThreadCurrentUICulture = threadUICulture;
        }
Ejemplo n.º 6
0
        public async Task DateKinds()
        {
            IMobileServiceTable<DateExample> table = GetClient().GetTable<DateExample>();

            DateTime original = new DateTime(2009, 10, 21, 14, 22, 59, 860, DateTimeKind.Local);
            DateExample instance = new DateExample { Date = original };
            
            Log("Start Kind: {0}", instance.Date.Kind);
            await table.InsertAsync(instance);
            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);
            Assert.AreEqual(original, instance.Date);

            Log("Change to UTC");
            instance.Date = new DateTime(2010, 5, 21, 0, 0, 0, 0, DateTimeKind.Utc);
            await table.UpdateAsync(instance);
            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);

            Log("Change to Local");
            instance.Date = new DateTime(2010, 5, 21, 0, 0, 0, 0, DateTimeKind.Local);
            await table.UpdateAsync(instance);
            Assert.AreEqual(DateTimeKind.Local, instance.Date.Kind);
        }