Exemplo n.º 1
0
        private async Task Test_Nested_Scope_Update_Async(ManualResetEvent e)
        {
            Guid id;
            var  methodName = MethodBase.GetCurrentMethod().Name;

            using (var scope = new DataAccessScope())
            {
                var child = this.model.Children.Create();

                await scope.FlushAsync().ContinueOnAnyContext();

                id = child.Id;

                using (var inner = new DataAccessScope())
                {
                    child.Nickname = methodName;

                    await inner.CompleteAsync().ContinueOnAnyContext();
                }

                await scope.FlushAsync();

                Assert.AreEqual(child.Id, this.model.Children.Single(c => c.Nickname == methodName).Id);

                await scope.CompleteAsync().ContinueOnAnyContext();
            }

            Assert.AreEqual(id, this.model.Children.Single(c => c.Nickname == methodName).Id);

            e.Set();
        }
Exemplo n.º 2
0
        public void Test_DeleteAsync()
        {
            Func <Task> func = async delegate
            {
                using (var scope = new DataAccessScope())
                {
                    var school = this.model.Schools.Create();

                    await scope.FlushAsync();

                    var id = school.Id;

                    var item = await this.model.Schools.FirstOrDefaultAsync(c => c.Id == id);

                    Assert.IsNotNull(item);

                    await this.model.Schools.Where(c => c.Id == id).DeleteAsync();

                    item = await this.model.Schools.FirstOrDefaultAsync(c => c.Id == id);

                    Assert.IsNull(item);

                    await scope.CompleteAsync();
                }
            };

            var task = Task.Run(func);

            task.GetAwaiter().GetResult();
        }