Esempio n. 1
0
        public void ExpectInstance <TService, TExpectedType>()
        {
            ServiceMatch match = ServiceMatch.CreateMatch <TService>();

            AddNewMatch <TService>(match);
            match.AddInstance <TExpectedType>();
        }
Esempio n. 2
0
        public ExpectedCollectionBuilder ExpectSubcollection <TService>()
        {
            ServiceMatch match = ServiceMatch.CreateSubcollectionMatch <TService>();

            AddNewMatch <TService>(match);
            return(new ExpectedCollectionBuilder(match));
        }
Esempio n. 3
0
        public void ExpectFactory <TService, TPeerType>(ServiceLifetime lifetime = ServiceLifetime.Singleton)
        {
            ServiceMatch match = ServiceMatch.CreateMatch <TService>();

            AddNewMatch <TService>(match);
            match.AddFactory <TPeerType>(lifetime);
        }
Esempio n. 4
0
        public void Expect <TService, TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Singleton)
        {
            ServiceMatch match = ServiceMatch.CreateMatch <TService>();

            AddNewMatch <TService>(match);
            match.Add <TImplementation>(lifetime);
        }
Esempio n. 5
0
 private void AddNewMatch <T>(ServiceMatch match)
 {
     if (!_serviceMatches.TryAdd(typeof(T), match))
     {
         throw new InvalidOperationException($"Type {typeof(T)} has already been registered as expected.");
     }
 }
Esempio n. 6
0
        public void Expect <TService, TPeerType>(string typeName, ServiceLifetime lifetime = ServiceLifetime.Singleton)
        {
            ArgumentNullException.ThrowIfNull(typeName);

            ServiceMatch match = ServiceMatch.CreateMatch <TService>();

            AddNewMatch <TService>(match);
            match.Add <TPeerType>(typeName, lifetime);
        }
        public void Expect <TService, TPeerType>(string typeName, ServiceLifetime lifetime = ServiceLifetime.Singleton)
        {
            if (typeName == null)
            {
                throw new ArgumentNullException(nameof(typeName));
            }

            ServiceMatch match = ServiceMatch.CreateMatch <TService>();

            AddNewMatch <TService>(match);
            match.Add <TPeerType>(typeName, lifetime);
        }
Esempio n. 8
0
        public void ExpectNone <TService>()
        {
            ServiceMatch match = ServiceMatch.CreateNoneMatch <TService>();

            AddNewMatch <TService>(match);
        }
 public ExpectedCollectionBuilder(ServiceMatch match)
 {
     _match = match;
 }