示例#1
0
        public async Task JsonStringHurlAsyncTest()
        {
            SqlDataRequest dataRequest = new SqlDataRequest(ConnectionString);

            var obj2 = new
            {
                Id           = Guid.NewGuid(),
                Name         = string.Format("Test Async:{0}", DateTime.Now.ToLongDateString()),
                Description  = string.Format("Description Async:{0}", DateTime.Now.ToLongDateString()),
                Details      = string.Format("Details Async:{0}", DateTime.Now.ToLongDateString()),
                RecordedDate = DateTime.Now,
                IsActive     = true
            };

            int rowsAffected2 = await dataRequest.HurlAsync("[dbo].[usp_Test_Insert]", JsonConvert.SerializeObject(obj2));

            Assert.IsTrue(rowsAffected2 > 0);
        }
示例#2
0
        public async Task MultiObjectHurlAsyncTest()
        {
            SqlDataRequest dataRequest = new SqlDataRequest(ConnectionString);

            var objForList1 = new
            {
                Id           = Guid.NewGuid(),
                Name         = string.Format("Test Async:{0}", DateTime.Now.ToLongDateString()),
                Description  = string.Format("Description Async:{0}", DateTime.Now.ToLongDateString()),
                Details      = string.Format("Details Async:{0}", DateTime.Now.ToLongDateString()),
                RecordedDate = DateTime.Now,
                IsActive     = true
            };

            var objForList2 = new
            {
                Id           = Guid.NewGuid(),
                Name         = string.Format("Test Async :{0}", DateTime.Now.ToLongDateString()),
                Description  = string.Format("Description Async :{0}", DateTime.Now.ToLongDateString()),
                Details      = string.Format("Details Async :{0}", DateTime.Now.ToLongDateString()),
                RecordedDate = DateTime.Now,
                IsActive     = true
            };

            var objForList3 = new
            {
                Id           = Guid.NewGuid(),
                Name         = string.Format("Test Async :{0}", DateTime.Now.ToLongDateString()),
                Description  = string.Format("Description Async :{0}", DateTime.Now.ToLongDateString()),
                Details      = string.Format("Details Async:{0}", DateTime.Now.ToLongDateString()),
                RecordedDate = DateTime.Now,
                IsActive     = true
            };
            List <dynamic> objects = new List <dynamic>()
            {
                objForList1, objForList2, objForList3
            };

            int rowsAffected3 = await dataRequest.HurlAsync("[dbo].[usp_Test_Insert]", objects);

            Assert.IsTrue(rowsAffected3 > 0);
        }