示例#1
0
        public void ShouldCreateTest()
        {
            using (ResourceManager resourceManager = new ResourceManager())
            {
                Guid? __ = resourceManager.Enter();
                IDisposable disposable;

                disposable = new MockLifecycle();
                resourceManager.Watching(__, disposable);

                disposable = new MockLifecycle();
                //resourceManager.Using(__, disposable);
                using (resourceManager.Using(__, disposable))
                {
                }

                resourceManager.Leave(__);

                resourceManager.Check();
            }
        }
示例#2
0
        public async ValueTask ShouldCreateTestAsync()
        {
            await using (ResourceManager resourceManager = new ResourceManager())
            {
                Guid?__ = await resourceManager.EnterAsync();

                IAsyncDisposable asyncDisposable;

                asyncDisposable = new MockLifecycle();
                await resourceManager.WatchingAsync(__, asyncDisposable);

                asyncDisposable = new MockLifecycle();
                //resourceManager.UsingAsync(__, disposable);
                await using (await resourceManager.UsingAsync(__, asyncDisposable))
                {
                }

                await resourceManager.LeaveAsync(__);

                await resourceManager.CheckAsync();
            }
        }