Ejemplo n.º 1
0
        public void GetKeys_Typed_Enum()
        {
            // Arrange
            IKeyedServiceRegister register = GetRegistrar();

            // Act
            var types = register.GetKeys <IMyService, AvailableServices>().ToList();

            // Assert
            Assert.That(types, Has.Count.EqualTo(2));
            Assert.That(types, Contains.Item(AvailableServices.Service1));
            Assert.That(types, Contains.Item(AvailableServices.Service2));
        }
Ejemplo n.º 2
0
        public void GetKeys_Typed_String()
        {
            // Arrange
            IKeyedServiceRegister register = GetRegistrar();

            // Act
            var types = register.GetKeys <IMyService, string>().ToList();

            // Assert
            Assert.That(types, Has.Count.EqualTo(2));
            Assert.That(types, Contains.Item("Service1"));
            Assert.That(types, Contains.Item("Service2"));
        }
 public static IEnumerable <TKey> GetKeys <TInterface, TKey>(this IKeyedServiceRegister register)
 {
     return(register.GetKeys(typeof(TInterface)).OfType <TKey>());
 }
 public static IEnumerable <object> GetKeys <TInterface>(this IKeyedServiceRegister register)
 {
     return(register.GetKeys(typeof(TInterface)));
 }