Esempio n. 1
0
        protected override void beforeEach()
        {
            theEtag = "12345";

            theFiles = new[] { new AssetFile("a"), new AssetFile("b") };

            theAssetPath = new AssetPath("scripts/something")
            {
                ResourceHash = Guid.NewGuid().ToString()
            };

            var writer = new StubContentWriter(theAssetPath, theFiles);

            Services.Inject <IContentWriter>(writer);

            theHeaders = new Header[] {
                new Header("a", "1"),
                new Header("b", "2"),
                new Header("c", "3"),
            };

            MockFor <IAssetCacheHeaders>().Stub(x => x.HeadersFor(theFiles)).Return(theHeaders);

            MockFor <IETagGenerator <IEnumerable <AssetFile> > >()
            .Stub(x => x.Create(theFiles))
            .Return(theEtag);

            FubuMode.Reset();
            FubuMode.InDevelopment().ShouldBeFalse();

            ClassUnderTest.Write(theAssetPath);
        }
Esempio n. 2
0
        public override bool Execute(ModeInput input)
        {
            if (input.ClearFlag)
            {
                FubuMode.Detector.SetMode(string.Empty);
            }

            if (input.DevFlag)
            {
                FubuMode.Detector.SetMode(FubuMode.Development);
            }

            if (input.ModeFlag.IsNotEmpty())
            {
                FubuMode.Detector.SetMode(input.ModeFlag);
            }

            FubuMode.Reset();

            var mode = FubuMode.Mode();

            if (mode.IsEmpty())
            {
                Console.WriteLine("No FubuMode is set");
            }
            else
            {
                Console.WriteLine("FubuMode = '{0}'", FubuMode.Mode());
            }

            return(true);
        }
        public void SetUp()
        {
            FubuMode.Reset();
            verboseGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.AlterSettings <DiagnosticsSettings>(x =>
                {
                    x.TraceLevel = TraceLevel.Verbose;
                });
            });

            productionGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.AlterSettings <DiagnosticsSettings>(x =>
                {
                    x.TraceLevel = TraceLevel.Production;
                });
            });

            noneGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.AlterSettings <DiagnosticsSettings>(x =>
                {
                    x.TraceLevel = TraceLevel.None;
                });
            });
        }
Esempio n. 4
0
        public void DevMode_is_false()
        {
            Environment.SetEnvironmentVariable("FubuMode", "Production", EnvironmentVariableTarget.Machine);
            FubuMode.Reset();
            FubuMode.InDevelopment().ShouldBeFalse();

            FubuMode.Mode().ShouldEqual("Production");
        }
Esempio n. 5
0
        public void DevMode_as_is_is_true()
        {
            Environment.SetEnvironmentVariable("FubuMode", "Development", EnvironmentVariableTarget.Machine);
            FubuMode.Reset();
            FubuMode.InDevelopment().ShouldBeTrue();

            FubuMode.Mode().ShouldEqual("Development");
        }
        public void no_about_endpoint_if_not_in_development_mode()
        {
            FubuMode.Reset();

            var graph = BehaviorGraph.BuildEmptyGraph();

            graph.BehaviorFor <AboutEndpoint>(x => x.get__about())
            .ShouldBeNull();
        }
Esempio n. 7
0
        public Tag_building_in_production_mode()
        {
            FubuMode.Reset();

            File("content/scripts/script1.js");

            File("content/styles/styles1.css");

            File("content/images/image1.bmp");
        }
Esempio n. 8
0
        public void set_to_another_mode()
        {
            theCommand.Execute(new ModeInput {
                ModeFlag = "Something"
            });

            FubuMode.Reset();

            FubuMode.Mode().ShouldEqual("Something");
        }
        public void SetUp()
        {
            FubuMode.Reset();

            var registry = new FubuRegistry();

            registry.Actions.IncludeType <PlacementController>();

            theGraph = BehaviorGraph.BuildFrom(registry);
        }
Esempio n. 10
0
        public void get_the_200_in_normal_mode()
        {
            FubuMode.Reset();

            TestHost.Scenario(_ =>
            {
                _.Get.Url("_fubu");
                _.StatusCodeShouldBeOk();
            });
        }
