예제 #1
0
			public void ThisDoesnt()
			{
				IFoo mockFoo = MockRepository.Mock<IFoo>();

				int junk = 3;
                mockFoo.Expect(x => x.foo(ref Arg<int>.Ref(junk).Dummy))
                    .IgnoreArguments()
                    .Repeat.Once()
                    .Return(true);

                ClassUnderTest cut = new ClassUnderTest();
                Assert.Equal(3, cut.doit(mockFoo));
			}
        public void SampleTest()
        {
            var client = Substitute.For<IClient>();
            var log = Substitute.For<ILog>();
            var target = new ClassUnderTest(client, log);
            const string errorResponse = "some issue";
            dynamic postResponse = new { error = errorResponse };
            client.Post("", "").ReturnsForAnyArgs(postResponse);

            // Act
            target.Handle("test");

            // Assert
            log.Received().Error(Arg.Is<Exception>(x => x.Message == errorResponse));
        }
예제 #3
0
 public void h_uses_servicelocator_to_get_htmlencoder()
 {
     _serviceLocator.Expect(x => x.GetInstance(typeof(IHtmlEncoder))).Return(new DefaultHtmlEncoder());
     ClassUnderTest.H("<div>").ShouldEqual("&lt;div&gt;");
     _serviceLocator.VerifyAllExpectations();
 }
 public void sets_the_nested_output_writer_as_the_view_output()
 {
     _view.Output = new StringWriter();
     ClassUnderTest.Modify(_view);
     _nestedOutput.Writer.ShouldBeTheSameAs(_view.Output);
 }
 List<object> GetArgumentValues(Expression<Action<ClassUnderTest>> action, ClassUnderTest instance)
 {
     return action.ExtractArguments(instance).Select(o => o.Value).ToList();
 }
예제 #6
0
        public void run_now_successfully()
        {
            ClassUnderTest.RunNow();

            MockFor <IServiceBus>().AssertWasCalled(x => x.Consume(new JobRequest <APollingJob>()), x => x.IgnoreArguments());
        }
예제 #7
0
 public void should_not_continue_loading()
 {
     ClassUnderTest.AssertWasNotCalled(x => x.LoadFilesFromContentFolder(null, null), x => x.IgnoreArguments());
 }
예제 #8
0
 public void When_generate_test_six()
 {
     Assert.That(ClassUnderTest.Generate(6), Is.EquivalentTo(BuildList(2, 3)));
 }
예제 #9
0
 public void When_generate_test_nine()
 {
     Assert.That(ClassUnderTest.Generate(9), Is.EquivalentTo(BuildList(3, 3)));
 }
예제 #10
0
 public void it_does_not_bind_generic_viewmodels()
 {
     _parsing.ViewModelType = "System.Collections.List<System.String>";
     ClassUnderTest.CanBind(_request).ShouldBeFalse();
 }
 List <StepArgument> GetArguments(Expression <Action <ClassUnderTest> > action, ClassUnderTest instance)
 {
     return(action.ExtractArguments(instance).ToList());
 }
 public void the_shared_path_builder_is_given_proper_args_when_reachables_of()
 {
     created_builder(true);
     ClassUnderTest.ReachablesOf(_template);
     MockFor <ISharedPathBuilder>().VerifyAllExpectations();
 }
예제 #13
0
 public void tag()
 {
     ClassUnderTest.Tag("div").ShouldNotBeNull().TagName().ShouldEqual("div");
 }
 public void the_shared_path_builder_is_given_proper_args_when_sharedpaths_of()
 {
     ClassUnderTest.SharedPathsOf(_template);
     MockFor <ISharedPathBuilder>().VerifyAllExpectations();
 }
 public void when_no_sharing_exists_only_local_paths_are_returned()
 {
     ClassUnderTest.SharedPathsOf(_template).SequenceEqual(_paths).ShouldBeTrue();
 }
 public void invokes_render_on_injected_render_action()
 {
     ClassUnderTest.Invoke(_renderAction);
     _renderAction.VerifyAllExpectations();
 }
 public void if_nested_output_is_active_applies_returns_true_otherwise_false()
 {
     ClassUnderTest.Applies().ShouldBeFalse();
     _nestedOutput.SetWriter(() => _writer);
     ClassUnderTest.Applies().ShouldBeTrue();
 }
예제 #18
0
 public void ShouldCallSearchWithException()
 {
     ClassUnderTest.Search(new SearchQuery <Movie>());
     ClassUnderTest.AssertWasCalled(x => x.SearchWithException(null), x => x.IgnoreArguments());
 }
 List <object> GetArgumentValues(Expression <Action <ClassUnderTest> > action, ClassUnderTest instance)
 {
     return(action.ExtractArguments(instance).Select(o => o.Value).ToList());
 }
