This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this will cause module A to resolve its own dependencies | |
| var a = require('A')(); | |
| console.log(a.action()); | |
| // or for testing we can provide the dependencies | |
| var aTest = require('A')({ | |
| foo: function() { return 'foo'; } | |
| }, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // does not work | |
| var service = Substitute.For<IService>(); | |
| service.Method(Arg.Any<DerivedType>()).Returns(1); | |
| service.Method(Arg.Any<AnotherDerivedType>()).Returns(2); | |
| // works | |
| var service = Substitute.For<IService>(); | |
| service.Method(Arg.Is<BaseType>(a => a is DerivedType)).Returns(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Render a partial once for each item in a collection | |
| /// </summary> | |
| public static void RenderCollection(this HtmlHelper html, string partial, IEnumerable collection) | |
| { | |
| foreach (var thing in collection) | |
| html.RenderPartial(partial, thing); | |
| } | |
| // usage: @{Html.RenderCollection("_MyPartial", Model.SomeCollection);} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public ActionResult ViewMap<TSource, TTarget>(TSource model, Action<TTarget> after) | |
| { | |
| if (model == null) return HttpNotFound(); | |
| TTarget mapped = Mapper.FindTypeMapFor<TSource, TTarget>() != null | |
| ? Mapper.Map<TSource, TTarget>(model) | |
| : Mapper.DynamicMap<TSource, TTarget>(model); | |
| after(mapped); | |
| return View(mapped); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public ActionResult Show(Infrastructure infrastructure) | |
| { | |
| return ViewMap<Infrastructure, ShowInfrastructureModel>(infrastructure); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var months = CultureInfo.CurrentUICulture.DateTimeFormat.MonthNames.Take(12); | |
| return months.Aggregate(new List<SelectListItem>(), (accumulator, month) => | |
| { | |
| accumulator.Add(new SelectListItem{ Value = (accumulator.Count + 1).ToString(), Text = month }); | |
| return accumulator; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var stream = new MemoryStream()) | |
| using (var textWriter = new StreamWriter(stream)) | |
| using (var writer = new CsvWriter(textWriter)) | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyThingMapper : EntityDtoMapper<Thing, ThingViewModel> | |
| { | |
| public MyThingMapper(IThingService service) : base(MappingDirections.Both) | |
| { | |
| ... | |
| } | |
| protected override TEntity MapToEntity(TDto source, TEntity destination) | |
| { | |
| DoMapToEntity(source, destination); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Home = | |
| Router: Backbone.Router.extend | |
| routes: | |
| '': 'home' | |
| home: -> | |
| new Home.Views.Start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe 'home', -> | |
| describe 'load', -> | |
| before -> | |
| App.TestHelper.reset() | |
| it 'should render the home view', -> | |
| new App.Modules.Home.Views.Start() | |
| expect($('.btn:contains(Create a list)').length).to.be(1) |