Exemplo n.º 1
0
        public void ApplyCommonSettingsUsesODataServerBehavior()
        {
            var testSubject = new ODataMessageWriterSettings();

            testSubject.EnableDefaultBehavior();
            MessageWriterBuilder.ApplyCommonSettings(testSubject, new Uri("http://www.example.com"), VersionUtil.Version4Dot0, this.dataServiceSimulator, this.responseMessageSimulator);
            testSubject.WriterBehavior.ShouldHave().AllProperties().EqualTo(ODataWriterBehavior.CreateODataServerBehavior());
        }
Exemplo n.º 2
0
        public void VersionShouldBeConvertedAndSet()
        {
            var testSubject = new ODataMessageWriterSettings {
                Version = ODataVersion.V4
            };

            MessageWriterBuilder.ApplyCommonSettings(testSubject, new Uri("http://www.example.com"), VersionUtil.Version4Dot0, this.dataServiceSimulator, this.responseMessageSimulator);
            testSubject.Version.Should().Be(ODataVersion.V4);
        }
Exemplo n.º 3
0
        public void ServiceUriShouldBeSetAsBase()
        {
            Uri serviceUri  = new Uri("http://www.example.com");
            var testSubject = new ODataMessageWriterSettings {
                BaseUri = null
            };

            MessageWriterBuilder.ApplyCommonSettings(testSubject, serviceUri, VersionUtil.Version4Dot0, this.dataServiceSimulator, this.responseMessageSimulator);
            testSubject.BaseUri.Should().BeSameAs(serviceUri);
        }
Exemplo n.º 4
0
        public void ApplyCommonSettingsShouldDisableMessageStreamDisposalForTopLevel()
        {
            // AstoriaResponseMessage is only used for representing top-level responses, not individual parts of a batched response.
            var topLevelResponseMessage = new AstoriaResponseMessage(this.host);

            var testSubject = new ODataMessageWriterSettings {
                EnableMessageStreamDisposal = true
            };

            MessageWriterBuilder.ApplyCommonSettings(testSubject, new Uri("http://www.example.com"), VersionUtil.Version4Dot0, this.dataServiceSimulator, topLevelResponseMessage);
            testSubject.EnableMessageStreamDisposal.Should().BeFalse();
        }
Exemplo n.º 5
0
        public void ApplyCommonSettingsShouldNotDisableMessageStreamDisposalForNonTopLevel()
        {
            // AstoriaResponseMessage is only used for representing top-level responses, not individual parts of a batched response.
            // For this test, its enough to just pass the test implementation of the response contract.
            var nonTopLevelResponseMessage = this.responseMessageSimulator;

            var testSubject = new ODataMessageWriterSettings {
                EnableMessageStreamDisposal = false
            };

            MessageWriterBuilder.ApplyCommonSettings(testSubject, new Uri("http://www.example.com"), VersionUtil.Version4Dot0, this.dataServiceSimulator, nonTopLevelResponseMessage);
            testSubject.EnableMessageStreamDisposal.Should().BeTrue();
        }