コード例 #1
0
        public void WhenTryToRegisterMultipleTimesTheSameService_ThrowAnException()
        {
            var serviceLocator = new Services.ServiceLocator.ServiceLocator();
            var service        = new TestService1();

            serviceLocator.Register <ITestService>(service);

            Assert.Throws <ArgumentException>(() => serviceLocator.Register <ITestService>(service));
        }
コード例 #2
0
        public void WhenRegisterAServiceAndTryToGetIt_ReturnTheRegisteredService()
        {
            var serviceLocator = new Services.ServiceLocator.ServiceLocator();
            var service        = new TestService1();

            serviceLocator.Register <ITestService>(service);

            Assert.AreEqual(service, serviceLocator.Get <ITestService>());
        }