コード例 #1
0
        public void ServicesRegisteredByInstanceFromServiceCollectionShouldBeUntracked()
        {
            var svc = new DisposableService();

            var services = new Registry();

            services.AddSingleton(svc);

            using (var container = services.CreateContainer()) {
                var svc2 = container.GetService <DisposableService>();
                Assert.Same(svc, svc2);
            }

            Assert.False(svc.Disposed);
        }
コード例 #2
0
ファイル: MobileUnitTest.cs プロジェクト: cwaldron/CafeLib
        /// <summary>
        /// Setup test.
        /// </summary>
        protected virtual void SetupTest()
        {
            // fake set up of the IoC
            SetupRegistry();

            // Setup for all tests.
            AlertService      = new Mock <IAlertService>();
            NavigationService = new Mock <INavigationService>();
            PageService       = new Mock <IPageService>();

            Registry
            .AddSingleton <IDeviceService, FakeDeviceService>()
            .AddSingleton(x => AlertService.Object)
            .AddSingleton(x => NavigationService.Object)
            .AddSingleton(x => PageService.Object);
        }