public static Extremum FromDto(ExtremumDto dto) { var extremum = new Extremum { ExtremumId = dto.ExtremumId, DateIndex = dto.DateIndex, AssetId = dto.AssetId, TimeframeId = dto.TimeframeId, ExtremumTypeId = dto.ExtremumTypeId, Value = dto.Value, IsEvaluationOpen = dto.IsEvaluationOpen, EarlierCounter = dto.EarlierCounter, EarlierAmplitude = dto.EarlierAmplitude, EarlierTotalArea = dto.EarlierTotalArea, EarlierAverageArea = dto.EarlierAverageArea, EarlierChange1 = dto.EarlierChange1, EarlierChange2 = dto.EarlierChange2, EarlierChange3 = dto.EarlierChange3, EarlierChange5 = dto.EarlierChange5, EarlierChange10 = dto.EarlierChange10, LaterCounter = dto.LaterCounter, LaterAmplitude = dto.LaterAmplitude, LaterTotalArea = dto.LaterTotalArea, LaterAverageArea = dto.LaterAverageArea, LaterChange1 = dto.LaterChange1, LaterChange2 = dto.LaterChange2, LaterChange3 = dto.LaterChange3, LaterChange5 = dto.LaterChange5, LaterChange10 = dto.LaterChange10 }; return(extremum); }
public void ToDto_ReturnsProperExtremumDtoObject() { //Arrange Price price = getPrice(DEFAULT_INDEX_NUMBER); Extremum extremum = new Extremum(price, ExtremumType.PeakByClose) { ExtremumId = 1, SimulationId = DEFAULT_SIMULATION_ID, LastCheckedDateTime = new DateTime(2017, 3, 5, 12, 0, 0), Volatility = 1.23, EarlierCounter = 15, EarlierAmplitude = 7.45, EarlierChange1 = 1.12, EarlierChange2 = 2.21, EarlierChange3 = 3.12, EarlierChange5 = 4.56, EarlierChange10 = 5.28, LaterCounter = 16, LaterAmplitude = 1.23, LaterChange1 = 0.72, LaterChange2 = 0.54, LaterChange3 = 1.57, LaterChange5 = 2.41, LaterChange10 = 3.15, Open = true, Value = 123.42 }; //Act ExtremumDto actualDto = extremum.ToDto(); //Assert ExtremumDto expectedDto = new ExtremumDto() { Id = 1, SimulationId = DEFAULT_SIMULATION_ID, Date = DEFAULT_BASE_DATE, IndexNumber = DEFAULT_INDEX_NUMBER, AssetId = DEFAULT_ASSET_ID, TimeframeId = DEFAULT_TIMEFRAME_ID, LastCheckedDateTime = new DateTime(2017, 3, 5, 12, 0, 0), ExtremumType = 1, Volatility = 1.23, EarlierCounter = 15, EarlierAmplitude = 7.45, EarlierChange1 = 1.12, EarlierChange2 = 2.21, EarlierChange3 = 3.12, EarlierChange5 = 4.56, EarlierChange10 = 5.28, LaterCounter = 16, LaterAmplitude = 1.23, LaterChange1 = 0.72, LaterChange2 = 0.54, LaterChange3 = 1.57, LaterChange5 = 2.41, LaterChange10 = 3.15, IsOpen = true, Value = 123.42 }; Assert.AreEqual(expectedDto, actualDto); }
public void CopyProperties_AfterwardAllPropertiesAreEqual() { //Arrange var baseItem = new ExtremumDto() { Id = 1, Date = new DateTime(2017, 3, 4, 21, 10, 0), AssetId = 1, TimeframeId = 1, SimulationId = 1, IndexNumber = 51, LastCheckedDateTime = new DateTime(2017, 3, 5, 12, 0, 0), ExtremumType = 1, Volatility = 1.23, EarlierCounter = 15, EarlierAmplitude = 7.45, EarlierChange1 = 1.12, EarlierChange2 = 2.21, EarlierChange3 = 3.12, EarlierChange5 = 4.56, EarlierChange10 = 5.28, LaterCounter = 16, LaterAmplitude = 1.23, LaterChange1 = 0.72, LaterChange2 = 0.54, LaterChange3 = 1.57, LaterChange5 = 2.41, LaterChange10 = 3.15, IsOpen = true, Timestamp = DateTime.Now, Value = 11.34 }; var comparedItem = new ExtremumDto() { Id = 2, Date = new DateTime(2017, 3, 4, 22, 10, 0), AssetId = 1, TimeframeId = 1, SimulationId = 1, IndexNumber = 55, LastCheckedDateTime = new DateTime(2017, 3, 5, 12, 0, 0), ExtremumType = 1, Volatility = 1.33, EarlierCounter = 16, EarlierAmplitude = 7.45, EarlierChange1 = 1.12, EarlierChange2 = 2.22, EarlierChange3 = 3.12, EarlierChange5 = 4.56, EarlierChange10 = 5.28, LaterCounter = 16, LaterAmplitude = 1.23, LaterChange1 = 0.72, LaterChange2 = 0.54, LaterChange3 = 1.57, LaterChange5 = 2.41, LaterChange10 = 3.15, IsOpen = true, Timestamp = DateTime.Now, Value = 0 }; //Act comparedItem.CopyProperties(baseItem); var areEqual = baseItem.Equals(comparedItem); //Assert Assert.IsTrue(areEqual); }