コード例 #1
0
ファイル: OwnedTests.cs プロジェクト: jrjohn/Grace
        public void SimpleDisposableTest()
        {
            Owned<IDisposableService> owned = new Owned<IDisposableService>();
            DisposableService disposableService = new DisposableService();
            bool eventFired = false;

            disposableService.Disposing += (sender, args) => eventFired = true;

            owned.SetValue(disposableService);

            Assert.True(ReferenceEquals(owned.Value, disposableService));

            owned.Dispose();

            Assert.True(eventFired);
        }
コード例 #2
0
ファイル: OwnedTests.cs プロジェクト: jrjohn/Grace
        public void SimpleNonDisposableTest()
        {
            Owned<IBasicService> owned = new Owned<IBasicService>();
            BasicService basicService = new BasicService();

            owned.SetValue(basicService);

            Assert.True(ReferenceEquals(owned.Value, basicService));

            owned.Dispose();
        }