Esempio n. 11
0
        public void SetUp()
        {
            FubuMode.Reset();

            _runtime  = FubuApplication.For <ApplicationRegistry>().StructureMap().Bootstrap();
            behaviors = _runtime.Factory.Get <BehaviorGraph>();

            appChain = behaviors.BehaviorFor <ApplicationActions>(x => x.get_app_action());
            pakChain = behaviors.BehaviorFor <PackageActions>(x => x.get_pak_action());
        }
Esempio n. 12
0
        public void headers_in_production_mode()
        {
            FubuMode.Reset();

            var settings = new AssetSettings();

            settings.Headers.GetAllKeys()
            .ShouldHaveTheSameElementsAs(HttpRequestHeaders.CacheControl, HttpRequestHeaders.Expires);

            settings.Headers[HttpRequestHeaders.CacheControl]().ShouldEqual("private, max-age=86400");
            settings.Headers[HttpRequestHeaders.Expires]().ShouldNotBeNull();
        }
Esempio n. 13
0
        public void clear_the_mode()
        {
            theCommand.Execute(new ModeInput {
                DevFlag = true
            });

            theCommand.Execute(new ModeInput {
                ClearFlag = true
            });

            FubuMode.Reset();
            FubuMode.Mode().IsEmpty().ShouldBeTrue();
        }
Esempio n. 14
0
        public void override_devmode()
        {
            string isDev = FubuMode.Development;

            FubuMode.Mode(() => isDev);

            FubuMode.InDevelopment().ShouldBeTrue();

            isDev = "something else";

            FubuMode.Reset();
            FubuMode.InDevelopment().ShouldBeFalse();
        }
Esempio n. 15
0
        public void set_to_dev_mode()
        {
            theCommand.Execute(new ModeInput
            {
                ClearFlag = true
            });

            theCommand.Execute(new ModeInput
            {
                DevFlag = true
            });

            FubuMode.Reset();

            FubuMode.InDevelopment().ShouldBeTrue();
        }
Esempio n. 16
0
        protected override void beforeEach()
        {
            theAssetPath = new AssetPath("scripts/something")
            {
                ResourceHash = Guid.NewGuid().ToString()
            };

            MockFor <IContentWriter>().Expect(x => x.Write(theAssetPath, null))
            .Constraints(Is.Equal(theAssetPath), Is.NotNull())
            .Return(false);


            FubuMode.Reset();
            FubuMode.InDevelopment().ShouldBeFalse();

            ClassUnderTest.Write(theAssetPath);
        }
        public void manual_test_the_auto_reloading_tag()
        {
            FubuMode.Mode(FubuMode.Development);

            using (var server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(port: 5601))
            {
                Process.Start("http://localhost:5601/reloaded");
                Thread.Sleep(20000);
            }

            using (var server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(port: 5601))
            {
                Thread.Sleep(20000);
            }

            FubuMode.Reset();
        }
Esempio n. 18
0
        public void SetUp()
        {
            FubuMode.Reset();

            var registry = new FubuRegistry();

            registry.Actions.IncludeType <OrderingPolicyController>();

            registry.Policies.Local.Add(policy => {
                policy.Wrap.WithBehavior <OPWrapper1>();
            });

            registry.Policies.Global.Reorder(policy => {
                policy.ThisWrapperBeBefore <OPWrapper1>();
                policy.CategoryMustBeAfter = BehaviorCategory.Authorization;
            });

            graph = BehaviorGraph.BuildFrom(registry);
        }
Esempio n. 19
0
        public void Receive(StartApplication message)
        {
            Console.WriteLine("Trying to start application " + message);

            if (message.UseProductionMode)
            {
                Console.WriteLine("FubuMode = Production");
                FubuMode.Reset();
            }
            else
            {
                Console.WriteLine("FubuMode = Development");
                FubuMode.Mode(FubuMode.Development);
            }

            var chooser = new ApplicationSourceChooser(_typeFinder, _messaging);

            chooser.Find(message, applicationType => {
                _activator.Initialize(applicationType, message.PortNumber, message.PhysicalPath);
            });
        }
