public void Init()
 {
     this.context             = new DataServiceContext(new Uri("http://temp.org/"), ODataProtocolVersion.V4);
     this.responseInfo        = new ResponseInfo(new RequestInfo(this.context), MergeOption.NoTracking);
     this.readingHelper       = new ODataMessageReadingHelper(this.responseInfo);
     this.atomResponseMessage = new ODataResponseMessageSimulator();
     this.atomResponseMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/AtOm");
     this.jsonResponseMessage = new ODataResponseMessageSimulator();
     this.jsonResponseMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/jsOn");
 }
 public void Init()
 {
     this.context = new DataServiceContext(new Uri("http://temp.org/"), ODataProtocolVersion.V4);
     this.responseInfo = new ResponseInfo(new RequestInfo(this.context), MergeOption.NoTracking);
     this.readingHelper = new ODataMessageReadingHelper(this.responseInfo);
     this.atomResponseMessage = new ODataResponseMessageSimulator();
     this.atomResponseMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/AtOm");
     this.jsonResponseMessage = new ODataResponseMessageSimulator();
     this.jsonResponseMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/jsOn");
 }
Ejemplo n.º 3
0
        public void Initialize()
        {
            this.host = new DataServiceHost2Simulator();

            var context = new DataServiceOperationContext(this.host);

            this.dataServiceSimulator = new DataServiceSimulator {
                OperationContext = context
            };

            var providerSimulator = new DataServiceProviderSimulator();

            DataServiceStaticConfiguration staticConfiguration = new DataServiceStaticConfiguration(this.dataServiceSimulator.Instance.GetType(), providerSimulator);
            IDataServiceProviderBehavior   providerBehavior    = DataServiceProviderBehavior.CustomDataServiceProviderBehavior;

            var resourceType = new ResourceType(typeof(object), ResourceTypeKind.EntityType, null, "SelectTestNamespace", "Fake", false)
            {
                CanReflectOnInstanceType = false, IsOpenType = true
            };

            resourceType.AddProperty(new ResourceProperty("Id", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)))
            {
                CanReflectOnInstanceTypeProperty = false
            });
            var resourceSet = new ResourceSet("FakeSet", resourceType);

            resourceSet.SetReadOnly();

            providerSimulator.AddResourceSet(resourceSet);

            var configuration = new DataServiceConfiguration(providerSimulator);

            configuration.SetEntitySetAccessRule("*", EntitySetRights.All);

            var provider = new DataServiceProviderWrapper(
                new DataServiceCacheItem(
                    configuration,
                    staticConfiguration),
                providerSimulator,
                providerSimulator,
                this.dataServiceSimulator,
                false);

            this.dataServiceSimulator.ProcessingPipeline = new DataServiceProcessingPipeline();
            this.dataServiceSimulator.Provider           = provider;
            provider.ProviderBehavior = providerBehavior;
            this.dataServiceSimulator.Configuration = new DataServiceConfiguration(providerSimulator);
            this.dataServiceSimulator.Configuration.DataServiceBehavior.MaxProtocolVersion = ODataProtocolVersion.V4;

            this.responseMessageSimulator = new ODataResponseMessageSimulator();
        }
        public void Initialize()
        {
            this.host = new DataServiceHost2Simulator();

            var context = new DataServiceOperationContext(this.host);
            this.dataServiceSimulator = new DataServiceSimulator { OperationContext = context };

            var providerSimulator = new DataServiceProviderSimulator();

            DataServiceStaticConfiguration staticConfiguration = new DataServiceStaticConfiguration(this.dataServiceSimulator.Instance.GetType(), providerSimulator);
            IDataServiceProviderBehavior providerBehavior = DataServiceProviderBehavior.CustomDataServiceProviderBehavior;

            var resourceType = new ResourceType(typeof(object), ResourceTypeKind.EntityType, null, "SelectTestNamespace", "Fake", false) { CanReflectOnInstanceType = false, IsOpenType = true };
            resourceType.AddProperty(new ResourceProperty("Id", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int))) { CanReflectOnInstanceTypeProperty = false });
            var resourceSet = new ResourceSet("FakeSet", resourceType);
            resourceSet.SetReadOnly();

            providerSimulator.AddResourceSet(resourceSet);

            var configuration = new DataServiceConfiguration(providerSimulator);
            configuration.SetEntitySetAccessRule("*", EntitySetRights.All);

            var provider = new DataServiceProviderWrapper(
                new DataServiceCacheItem(
                    configuration,
                    staticConfiguration), 
                providerSimulator, 
                providerSimulator, 
                this.dataServiceSimulator,
                false);

            this.dataServiceSimulator.ProcessingPipeline = new DataServiceProcessingPipeline();
            this.dataServiceSimulator.Provider = provider;
            provider.ProviderBehavior = providerBehavior;
            this.dataServiceSimulator.Configuration = new DataServiceConfiguration(providerSimulator);
            this.dataServiceSimulator.Configuration.DataServiceBehavior.MaxProtocolVersion = ODataProtocolVersion.V4;

            this.responseMessageSimulator = new ODataResponseMessageSimulator();
        }
        public void ShortIntegrationEventsShouldOccurInReadOrderForAtom()
        {
            var results = TestValidReadWithAllHooked(() =>
            {
                var simulator = new ODataResponseMessageSimulator();
                simulator.SetHeader("Content-Type", "application/atom+xml");
                simulator.SetHeader("Accept", "application/atom+xml");
                simulator.Stream = new MemoryStream(Encoding.UTF8.GetBytes(ProductsWithExpandedCategoryEntry));

                var oms = new ODataMessageReaderSettings()
                {
                    EnableAtom = true
                };
                var messageReader = new ODataMessageReader((IODataResponseMessage)simulator, oms);
                return(messageReader.CreateODataFeedReader());
            });

            results.Should().HaveCount(18);
            results[0].Validate <ReadingFeedArgs>(OnFeedStart, "http://services.odata.org/OData/OData.svc/Products");
            results[1].Validate <ReadingEntryArgs>(OnEntryStart, "http://services.odata.org/OData/OData.svc/Products(0)");
            results[2].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkStart, "Category");
            results[3].Validate <ReadingEntryArgs>(OnEntryStart, "http://services.odata.org/OData/OData.svc/Categories(0)");
            results[4].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkStart, "Products");
            results[5].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkEnd, "Products");
            results[6].Validate <ReadingEntryArgs>(OnEntryEnd, "http://services.odata.org/OData/OData.svc/Categories(0)");
            results[7].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkEnd, "Category");
            results[8].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkStart, "Orders");
            results[9].Validate <ReadingFeedArgs>(OnFeedStart, "http://services.odata.org/OData/OData.svc/Products(0)/Orders");
            results[10].Validate <ReadingEntryArgs>(OnEntryStart, "http://services.odata.org/OData/OData.svc/Orders(0)");
            results[11].Validate <ReadingEntryArgs>(OnEntryEnd, "http://services.odata.org/OData/OData.svc/Orders(0)");
            results[12].Validate <ReadingFeedArgs>(OnFeedEnd, "http://services.odata.org/OData/OData.svc/Products(0)/Orders");
            results[13].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkEnd, "Orders");
            results[14].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkStart, "Supplier");
            results[15].Validate <ReadingNavigationLinkArgs>(OnNavigationLinkEnd, "Supplier");
            results[16].Validate <ReadingEntryArgs>(OnEntryEnd, "http://services.odata.org/OData/OData.svc/Products(0)");
            results[17].Validate <ReadingFeedArgs>(OnFeedEnd, "http://services.odata.org/OData/OData.svc/Products");
        }