protected override void beforeEach()
        {
            MockFor <IExecutionQueue>().Expect(x => x.GetAllQueuedTests()).Return(new Test[0]);
            MockFor <IExecutionQueue>().Expect(x => x.IsExecuting()).Return(true);

            ClassUnderTest.Activate(DataMother.ScreenObjectRegistry());
        }
Esempio n. 2
0
        protected override void beforeEach()
        {
            _viewEngine = new SparkViewEngine();
            _settings   = _viewEngine.Settings;

            Services.Inject <ISparkViewEngine>(_viewEngine);
            ClassUnderTest.Activate(Enumerable.Empty <IPackageInfo>(), MockFor <IPackageLog>());
        }
Esempio n. 3
0
        public void calling_activate_registers_all_asset_precompilers_with_the_asset_graph()
        {
            ClassUnderTest.Activate(new IPackageInfo[] { }, _log);

            _assetGraph.Precompile();

            _result.ShouldBeTrue();
        }
Esempio n. 4
0
        public void Returns_element_id_from_naming_convention()
        {
            var elementRequest = new ElementRequest(_accessor);

            ClassUnderTest.Activate(elementRequest);

            elementRequest.ElementId.ShouldEqual("FirstName");
        }
Esempio n. 5
0
        public void everything_is_wonderful_if_there_is_at_least_one_strategy()
        {
            Services.CreateMockArrayFor <IAuthenticationStrategy>(3);

            var packageLog = MockFor <IActivationLog>();

            ClassUnderTest.Activate(packageLog, null);

            packageLog.AssertWasNotCalled(x => x.MarkFailure("text"), x => x.IgnoreArguments());
        }
Esempio n. 6
0
        protected override void beforeEach()
        {
            _config = new TemplateServiceConfiguration();
            _config.Namespaces.Clear();
            var templateService = new FubuTemplateService(new TemplateRegistry <IRazorTemplate>(), new TemplateService(_config), new FileSystem());

            Services.Inject(_config);
            Services.Inject <IFubuTemplateService>(templateService);
            ClassUnderTest.Activate(Enumerable.Empty <IPackageInfo>(), MockFor <IPackageLog>());
        }
        protected override void beforeEach()
        {
            theElementRequest = ElementRequest.For <Address>(new Address(), x => x.Address1);

            MockFor <IElementNamingConvention>().Stub(
                x => x.GetName(theElementRequest.HolderType(), theElementRequest.Accessor))
            .Return("the element name");

            ClassUnderTest.Activate(theElementRequest);
        }
Esempio n. 8
0
        public void does_not_activate_when_in_development_mode()
        {
            var activated = false;

            FubuMode.Mode(FubuMode.Development);
            ClassUnderTest.UseActivation(p => activated = true);
            ClassUnderTest.Activate(MockFor <IEnumerable <IPackageInfo> >(), MockFor <IPackageLog>());

            activated.ShouldBeFalse();
        }
        public void logs_an_error_if_there_are_no_IAuthenticationStrategys_registered()
        {
            Services.CreateMockArrayFor <IAuthenticationStrategy>(0);

            var packageLog = MockFor <IPackageLog>();

            ClassUnderTest.Activate(null, packageLog);

            packageLog.AssertWasCalled(x => x.MarkFailure("There are no IAuthenticationStrategy services registered.  Either register an IAuthenticationStrategy or remove FubuMVC.Authentication from your application"));
        }
Esempio n. 10
0
        public void activates_in_non_development_modes()
        {
            var activated = false;

            FubuMode.Mode("Chuck Norris Mode");
            ClassUnderTest.UseActivation(p => activated = true);
            ClassUnderTest.Activate(MockFor <IEnumerable <IPackageInfo> >(), MockFor <IPackageLog>());

            activated.ShouldBeTrueBecause("Chuck Norris would otherwise switch to RoR or MS MVC");
        }
Esempio n. 11
0
        public void use_the_first_value_of_a_sub_type_if_one_exists()
        {
            var model = new SubclassTestModelForActivation();

            theRequest.Set(model);

            ClassUnderTest.Activate(thePage);

            thePage.AssertWasCalled(x => x.Model = model);
        }
Esempio n. 12
0
        public void use_the_explicit_type_requested_first_if_it_exists()
        {
            var model = new TestModelForActivation();

            theRequest.Set(model);

            ClassUnderTest.Activate(thePage);

            thePage.AssertWasCalled(x => x.Model = model);
        }
Esempio n. 13
0
        protected override void beforeEach()
        {
            _theServices = MockRepository.GenerateMock <IServiceLocator>();

            _theRequest = new InMemoryFubuRequest();
            _theRequest.Set(new SubclassTestModelForActivation());
            _theServices.Stub(x => x.GetInstance <IFubuRequest>()).Return(_theRequest);
            _simpleFubuPage = new SimpleFubuPage <TestModelForActivation>();
            ClassUnderTest.Activate(_theServices, _simpleFubuPage);
        }
