コード例 #1
0
        public void Should_not_register_entity_types_in_application_container_when_initializing_bootstrapper()
        {
            // Given
            var rootPathProvider = Mock.Of <IRootPathProvider>();

            var bootstrapper = new CommuterBootstrapper(rootPathProvider);

            // When
            bootstrapper.Initialise();

            // Then
            var applicationContainer = bootstrapper.GetApplicationContainer();

            Assert.Throws <TinyIoCResolutionException>(() => applicationContainer.Resolve <ITrainRoute>());
        }
コード例 #2
0
        public void Should_have_precedence_for_JSON_serialization_with_ServiceStackSerializer_when_initializing_bootstrapper()
        {
            // Given
            var rootPathProvider = Mock.Of <IRootPathProvider>();

            var bootstrapper = new CommuterBootstrapper(rootPathProvider);

            // When
            var serializers = bootstrapper.InternalConfiguration.Serializers.Select(s => s.UnderlyingSystemType).ToList();
            var indexOfServiceStackJsonSerializer = serializers.FindIndex(0, s => s.UnderlyingSystemType == typeof(ServiceStackJsonSerializer));
            var indexOfDefaultJsonSerializer      = serializers.FindIndex(0, s => s.UnderlyingSystemType == typeof(DefaultJsonSerializer));

            // Then
            Assert.True(serializers.Count(s => s.UnderlyingSystemType == typeof(ServiceStackJsonSerializer)) > 0);
            Assert.True(indexOfServiceStackJsonSerializer < indexOfDefaultJsonSerializer);
        }
コード例 #3
0
        public void Should_use_custom_root_path_provider_when_when_initializing_bootstrapper()
        {
            var expectedHaveBeenCalled = false;
            // Given
            var rootPathProvider = new Mock <CommuterRootPathProvider>();

            rootPathProvider.Setup(r => r.GetRootPath()).Callback(() => { expectedHaveBeenCalled = true; });

            var bootstrapper = new CommuterBootstrapper(rootPathProvider.Object);

            // When
            bootstrapper.Initialise();

            // Then
            Assert.True(expectedHaveBeenCalled);
        }
コード例 #4
0
        public void Should_have_bundled_static_content_when_initializing_bootstrapper()
        {
            var expectedHaveBeenCalled = false;

            // Given
            var contentBundler = new Mock <IStaticContentBundler>();
            var staticContentsConventionsAppender = Mock.Of <IStaticContentsConventionsAppender>();

            contentBundler.Setup(b => b.Bundle()).Callback(() =>
                                                           { expectedHaveBeenCalled = true; });
            var rootPathProvider = Mock.Of <IRootPathProvider>();

            var bootstrapper = new CommuterBootstrapper(rootPathProvider, contentBundler.Object, staticContentsConventionsAppender);

            // When
            bootstrapper.Initialise();

            // Then
            Assert.True(expectedHaveBeenCalled);
        }
コード例 #5
0
        public void Should_have_registrered_paths_for_static_content_when_initializing_bootstrapper()
        {
            var expectedHaveBeenCalled = false;

            // Given
            var contentBundler = Mock.Of <IStaticContentBundler>();
            var staticContentsConventionsAppender = new Mock <IStaticContentsConventionsAppender>(MockBehavior.Default);

            staticContentsConventionsAppender.Setup(a => a.AddPaths(It.IsAny <NancyConventions>())).Callback(() =>
                                                                                                             { expectedHaveBeenCalled = true; });
            var rootPathProvider = Mock.Of <IRootPathProvider>();

            var bootstrapper = new CommuterBootstrapper(rootPathProvider, contentBundler, staticContentsConventionsAppender.Object);

            // When
            bootstrapper.Initialise();

            // Then
            Assert.True(expectedHaveBeenCalled);
        }