существующих таблиц SQL Server
Два теста:
Назовите это A:
[Test]
public void AssertAccessPolicyWithIdAndChecksum()
{
var pol = Repo.GetPolicyFlightStatus(aut_id: 44544, checksum: "QXSDENY");
Assert.NotNull(pol);
}
Назовите это B
[Test]
public void AssertGetFriendlyPolicy()
{
var lineRepo = new tbl_StatusRepository();
var pol = Repo.GetPolicyFlightStatus(aut_id: 44544, checksum: "QXSDENY");
Assert.AreEqual("With Underwriter", pol.tbl_Status.txt_friendlyName);
Assert.AreEqual("WC/Longshore", pol.tbl_Line.txt_friendlyName);
}
Модели:
public partial class tbl_Policy
{
[Key]
public int aut_id { get; set; }
[ForeignKey("tbl_Status")]
public int int_statusID { get; set; }
public virtual tbl_Status tbl_Status { get; set; }
[ForeignKey("tbl_Line")]
public int int_lineID { get; set; }
public virtual tbl_Line tbl_Line { get; set; }
}
public class tbl_Status
{
[Key]
public int aut_id { get; set; }
public string txt_status { get; set; }
public string txt_friendlyName { get; set; }
public virtual tbl_Policy tbl_Policy { get; set; }
}
public class tbl_Line
{
[Key]
public int aut_id { get; set; }
public string txt_Line { get; set; }
public string txt_friendlyName { get; set; }
public virtual tbl_Policy tbl_Policy { get; set; }
}
при запуске
internal static tbl_Policy GetPolicyFlightStatus(int aut_id, string checksum)
{
if (Transcoder.Transcode(aut_id) == checksum)
{
var ctx = new LIGDataContext();
return ctx.tbl_Policy.Include("tbl_Line").Include("tbl_Status").Single(f => f.aut_id == aut_id);
}
return null;
}
TestA проходит тестBB выдает исключение в первой строке подтвержденияДобавление включений для подтаблиц
internal static tbl_Policy GetPolicyFlightStatus(int aut_id, string checksum)
{
if (Transcoder.Transcode(aut_id) == checksum)
{
var ctx = new LIGDataContext();
return ctx.tbl_Policy.Include("tbl_Line").Include("tbl_Status").Single(f => f.aut_id == aut_id);
}
return null;
}
Тест A и бросок B LIG2010RedesignMVC3.LIGMVC2010FlightTrackerTests.AssertAccessPolicyWithIdAndChecksum: System.InvalidOperationException: последовательность не содержит элементовLIG2010RedesignMVC3.LIGMVC2010FlightTrackerTests.AssertGetFriendlyPolicy: System.InvalidOperationException: последовательность не содержит элементов