Esempio n. 14
0
        public void Returns_existing_element_id()
        {
            var elementRequest = new ElementRequest(_accessor)
            {
                ElementId = "Person[0]FirstName"
            };

            ClassUnderTest.Activate(elementRequest);

            elementRequest.ElementId.ShouldEqual("Person[0]FirstName");
        }
Esempio n. 15
0
        public void does_not_activate_when_setting_is_set_to_false()
        {
            var activated = false;

            theSettings.PrecompileViews = false;

            ClassUnderTest.UseActivation(p => activated = true);
            ClassUnderTest.Activate(MockFor <IEnumerable <IPackageInfo> >(), MockFor <IPackageLog>());

            activated.ShouldBeFalse();
        }
        protected override void beforeEach()
        {
            theGraph = MockRepository.GenerateMock <ChannelGraph>();

            Services.Inject(theGraph);
            Services.PartialMockTheClassUnderTest();

            ClassUnderTest.Stub(x => x.OpenChannels());
            ClassUnderTest.Stub(x => x.ExecuteActivators());

            ClassUnderTest.Activate(new IPackageInfo[0], new PackageLog());
        }
        protected override void beforeEach()
        {
            theContainer = new Container();
            Services.Inject <IContainerFacility>(new StructureMapContainerFacility(theContainer));

            theGraph = new AssetGraph();
            Services.Inject(theGraph);

            theContextIs();

            ClassUnderTest.Activate(new IPackageInfo[0], MockFor <IPackageLog>());
        }
Esempio n. 18
0
        public void calling_activate_invokes_any_registered_asset_precompilers()
        {
            var result = false;

            _assetGraph.OnPrecompile(x =>
            {
                result = true;
            });

            ClassUnderTest.Activate(new IPackageInfo[] { }, _log);
            result.ShouldBeTrue();
        }
Esempio n. 19
0
        protected override void beforeEach()
        {
            theModel = new TestModelForActivation();
            MockFor <IFubuRequest>().Stub(x => x.Has <TestModelForActivation>()).Return(false);
            MockFor <IFubuRequest>().Stub(x => x.Find <TestModelForActivation>()).Return(new TestModelForActivation[0]);
            MockFor <IFubuRequest>().Stub(x => x.Get <TestModelForActivation>()).Return(theModel);

            thePage = MockFor <IFubuPage <TestModelForActivation> >();

            MockFor <IServiceLocator>().Stub(x => x.GetInstance <IFubuRequest>()).Return(MockFor <IFubuRequest>());

            ClassUnderTest.Activate(thePage);
        }
Esempio n. 20
0
        protected override void beforeEach()
        {
            package1 = new StubPackage("1");
            package2 = new StubPackage("2");
            package3 = new StubPackage("3");

            package1.RegisterFolder(FubuMvcPackages.WebContentFolder, "folder1");
            package3.RegisterFolder(FubuMvcPackages.WebContentFolder, "folder3");

            theLog = MockFor <IPackageLog>();

            ClassUnderTest.Activate(new IPackageInfo[] { package1, package2, package3 }, theLog);
        }
        protected override void beforeEach()
        {
            theContainer = new Container(x => {
                x.ForSingletonOf <ICombinationPolicyCache>().Use <CombinationPolicyCache>();
            });

            theGraph = new AssetGraph();
            Services.Inject(theGraph);

            theContextIs();

            ClassUnderTest.Activate(new IPackageInfo[0], MockFor <IPackageLog>());
        }
Esempio n. 22
0
        protected override void beforeEach()
        {
            theGraph = ValidationGraph.BasicGraph();
            Services.Inject(theGraph);

            theTypes = new TypePool();
            theTypes.AddType <RegistrationTargetRules>();

            Services.PartialMockTheClassUnderTest();
            ClassUnderTest.Stub(x => x.Types()).Return(theTypes);

            ClassUnderTest.Activate(new IPackageInfo[0], new PackageLog());
        }
