Пример #1
0
        public void Dispose_ShouldDisposeInternalServiceProvider()
        {
            void OnConfiguring(EventsContextOptions x)
            {
            }

            void OnBuildingPipelines(IPipelinesBuilder x)
            {
            }

            void OnBuildingSubscriptions(SubscriptionsBuilder x)
            {
            }

            var internalEventsContext = new InternalEventsContext(
                _options,
                OnConfiguring,
                OnBuildingPipelines,
                OnBuildingSubscriptions,
                _appServiceProviderMock.Object,
                _eventsContextMock.Object
                );

            internalEventsContext.Dispose();

            Assert.That(() =>
            {
                internalEventsContext.InternalServiceProvider.GetService(typeof(object));
            }, Throws.TypeOf <ObjectDisposedException>());
        }
Пример #2
0
        public void Ctor_ShouldCallActionsAndCreateInternalServiceProvider()
        {
            var isOnConfiguringInvoked           = false;
            var isOnBuildingPipelinesInvoked     = false;
            var isOnBuildingSubscriptionsInvoked = false;

            void OnConfiguring(EventsContextOptions x) => isOnConfiguringInvoked = true;

            void OnBuildingPipelines(IPipelinesBuilder x) => isOnBuildingPipelinesInvoked = true;

            void OnBuildingSubscriptions(SubscriptionsBuilder x) => isOnBuildingSubscriptionsInvoked = true;

            var internalEventsContext = new InternalEventsContext(
                _options,
                OnConfiguring,
                OnBuildingPipelines,
                OnBuildingSubscriptions,
                _appServiceProviderMock.Object,
                _eventsContextMock.Object
                );

            Assert.That(isOnConfiguringInvoked, Is.True);
            Assert.That(isOnBuildingPipelinesInvoked, Is.True);
            Assert.That(isOnBuildingSubscriptionsInvoked, Is.True);

            Assert.That(
                internalEventsContext,
                Has.Property(nameof(internalEventsContext.InternalServiceProvider)).Not.Null
                );
        }