Esempio n. 1
0
        public InfoCarrierQueryResultMapperTest(NorthwindQueryInfoCarrierFixture <NoopModelCustomizer> fixture)
        {
            this.context = fixture.CreateContext();

            this.queryResultMapper = new InfoCarrierQueryResultMapper(
                this.context.GetService <IQueryContextFactory>().Create(),
                new Aqua.TypeSystem.TypeResolver(),
                new Aqua.TypeSystem.TypeInfoProvider());

            IEnumerable <DynamicObject> Yield(params DynamicObject[] dynamicObjects) => dynamicObjects;

            // Mapped array
            {
                var obj         = new[] { 1, 2, 3 };
                var array       = obj.Select(x => new DynamicObject(x)).ToArray();
                var mappedArray = new DynamicObject();
                mappedArray.Add("ArrayType", new Aqua.TypeSystem.TypeInfo(obj.GetType(), includePropertyInfos: false));
                mappedArray.Add("Elements", array);
                this.arrayDto = Yield(mappedArray);
            }

            // Mapped list
            {
                var enumerable = new List <int> {
                    1, 2, 3
                };
                var mappedEnumerable = new DynamicObject(typeof(IEnumerable <int>));
                mappedEnumerable.Add(
                    "Elements",
                    new DynamicObject(enumerable.Select(x => new DynamicObject(x)).ToList()));
                this.listDto = Yield(mappedEnumerable);
            }

            // Mapped grouping
            {
                var key      = "hello";
                var elements = new List <int> {
                    1, 2, 3
                };
                var mappedGrouping = new DynamicObject(typeof(IGrouping <string, int>));
                mappedGrouping.Add("Key", new DynamicObject(key));
                mappedGrouping.Add(
                    "Elements",
                    new DynamicObject(elements.Select(x => new DynamicObject(x)).ToList()));
                this.groupingDto = Yield(mappedGrouping);
            }

            // Mapped product entity
            {
                var mappedProduct = new DynamicObject(typeof(Product));
                mappedProduct.Add("__EntityType", "Product");
                mappedProduct.Add("__EntityLoadedNavigations", new DynamicObject(new List <string>()));
                mappedProduct.Add("ProductID", new DynamicObject(1));
                mappedProduct.Add("ProductName", new DynamicObject("Potato"));
                mappedProduct.Add("Discontinued", new DynamicObject(false));
                mappedProduct.Add("UnitsInStock", new DynamicObject(default(ushort)));
                this.productDto = Yield(mappedProduct);
            }
        }
 public ConcurrencyDetectorInfoCarrierTest(NorthwindQueryInfoCarrierFixture <NoopModelCustomizer> fixture)
     : base(fixture)
 {
 }