예제 #1
0
        public async Task RegisterConverterGivenGenericMethodCalledAndPosted()
        {
            await TestingHost.Instance.GetNewWebHost().ConfigureAwait(true);

            var settings = new ODataClientSettings
            {
                BaseUri = TestingHost.Instance.BaseODataUrl,
                IgnoreUnmappedProperties = true,
            };

            settings.RegisterExtendableEnum <SampleStatus>();
            var client = new ODataClient(settings);

            var originalCount = DataContext.Books.Count;

            var novel = new SampleBook
            {
                Id     = Guid.NewGuid().ToString(),
                Title  = "The Never Ending Novel",
                Status = SampleStatus.Active,
            };

            await client
            .For <SampleBook>()
            .Set(novel)
            .InsertEntryAsync()
            .ConfigureAwait(true);

            Assert.AreEqual(originalCount + 1, DataContext.Books.Count);
        }
예제 #2
0
        public async Task ThrowArgumentExceptionGivenTypeIsNotExtendableEnumDescendant()
        {
            await TestingHost.Instance.GetNewWebHost().ConfigureAwait(true);

            var settings = new ODataClientSettings
            {
                BaseUri = TestingHost.Instance.BaseODataUrl,
            };

            settings.RegisterExtendableEnum(typeof(string));
            Assert.Fail("An ArgumentException should have been thrown.");
        }
예제 #3
0
        public async Task RegisterConverterGivenNonGenericMethodCalled()
        {
            await TestingHost.Instance.GetNewWebHost().ConfigureAwait(true);

            var settings = new ODataClientSettings
            {
                BaseUri = TestingHost.Instance.BaseODataUrl,
            };

            settings.RegisterExtendableEnum(typeof(SampleStatus));
            var client = new ODataClient(settings);

            var target = DataContext.Books.First();

            var book = await client
                       .For <SampleBook>()
                       .Key(target.Id)
                       .FindEntryAsync()
                       .ConfigureAwait(true);

            Assert.AreEqual(target.Status, book.Status);
        }