本文整理汇总了C#中NUnit.Framework.TestContext.Db方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.Db方法的具体用法?C# TestContext.Db怎么用?C# TestContext.Db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.TestContext
的用法示例。
在下文中一共展示了TestContext.Db方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contract_Contract
public void Contract_Contract()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Contract>();
var columns = map.Properties;
Assert.AreEqual(19, columns.Length);
map.Prop(x => x.Id)
.IsIdentity()
.IsFk(false)
.IsDiscriminator(false)
.IsRequired()
.HasColumnName("Id");
map.Prop(x => x.AvpContractNr)
.IsIdentity(false)
.IsFk(false)
.IsDiscriminator(false)
.IsRequired(false)
.HasColumnName("AvpContractNr")
.MaxLength(50);
}
}
示例2: Contract_ContractFixed
public void Contract_ContractFixed()
{
using (var ctx = new TestContext())
{
var tableMapping = ctx.Db<ContractFixed>();
var columns = tableMapping.Properties;
Assert.AreEqual(21, columns.Length);
}
}
示例3: Contract_ContractBase
public void Contract_ContractBase()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<ContractBase>();
var columns = map.Properties;
Assert.AreEqual(19, columns.Length);
Assert.AreEqual(1, map.Discriminators.Length);
}
}
示例4: Entity_ComplextType_WhereComplexTypeIsLastProperty
public void Entity_ComplextType_WhereComplexTypeIsLastProperty()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<House>();
map.Prop(x => x.Name)
.HasColumnName("Name");
map.Prop(x => x.Address.City)
.HasColumnName("Address_City");
}
}
示例5: Contract_ContractKomb1
public void Contract_ContractKomb1()
{
using (var ctx = new TestContext())
{
var tableMapping = ctx.Db<ContractKomb1>();
var columns = tableMapping.Properties;
Assert.AreEqual(24, columns.Length);
tableMapping.Prop(x => x.Base)
.HasColumnName("Base")
.HasPrecision(18)
.HasScale(4);
}
}
示例6: Entity_ComplexType
public void Entity_ComplexType()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<TestUser>();
map.Prop(x => x.Id)
.HasColumnName("Id")
.IsPk()
.IsFk(false)
.IsNavigationProperty(false);
map.Prop(x => x.FirstName)
.HasColumnName("Name")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.LastName)
.HasColumnName("LastName")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.PhoneNumber)
.HasColumnName("Contact_PhoneNumber")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.Address.Country)
.HasColumnName("Contact_Address_Country")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.Address.County)
.HasColumnName("Contact_Address_County")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.Address.City)
.HasColumnName("Contact_Address_City")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.Address.PostalCode)
.HasColumnName("Contact_Address_PostalCode")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.Address.StreetAddress)
.HasColumnName("Contact_Address_StreetAddress")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
#if !NET40
var propertyPropertyMap = map.Prop(x => x.Contact.Address.Location);
propertyPropertyMap
.HasColumnName("Contact_Address_Location")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false);
Console.WriteLine(propertyPropertyMap.DefaultValue);
Console.WriteLine(propertyPropertyMap.FixedLength);
Console.WriteLine(propertyPropertyMap.MaxLength);
Console.WriteLine(propertyPropertyMap.Precision);
Console.WriteLine(propertyPropertyMap.Scale);
Console.WriteLine(propertyPropertyMap.Type);
Console.WriteLine(propertyPropertyMap.Unicode);
var shapePropertyMap = map.Prop(x => x.Contact.Address.Shape);
shapePropertyMap
.HasColumnName("Contact_Address_Shape")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false);
Console.WriteLine(shapePropertyMap.DefaultValue);
Console.WriteLine(shapePropertyMap.FixedLength);
Console.WriteLine(shapePropertyMap.MaxLength);
Console.WriteLine(shapePropertyMap.Precision);
Console.WriteLine(shapePropertyMap.Scale);
Console.WriteLine(shapePropertyMap.Type);
Console.WriteLine(shapePropertyMap.Unicode);
#endif
}
}
示例7: Entity_Simple
public void Entity_Simple()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Page>();
Console.WriteLine("{0}:{1}", map.Type, map.TableName);
map.Prop(x => x.PageId)
.HasColumnName("PageId")
.IsPk()
.IsFk(false)
.IsIdentity()
.IsNavigationProperty(false);
map.Prop(x => x.Title)
.HasColumnName("Title")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired()
.IsNavigationProperty(false)
.MaxLength(255);
map.Prop(x => x.Content)
.HasColumnName("Content")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.ParentId)
.HasColumnName("ParentId")
.IsPk(false)
.IsFk()
.IsIdentity(false)
.IsRequired(false)
.IsNavigationProperty(false)
.NavigationPropertyName("Parent");
Assert.AreEqual(map.Prop(x => x.PageId), map.Prop(x => x.ParentId).FkTargetColumn);
map.Prop(x => x.Parent)
.HasColumnName("ParentId")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsNavigationProperty()
.ForeignKeyPropertyName("ParentId")
.ForeignKey(map.Prop(x => x.ParentId));
map.Prop(x => x.CreatedAt)
.HasColumnName("CreatedAt")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired(true)
.IsNavigationProperty(false);
map.Prop(x => x.ModifiedAt)
.HasColumnName("ModifiedAt")
.IsPk(false)
.IsFk(false)
.IsRequired(false)
.IsIdentity(false)
.IsNavigationProperty(false);
}
}