예제 #20
0
 public void site_resource()
 {
     ClassUnderTest.SiteResource = x => "App/{0}".ToFormat(x);
     ClassUnderTest.SiteResource("Views/Home/Home.spark").ShouldEqual("App/Views/Home/Home.spark");
 }
예제 #21
0
 public void does_not_blow_up_on_null_messages()
 {
     ClassUnderTest.Publish(null);
 }
예제 #22
0
        public void locate_master_returns_template_that_match_first_shared_directory_and_name()
        {
            var master = ClassUnderTest.LocateMaster("application", _template, _masterTemplateRegistry);

            master.ShouldNotBeNull().ShouldEqual(_masterTemplateRegistry[2]);
        }
예제 #23
0
 public void When_generate_test_eight()
 {
     Assert.That(ClassUnderTest.Generate(8), Is.EquivalentTo(BuildList(2, 2, 2)));
 }
예제 #24
0
        public void if_not_exists_locate_master_returns_null()
        {
            var master = ClassUnderTest.LocateMaster("admin", _template, _masterTemplateRegistry);

            master.ShouldBeNull();
        }
예제 #25
0
 public void When_generate_test_25()
 {
     Assert.That(ClassUnderTest.Generate(25), Is.EquivalentTo(BuildList(5, 5)));
 }
예제 #26
0
        public void if_not_exists_locate_bindings_returns_empty_list()
        {
            var bindings = ClassUnderTest.LocateBindings("sparkbindings", _template, _bindingTemplateRegistry);

            bindings.ShouldNotBeNull().ShouldHaveCount(0);
        }
예제 #27
0
 public void should_continue_to_scan_for_files()
 {
     ClassUnderTest.AssertWasCalled(x => x.LoadFilesFromContentFolder(thePackageDirectory, theContentFolder));
 }
 object[] GetArguments(Expression<Action<ClassUnderTest>> action, ClassUnderTest instance)
 {
     return action.ExtractArguments(instance).Select(o => o.Value).ToArray();
 }
 public void applies_if_nestedoutput_is_not_active()
 {
     ClassUnderTest.Applies(_view).ShouldBeTrue();
     _nestedOutput.SetWriter(() => new StringWriter());
     ClassUnderTest.Applies(_view).ShouldBeFalse();
 }
예제 #30
0
 public void binders_that_match_are_applied_against_each_spark_item()
 {
     ClassUnderTest.Compose(_templateRegistry);
     _binder1Templates.ShouldHaveCount(1).ShouldContain(_template1);
     _binder2Templates.ShouldHaveCount(1).ShouldContain(_template2);
 }
예제 #31
0
 public void applies_to_positive_based_on_mimetype_1()
 {
     ClassUnderTest.AppliesTo(new AssetFile("a.sass")).ShouldBeTrue();
 }
        public void activate_simply_starts_the_asset_file_watcher_going()
        {
            ClassUnderTest.Activate(new IPackageInfo[0], new PackageLog());

            MockFor <IAssetFileWatcher>().AssertWasCalled(x => x.StartWatchingAll());
        }
 List<StepArgument> GetArguments(Expression<Action<ClassUnderTest>> action, ClassUnderTest instance)
 {
     return action.ExtractArguments(instance).ToList();
 }
예제 #34
0
 public void should_allow_the_exception_to_bubble_up_wrapped_in_unhandled_exception()
 {
     Exception <NotImplementedException> .ShouldBeThrownBy(() => ClassUnderTest.InvokePartial())
     .ShouldBeTheSameAs(exception);
 }
예제 #35
0
 public void ThisDoesnt()
 {
     MockRepository mockery = new MockRepository();
     IFoo mockFoo = mockery.StrictMock<IFoo>();
     int junk = 3;
     using (mockery.Record())
     {
         Expect.Call(mockFoo.foo(ref junk)).
             IgnoreArguments().
             OutRef(3).
             Constraints(Is.Anything()).
             Repeat.Once().
             Return(true);
     }
     using (mockery.Playback())
     {
         ClassUnderTest cut = new ClassUnderTest();
         Assert.AreEqual(3, cut.doit(mockFoo), "should work.");
     }
 }
 public void render_partial_uses_partial_view_from_factory_and_calls_to_render_method()
 {
     _viewFactory.Stub(x => x.GetPartialView()).Return(_view);
     ClassUnderTest.RenderPartial();
     _view.VerifyAllExpectations();
 }