单元测试,OxyPlot 数据点比较
Unit testing, OxyPlot data point comparation
我想将从 postgres 数据库接收到的数据点与我发送到数据库的数据指针进行比较。
[TestMethod]
public void MeasurementWriteReadDelete()
{
Measurement core = new Measurement();
DbRepository database = null;
database = DbRepository.GetInstance();
database.EstablishConnection("postgres", "1234");
Assert.IsTrue(database.IsConnected);
core.Title = "aaa";
core.Description = "bbb";
core.Tester = "1.22";
core.ForceTravelCharacteristic.Points.Add(new DataPoint(0, 2));
core.PullForceCharacteristic.Points.Add(new DataPoint(0, 4));
core.ReturnSpeedCharacteristic.Points.Add(new DataPoint(1, 1));
core.EngagementPoint.X = 10;
core.EngagementPoint.Y = 13;
core.CreateInDatabase(DbRepository.GetInstance());
core.Id = Convert.ToUInt32(core.CurrentID);
core.ReadCharacteristicFromDatabase(DbRepository.GetInstance());
core.ReadMetadataFromDatabase(DbRepository.GetInstance());
Assert.AreEqual("aaa", core.Title);
Assert.AreEqual("bbb", core.Description);
Assert.AreEqual("1.22", core.Tester);
Assert.AreEqual(10, core.EngagementPoint.X);
Assert.AreEqual(13, core.EngagementPoint.Y);
Assert.AreEqual( , core.ForceTravelCharacteristic);
core.DeleteFromDatabase(DbRepository.GetInstance());
我想比较这个:
core.ForceTravelCharacteristic.Points.Add(new DataPoint(0, 2));
使用数据库中的数据:
core.ForceTravelCharacteristic
我该如何比较?
[TestMethod]
public void MeasurementWriteReadDelete()
{
Measurement core = new Measurement();
DbRepository database = null;
ForceTravelCharacteristicVal = new LineSeries();
ForceTravelCharacteristicVal.Points.Add(new DataPoint(3, 3));
database = DbRepository.GetInstance();
database.EstablishConnection("postgres", "1234");
Assert.IsTrue(database.IsConnected);
core.Title = "aaa";
core.Description = "bbb";
core.Tester = "1.22";
core.ForceTravelCharacteristic.Points.Add(new DataPoint(3, 3));
core.ForceTravelCharacteristic.Points.Add(new DataPoint(1, 5));
core.ForceTravelCharacteristic.Points.Add(new DataPoint(100, -100));
core.PullForceCharacteristic.Points.Add(new DataPoint(0, 4));
core.ReturnSpeedCharacteristic.Points.Add(new DataPoint(1, 1));
core.EngagementPoint.X = 10;
core.EngagementPoint.Y = 13;
core.CreateInDatabase(DbRepository.GetInstance());
core.Id = Convert.ToInt32(core.CurrentID);
core.ReadCharacteristicFromDatabase(DbRepository.GetInstance());
core.ReadMetadataFromDatabase(DbRepository.GetInstance());
Assert.AreEqual("aaa", core.Title);
Assert.AreEqual("bbb", core.Description);
Assert.AreEqual("1.22", core.Tester);
Assert.AreEqual(10, core.EngagementPoint.X);
Assert.AreEqual(13, core.EngagementPoint.Y);
Assert.AreEqual(ForceTravelCharacteristicVal.Points.ElementAt(0).X, core.ForceTravelCharacteristic.Points.ElementAt(0).X);
Assert.AreEqual(ForceTravelCharacteristicVal.Points.ElementAt(0).Y, core.ForceTravelCharacteristic.Points.ElementAt(0).Y);
core.DeleteFromDatabase(DbRepository.GetInstance());
}
public LineSeries ForceTravelCharacteristicVal { get; set; }
}
我想将从 postgres 数据库接收到的数据点与我发送到数据库的数据指针进行比较。
[TestMethod]
public void MeasurementWriteReadDelete()
{
Measurement core = new Measurement();
DbRepository database = null;
database = DbRepository.GetInstance();
database.EstablishConnection("postgres", "1234");
Assert.IsTrue(database.IsConnected);
core.Title = "aaa";
core.Description = "bbb";
core.Tester = "1.22";
core.ForceTravelCharacteristic.Points.Add(new DataPoint(0, 2));
core.PullForceCharacteristic.Points.Add(new DataPoint(0, 4));
core.ReturnSpeedCharacteristic.Points.Add(new DataPoint(1, 1));
core.EngagementPoint.X = 10;
core.EngagementPoint.Y = 13;
core.CreateInDatabase(DbRepository.GetInstance());
core.Id = Convert.ToUInt32(core.CurrentID);
core.ReadCharacteristicFromDatabase(DbRepository.GetInstance());
core.ReadMetadataFromDatabase(DbRepository.GetInstance());
Assert.AreEqual("aaa", core.Title);
Assert.AreEqual("bbb", core.Description);
Assert.AreEqual("1.22", core.Tester);
Assert.AreEqual(10, core.EngagementPoint.X);
Assert.AreEqual(13, core.EngagementPoint.Y);
Assert.AreEqual( , core.ForceTravelCharacteristic);
core.DeleteFromDatabase(DbRepository.GetInstance());
我想比较这个:
core.ForceTravelCharacteristic.Points.Add(new DataPoint(0, 2));
使用数据库中的数据:
core.ForceTravelCharacteristic
我该如何比较?
[TestMethod]
public void MeasurementWriteReadDelete()
{
Measurement core = new Measurement();
DbRepository database = null;
ForceTravelCharacteristicVal = new LineSeries();
ForceTravelCharacteristicVal.Points.Add(new DataPoint(3, 3));
database = DbRepository.GetInstance();
database.EstablishConnection("postgres", "1234");
Assert.IsTrue(database.IsConnected);
core.Title = "aaa";
core.Description = "bbb";
core.Tester = "1.22";
core.ForceTravelCharacteristic.Points.Add(new DataPoint(3, 3));
core.ForceTravelCharacteristic.Points.Add(new DataPoint(1, 5));
core.ForceTravelCharacteristic.Points.Add(new DataPoint(100, -100));
core.PullForceCharacteristic.Points.Add(new DataPoint(0, 4));
core.ReturnSpeedCharacteristic.Points.Add(new DataPoint(1, 1));
core.EngagementPoint.X = 10;
core.EngagementPoint.Y = 13;
core.CreateInDatabase(DbRepository.GetInstance());
core.Id = Convert.ToInt32(core.CurrentID);
core.ReadCharacteristicFromDatabase(DbRepository.GetInstance());
core.ReadMetadataFromDatabase(DbRepository.GetInstance());
Assert.AreEqual("aaa", core.Title);
Assert.AreEqual("bbb", core.Description);
Assert.AreEqual("1.22", core.Tester);
Assert.AreEqual(10, core.EngagementPoint.X);
Assert.AreEqual(13, core.EngagementPoint.Y);
Assert.AreEqual(ForceTravelCharacteristicVal.Points.ElementAt(0).X, core.ForceTravelCharacteristic.Points.ElementAt(0).X);
Assert.AreEqual(ForceTravelCharacteristicVal.Points.ElementAt(0).Y, core.ForceTravelCharacteristic.Points.ElementAt(0).Y);
core.DeleteFromDatabase(DbRepository.GetInstance());
}
public LineSeries ForceTravelCharacteristicVal { get; set; }
}