static HangfireHelperFixture()
        {
            ContainerDummy = new Mock <IContainer>();

            var appBuilderDummy = new AppBuilderFixture();

            GlobalConfiguration.Configuration.UseMemoryStorage();
            GlobalConfiguration.Configuration.UseActivator(new JobActivatorFixture(ContainerDummy.Object));
            appBuilderDummy.UseHangfireServer();
        }
예제 #2
0
        public void RegisterNancyForStartup()
        {
            // arrange
            var fixture         = new OwinStartupFixture();
            var sut             = fixture.Instance;
            var appBuilderDummy = new AppBuilderFixture();

            // act
            sut.Configuration(appBuilderDummy);

            // assert
            appBuilderDummy.MiddleWareRegistrationInvocations.Should().Be(1);
        }
예제 #3
0
        public void DisablingStatelessAuthWorksCorrectly()
        {
            // arrange
            var appBuilderMock    = new AppBuilderFixture();
            var configurationMock = new Mock <IOAuthTokenValidatorConfiguration>();
            var validatorMock     = new Mock <ITokenValidator>();

            // act
            appBuilderMock.UserStatelessOAuthTokenValidation(validatorMock.Object, configurationMock.Object);

            // assert
            appBuilderMock.MiddleWareRegistrationInvocations.Should().Be(0);
        }
        public void UseHangfire()
        {
            // arrange
            var appBuilderDummy = new AppBuilderFixture();
            var configuration   = new Mock <IHangfireConfiguration>();

            configuration.Setup(t => t.Enabled).Returns(true);

            // act
            appBuilderDummy.UseHangfire(configuration.Object);

            // assert
            configuration.Verify(t => t.SetupHangfire(appBuilderDummy), Times.Once);
        }
예제 #5
0
        public void RegisterOAuthValidatorForStartup()
        {
            // arrange
            var fixture         = new OwinStartupFixture();
            var sut             = fixture.Instance;
            var appBuilderDummy = new AppBuilderFixture();

            fixture.OAuthTokenValidatorConfigurationMock
            .Setup(t => t.Enabled)
            .Returns(true);

            // act
            sut.Configuration(appBuilderDummy);

            // assert
            appBuilderDummy.MiddleWareRegistrationInvocations.Should().Be(2);
        }
        public void DisabledHangfireIsNoSetUp()
        {
            // arrange
            ApplicationConfigurationHelper.AdjustKeys(ConfigurationKeys.HangfireEnabled, false.ToString());
            ApplicationConfigurationHelper.AdjustKeys(ConfigurationKeys.HangfireEnableDashboard, false.ToString());
            var activatorDummy = new Mock <JobActivator>();

            var hangfireConfigDummy = new HangfireStorageProviderFixture();

            var appBuilderDummy = new AppBuilderFixture();
            var sut             = new HangfireConfiguration(new List <HangfireStorageConfigurationBase> {
                hangfireConfigDummy
            }, activatorDummy.Object, new List <HangfireJobBase>());

            // act
            sut.SetupHangfire(appBuilderDummy);

            // assert
            hangfireConfigDummy.IsActive.Should().BeFalse();
        }
예제 #7
0
        public void RegisterHangfireForStartup()
        {
            // arrange
            var fixture = new OwinStartupFixture();

            fixture.HangfireConfigurationMock
            .Setup(t => t.Enabled)
            .Returns(true);
            fixture.HangfireConfigurationMock
            .Setup(t => t.EnableDashboard)
            .Returns(false);

            var appBuilderDummy = new AppBuilderFixture();
            var sut             = fixture.Instance;

            // act
            sut.Configuration(appBuilderDummy);

            // assert
            appBuilderDummy.MiddleWareRegistrationInvocations.Should().Be(1);
        }
        public void JobsAreNotConfiguredIfHangfireIsNotUsed()
        {
            // arrange
            ApplicationConfigurationHelper.AdjustKeys(ConfigurationKeys.HangfireEnabled, true.ToString());
            ApplicationConfigurationHelper.AdjustKeys(ConfigurationKeys.HangfireEnableDashboard, false.ToString());
            var activatorDummy = new Mock <JobActivator>();
            var jobDummy       = new JobFixture();

            var hangfireConfigDummy = new HangfireStorageProviderFixture();

            var appBuilderDummy = new AppBuilderFixture();
            var sut             = new HangfireConfiguration(new List <HangfireStorageConfigurationBase> {
                hangfireConfigDummy
            }, activatorDummy.Object, new List <HangfireJobBase> {
                jobDummy
            });

            // act
            sut.SetupHangfire(appBuilderDummy);

            // assert
            jobDummy.WasSetUp.Should().BeTrue();
        }