Skip to content

Instantly share code, notes, and snippets.

View chester89's full-sized avatar

Gleb Chermennov chester89

View GitHub Profile
[Test]
public void should_register_type_as_single_implementation()
{
Scan(ac =>
{
ac.AssemblyContainingType<ISingleInterface>();
ac.SingleImplementationsOfInterface();
});
shouldHaveFamily<ISingleInterface>();
@chester89
chester89 / example.html
Created June 30, 2012 16:48 — forked from joelnet/example.html
Unobtrusive Knockout support library for jQuery
Choose a ticket class: <select id="tickets"></select>
<p id="ticketOutput"></p>
<script id="ticketTemplate" type="text/x-jquery-tmpl">
{{if chosenTicket}}
You have chosen <b>${ chosenTicket().name }</b>
($${ chosenTicket().price })
<button data-bind="click: resetTicket">Clear</button>
{{/if}}
@chester89
chester89 / Describing issue 124
Created September 11, 2012 17:21
Fluent NHibernate automapping issue
public class Customer
{
public int Id { get; set; }
public ICollection<Order> Orders { get; set; }
}
public class BigBoss
{
public string FullName { get; set; }
public ICollection<OrderInfo> Orders { get; set; }
@chester89
chester89 / OneToManyFromDerivedFluentMapping
Created October 24, 2012 19:04
One to many from a derived class to other entity generates weird mapping
class Product
{
public int ProductId { get; set; }
}
class SpecialProduct : Product
{
public ICollection<Option> Options { get; set;}
}
@chester89
chester89 / koVirtualBindingHtmlError
Created October 30, 2012 12:16
Being wrong about missing comment tag - Knockout
<tbody data-bind="foreach: competences">
<tr>
<td data-bind="attr: { colspan: $root.scales().length + 2 }">Competence"<b data-bind="text: name"></b>"</td>
<!-- ko foreach: results -->
<tr>
<td><span data-bind="text: indicatorNegativeDisplay"></span></td>
<!-- ko foreach: $root.scales -->
<td>
<label data-bind="text: numericValue"></label>
<input type="radio" name="" data-bind="value: numericValue, checked: $parent.selectedScale"/>
@chester89
chester89 / gist:4990411
Created February 19, 2013 21:49
mapping components using convention in Fluent
public class when_specifying_component_convention
{
Establish context = () =>
{
model = new FluentNHibernate.PersistenceModel();
model.Conventions.Add<ComponentConvention>();
model.Add(new EntityWithComponentMap());
model.Add(new AddressMap());
};
@chester89
chester89 / gist:4995001
Created February 20, 2013 11:53
Moq setup for a method that takes base class parameter
public class when_car_was_stolen: claim_fixture
{
Because of = () =>
{
model.Risk = RiskTypes.Theft;
responsibleGuid = responsibleId;
workitemRepo.Setup(x => x.Add(MockIt.Is<SendEmailWorkItem>(wi => wi.ResponsibleId == responsibleGuid))).Verifiable();
workitemRepo.Setup(x => x.Add(MockIt.Is<WorkItem>(wi => wi.TaskType == (int)TaskTypes.CreateClaim && wi.ResponsibleId == responsibleGuid))).Verifiable();
controller.DamageClaim(model);
};
@chester89
chester89 / FluentMapping.cs
Created March 20, 2013 11:56
Fluent duplicate mapping problem
public class ArticleListMap : SubclassMap<Article>
{
ArticleListMap()
{
DiscriminatorValue(1);
}
}
public class ArticleMap : SubclassMap<Article>
{
ArticleMap()
@chester89
chester89 / gist:5455538
Created April 24, 2013 21:00
Fluent NHibernate mapping to a non-public field
public class TestClass
{
private decimal myField;
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual void SetField(decimal newOne)
{
myField = newOne;
}
@chester89
chester89 / gist:6066142
Created July 23, 2013 21:03
hbm resulting xml from a user type mapping
<joined-subclass name="FluentNHibernate.Testing.FluentInterfaceTests.Image, FluentNHibernate.Testing, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" table="[ImageInfo]">
<key>
<column name="[Guid]" />
</key>
....
<property access="field.camelcase" name="Contexts" type="FluentNHibernate.Testing.FluentInterfaceTests.ImageContextsUserType, FluentNHibernate.Testing, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null">
<column name="IsIcon" not-null="true" />
<column name="IsPromo" not-null="true" />
<column name="IsWallpaper" not-null="true" />
<column name="IsPlaceholder" not-null="true" />