Created
December 3, 2010 14:27
-
-
Save robashton/727014 to your computer and use it in GitHub Desktop.
This is the test
This file contains 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
[TestFixture] | |
public class WhenCreatedTypeHasBaseTypes | |
{ | |
IGenerationSession mSession; | |
[SetUp] | |
public void Setup() | |
{ | |
mSession = AutoPocoContainer.Configure(x => | |
{ | |
x.Conventions(c => | |
{ | |
c.UseDefaultConventions(); | |
}); | |
x.Include<ISimpleInterface>() | |
.Setup(c => c.InterfaceValue).Value("Interface") | |
.Setup(c=>c.OtherInterfaceValue).Value("Interface"); | |
x.Include<SimpleBaseClass>() | |
.Setup(c => c.BaseProperty).Value("Test") | |
.Setup(c => c.BaseVirtualProperty).Value("Base"); | |
x.Include<SimpleDerivedClass>() | |
.Setup(c => c.Name).Value("OtherTest") | |
.Setup(c => c.BaseVirtualProperty).Value("Derived") | |
.Setup(c => c.OtherInterfaceValue).Value("Derived") | |
.Setup(c => c.Name).Use<FirstNameSource>(); | |
}) | |
.CreateSession(); | |
} | |
[Test] | |
public void DerivedType_HasInterfaceValue() | |
{ | |
SimpleDerivedClass derivedClass = mSession.Single<SimpleDerivedClass>().Get(); | |
Assert.AreEqual("Interface", derivedClass.InterfaceValue); | |
} | |
[Test] | |
public void DerivedType_HasOverrideInterfaceValue() | |
{ | |
SimpleDerivedClass derivedClass = mSession.Single<SimpleDerivedClass>().Get(); | |
Assert.AreEqual("Derived", derivedClass.OtherInterfaceValue); | |
} | |
[Test] | |
public void DerivedType_OverriddenMember_HasDerivedValue() | |
{ | |
SimpleDerivedClass derivedClass = mSession.Single<SimpleDerivedClass>().Get(); | |
Assert.AreEqual("Derived", derivedClass.BaseVirtualProperty); | |
} | |
[Test] | |
public void DerivedType_ContainsBaseValues() | |
{ | |
SimpleDerivedClass derivedClass = mSession.Single<SimpleDerivedClass>().Get(); | |
Assert.AreEqual("Test", derivedClass.BaseProperty); | |
} | |
} |
This file contains 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 static class StandardExtensions | |
{ | |
/// <summary> | |
/// Sets the value of a member directly | |
/// </summary> | |
public static IEngineConfigurationTypeBuilder<TPoco> Value<TPoco, TMember>(this IEngineConfigurationTypeMemberBuilder<TPoco, TMember> memberConfig,TMember value) | |
{ | |
return memberConfig.Use<ValueSource<TMember>>(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment