Esempio n. 1
0
        public void AnonymousObject_SameProperties_CleverConverts()
        {
            var obj   = new { Name = "Fred", Age = 20 };
            var model = ConversionUtility.CleverConvertValue <TestModel>(obj);

            Assert.Equal(obj.Name, model.Name);
            Assert.Equal(obj.Age, model.Age);
        }
Esempio n. 2
0
        public async Task SetValueAsync(IDeferredItem <TItem> item, object deserializedValue, IDataTransaction dataTransaction)
        {
            await item.LoadAsync(); // TODO: and do we want to load items within the set function?

            TValue newValue = ConversionUtility.CleverConvertValue <TValue>(deserializedValue);

            _setterAction(item.LoadedItem, newValue);
        }
Esempio n. 3
0
        public void StringArray_CleverConverts()
        {
            var arr = new[] { "Uno", "Dos", "Tres" };

            var model = ConversionUtility.CleverConvertValue <string[]>(arr);

            Assert.Equal(arr[0], model[0]);
            Assert.Equal(arr[1], model[1]);
            Assert.Equal(arr[2], model[2]);
        }
Esempio n. 4
0
        public void AnonymousArray_SameProperties_CleverConverts()
        {
            var arr = new[]
            {
                new { Name = "Fred", Age = 20 },
                new { Name = "Bill", Age = 43 },
                new { Name = "Ben", Age = 65 }
            };

            var model = ConversionUtility.CleverConvertValue <TestModel[]>(arr);

            Assert.Equal(arr[0].Name, model[0].Name);
            Assert.Equal(arr[1].Age, model[1].Age);
            Assert.Equal(arr[2].Name, model[2].Name);
            Assert.Equal(arr[2].Age, model[2].Age);
        }