Esempio n. 23
0
        protected override void beforeEach()
        {
            suite = new Suite("the suite");
            test  = new Test("test 1");
            suite.AddTest(test);

            Services.Inject(suite);

            driver = MockRepository.GenerateMock <ITestLineDriver>();
            MockFor <ISuiteView>().Expect(x => x.AddTest(test, null)).Constraints(Is.Equal(test), Is.Anything()).Return(
                driver);

            ClassUnderTest.Activate(null);
        }
        protected override void beforeEach()
        {
            _viewEngine = new SparkViewEngine();
            _settings   = _viewEngine.Settings;

            var commonViewNamespaces = new CommonViewNamespaces();

            commonViewNamespaces.Add("Foo");
            commonViewNamespaces.Add("Bar");

            Services.Inject(commonViewNamespaces);

            Services.Inject <ISparkViewEngine>(_viewEngine);
            ClassUnderTest.Activate(Enumerable.Empty <IPackageInfo>(), MockFor <IPackageLog>());
        }
        protected override void beforeEach()
        {
            Test[] tests = DataMother.TestArray(3);
            items = new[] { new object(), new object(), new object() };

            for (int i = 0; i < items.Length; i++)
            {
                MockFor <IQueuedItemFactory>().Expect(x => x.Build(tests[i])).Return(items[i]);
            }

            MockFor <IExecutionQueue>().Expect(x => x.GetAllQueuedTests()).Return(tests);
            MockFor <IExecutionQueue>().Expect(x => x.IsEmpty()).Return(false);

            ClassUnderTest.Activate(DataMother.ScreenObjectRegistry());
        }
Esempio n. 26
0
        protected override void beforeEach()
        {
            thePackages = new IPackageInfo[] {
                new ContentOnlyPackageInfo("dir1", "Dir1"),
                new ContentOnlyPackageInfo("dir2", "Dir2"),
                new ContentOnlyPackageInfo("dir3", "Dir3"),
            };

            theFacility = new StubContainerFacility();
            Services.Inject <IContainerFacility>(theFacility);

            var spinup = Services.Container.GetInstance <SpinUpLocalizationCaches>();

            theFacility.Container.Inject(spinup);

            ClassUnderTest.Activate(thePackages, new PackageLog());
        }
        protected override void beforeEach()
        {
            theGraph = new AssetGraph();
            Services.Inject(theGraph);

            theCache = new AssetCombinationCache();
            Services.Inject <IAssetCombinationCache>(theCache);

            Services.Inject <IAssetFileGraph>(new StubAssetFileGraph());

            theGraph.AddToCombination("combo1", "a.js");
            theGraph.AddToCombination("combo1", "b.js");
            theGraph.AddToCombination("combo1", "c.js");

            theGraph.AddToCombination("combo2", "a.js");
            theGraph.AddToCombination("combo2", "b.js");

            ClassUnderTest.Activate(new IPackageInfo[0], MockFor <IPackageLog>());
        }
        protected override void beforeEach()
        {
            theLog = MockFor <IActivationLog>();

            theJobs = Services.CreateMockArrayFor <IPollingJob>(5);
            foreach (var pollingJob in theJobs)
            {
                pollingJob.Stub(_ => _.JobType).Return(typeof(AJob));
            }

            Services.Inject <IPollingJobs>(new PollingJobs(theJobs));

            ex1 = new NotImplementedException();
            ex2 = new NotSupportedException();

            theJobs[1].Expect(x => x.Start()).Throw(ex1);
            theJobs[2].Expect(x => x.Start()).Throw(ex2);

            ClassUnderTest.Activate(theLog, null);
        }
Esempio n. 29
0
        protected override void beforeEach()
        {
            suite = StoryTeller.Testing.DataMother.BuildHierarchy(@"
t1,Success
t2,Success
t3,Success
");


            test1 = suite.FindTest("t1");
            test2 = suite.FindTest("t2");
            test3 = suite.FindTest("t3");

            Services.Inject(suite);

            driver1 = MockRepository.GenerateMock <ITestLineDriver>();
            driver2 = MockRepository.GenerateMock <ITestLineDriver>();
            driver3 = MockRepository.GenerateMock <ITestLineDriver>();


            MockFor <ISuiteView>().Expect(x => x.AddTest(null, null)).Constraints(Is.Equal(test1), Is.Anything()).Return(
                driver1);
            MockFor <ISuiteView>().Expect(x => x.AddTest(null, null)).Constraints(Is.Equal(test2), Is.Anything()).Return(
                driver2);
            MockFor <ISuiteView>().Expect(x => x.AddTest(null, null)).Constraints(Is.Equal(test3), Is.Anything()).Return(
                driver3);

            MockFor <ITestService>().Expect(x => x.GetStatus(test1)).Return(TestState.Queued);
            MockFor <ITestExplorer>().Expect(x => x.IconFor(test1)).Return(Icon.Pending);

            MockFor <ITestService>().Expect(x => x.GetStatus(test2)).Return(TestState.NotQueued);
            MockFor <ITestExplorer>().Expect(x => x.IconFor(test2)).Return(Icon.Success);

            MockFor <ITestService>().Expect(x => x.GetStatus(test3)).Return(TestState.NotQueued);
            MockFor <ITestExplorer>().Expect(x => x.IconFor(test3)).Return(Icon.Failed);

            ClassUnderTest.Activate(null);
        }
Esempio n. 30
0
 public void activate_happy_path()
 {
     ClassUnderTest.Activate().Wait();
     MockFor <IPersistentTask>().AssertWasCalled(x => x.Activate());
 }