Esempio n. 20
0
        public void SetUp()
        {
            FubuMode.Reset();

            var node = new OutputNode(typeof(Address));

            node.Add(new JsonSerializer());
            node.Add(new XmlFormatter());
            node.Add(new FakeAddressWriter(), new SomeConditional());

            var container = StructureMapContainerFacility.GetBasicFubuContainer();

            container.Configure(x =>
            {
                // Need a stand in value
                x.For <IHttpRequest>().Use(MockRepository.GenerateMock <IHttpRequest>());
            });

            var objectDef = node.As <IContainerModel>().ToObjectDef();
            var instance  = new ObjectDefInstance(objectDef);

            theInputBehavior = container.GetInstance <OutputBehavior <Address> >(instance);
        }
        protected override void beforeEach()
        {
            FubuMode.Reset();

            MockFor <IHttpRequest>().Stub(x => x.RelativeUrl())
            .Return("the relative url");

            MockFor <IHttpRequest>().Stub(x => x.HttpMethod())
            .Return("PUT");

            LocalSystemTime = DateTime.Today.Add(5.Hours());

            theOriginatingChain = new RoutedChain("some/url");
            theOriginatingChain.AddToEnd(new OutputNode(GetType()));
            theOriginatingChain.UniqueId.ShouldNotEqual(Guid.Empty);

            MockFor <ICurrentChain>().Stub(x => x.OriginatingChain).Return(theOriginatingChain);


            theUrls = Services.StubUrls();

            theLog = ClassUnderTest.BuildForCurrentRequest();
        }
Esempio n. 22
0
        public void Receive(StartApplication message)
        {
            Console.WriteLine("Trying to start application " + message);

            PackageRegistry.Properties[HtmlHeadInjectionMiddleware.TEXT_PROPERTY] = message.HtmlHeadInjectedText;

            if (message.UseProductionMode)
            {
                Console.WriteLine("FubuMode = Production");
                FubuMode.Reset();
            }
            else
            {
                Console.WriteLine("FubuMode = Development");
                FubuMode.Mode(FubuMode.Development);
            }

            var chooser = new ApplicationSourceChooser(_typeFinder, _messaging);

            chooser.Find(message, applicationType => {
                _activator.Initialize(applicationType, message.PortNumber, message.PhysicalPath);
            });
        }
Esempio n. 23
0
        public void adds_the_authentication_node_if_it_exists()
        {
            FubuMode.Reset();

            var registry = new FubuRegistry();

            registry.Actions.IncludeType <AuthenticatedEndpoint>();
            registry.Configure(graph => {
                graph.Behaviors.OfType <RoutedChain>().Each(x => x.Authentication = new AuthNode());
            });

            using (var runtime = FubuApplication.For(registry).StructureMap().Bootstrap())
            {
                runtime.Behaviors.BehaviorFor <AuthenticatedEndpoint>(x => x.get_hello())
                .First().ShouldBeOfType <AuthNode>();
            }


            var chain = new RoutedChain("something");
            var auth  = new AuthNode();

            chain.Authentication = auth;
        }
Esempio n. 24
0
 public asset_writing_in_production()
 {
     FubuMode.Reset();
     File("Foo.js").WriteLine("var x = 0;");
 }
Esempio n. 25
0
 public void SetUp()
 {
     FubuMode.Reset();
 }
        protected override void afterRunning()
        {
            new FileSystem().DeleteFile(_file);

            FubuMode.Reset();
        }
 public asset_writing_headers_are_configurable()
 {
     FubuMode.Reset();
     File("Foo.js").WriteLine("var x = 0;");
 }
 public void TearDown()
 {
     FubuMode.Reset();
     server.SafeDispose();
 }
Esempio n. 29
0
 public void TearDown()
 {
     FubuMode.Reset();
 }
 public CoreServiceRegistry_specification()
 {
     FubuMode.Reset();
     _serviceGraph = BehaviorGraph.BuildEmptyGraph().Services;
 }