Пример #1
0
        public void Ctor_ShouldSuccessfullyInitialize_When_ActivatorAndContextAreValid()
        {
            StubSpiffyable spiffyableObject = TestHelper.Helper.GetPropertyValueFromInstance <StubSpiffyable>(
                "SpiffyableObject", true, false, subject);

            ISpiffyContext <StubSpiffyable> spiffyContext = TestHelper.Helper.GetPropertyValueFromInstance <ISpiffyContext <StubSpiffyable> >(
                "SpiffyContext", false, false, subject);

            Assert.Same(mockSpiffyable.Object, spiffyableObject);
            Assert.Same(mockSpiffyWorkerPool.Object, spiffyContext);
        }
Пример #2
0
        protected private BaseSpiffyWorker(Func <T> activator, ISpiffyContext <T> spiffyContext)
        {
            if (activator is null)
            {
                throw new ArgumentNullException(nameof(activator), "A spiffy worker requires an activator.");
            }

            if (spiffyContext is null)
            {
                throw new ArgumentNullException(nameof(spiffyContext), "A spiffy worker requires a spiffy context.");
            }

            SpiffyableObject = activator();
            if (SpiffyableObject is null)
            {
                throw new NullReferenceException("Unable to construct a spiffyable object using the provided activation function.");
            }

            SpiffyContext = spiffyContext;
            AssignNewWorkerId();
        }
Пример #3
0
 internal GenericSpiffyWorker(Func <T> activator, ISpiffyContext <T> spiffyContext, SpiffyLifetime lifetime)
     : base(activator, spiffyContext)
 {
     Lifetime = lifetime;
 }