async Task Delete(string theBoxId, string itemId)
    {
        #region NewtonsoftDelete
        var box = new NewtonsoftJsonBox(
            httpClient,
            theBoxId,
            serializer);
        await box.DeleteAsync(itemId);

        #endregion
    }
    async Task Create(string theBoxId)
    {
        #region NewtonsoftCreate
        var box = new NewtonsoftJsonBox(
            httpClient,
            theBoxId,
            serializer);
        var person = new Person
        {
            Age  = 10,
            Name = "Lesle"
        };
        await box.CreateAsync(person);

        #endregion
    }
Example #3
0
        public async Task CollectionNameTooLong()
        {
            var mockHttp = new MockHttpMessageHandler();
            var jsonBox  = new NewtonsoftJsonBox(mockHttp.ToHttpClient(), "testbox___jsonboxnet", new JsonSerializer());

            var fixture = new Fixture();
            var item    = fixture.Create <TestObject>();

            await jsonBox.Invoking(async jb => await jsonBox.CreateAsync("collection_collection", item))
            .Should().ThrowAsync <ArgumentException>();

            await jsonBox.Invoking(async jb => await jsonBox.CreateManyAsync("collection_collection", item))
            .Should().ThrowAsync <ArgumentException>();

            await jsonBox.Invoking(async jb => await jsonBox.CreateManyAsync("collection_collection", new List <TestObject> {
                item
            }))
            .Should().ThrowAsync <ArgumentException>();
        }