public void WhenRwyIsEnoughButUnableToClimbShouldThrowException() { var para = new TOParameters( 4000.0, // rwy length 1000.0, // elevation 210.0, // rwy heading -1.8, // slope 240.0, // wind direction 10.0, // wind speed 4.0, // oat 1000.0, // QHN false, // surface is wet? 250.0 * 1000.0, // weight kg 0, // thrust rating AntiIceOption.Off, true, // packs on 0); // flaps var calc = new TOCalculator(perfTable, para); double wt = calc.ClimbLimitWeightTon(); // Make it heavier than climb limit weight. PropertySetter.Set(para, "WeightKg", wt * 1000.0 + 1.0); Assert.Throws <PoorClimbPerformanceException>(() => new TOReportGenerator(perfTable, para).TakeOffReport()); }
public void Constructor_expression() { var setter = new PropertySetter <TestItem, int>(x => x.ItemId); var item = new TestItem(); setter.Set(item, 1); Assert.That(setter.Name, Is.EqualTo("ItemId")); Assert.That(setter.Set, Is.Not.Null); Assert.That(item.ItemId, Is.EqualTo(1)); }
public void Constructor_success() { var info = typeof(TestItem).GetProperty("ItemId"); var setter = new PropertySetter(info); var item = new TestItem(); setter.Set(item, 1); Assert.That(setter.Name, Is.EqualTo("ItemId")); Assert.That(setter.Set, Is.Not.Null); Assert.That(item.ItemId, Is.EqualTo(1)); }
private void AssertOtherResult(LandingReport report, LandingParameters para, BoeingPerfTable table) { var calc = new LandingCalculator(table, para); foreach (var i in report.AllSettings) { int brakeIndex = Array.FindIndex( table.BrakesAvailable(para.SurfaceCondition), x => x == i.BrkSetting); PropertySetter.Set(para, "BrakeIndex", brakeIndex); double rwyRequired = calc.DistanceRequiredMeter(); Assert.AreEqual(rwyRequired, i.ActualDisMeter, 0.5); double disRemain = para.RwyLengthMeter - rwyRequired; Assert.AreEqual(disRemain, i.DisRemainMeter, 0.5); } }
public static void SetProperty(object entity, IJsonProperty property, JsonValue value) { var propertyType = property.PropertyInfo.PropertyType; object propertyValue; try { if (property.Converter == null) { propertyValue = value; if (property.PropertyInfo.PropertyType.IsEnum) { object tempobject = (value as JsonPrimitive).Value; if (tempobject is int) { propertyValue = tempobject; } else { propertyValue = Enum.Parse(property.PropertyInfo.PropertyType, (string)tempobject); } } else if (property.PropertyInfo.PropertyType == typeof(Guid)) { propertyValue = new Guid(value.ToString()); } } else { propertyValue = property.Converter.FromJsonValue(propertyType, value, entity.GetType()); } } catch (Exception ex) { throw new ConversionException(property.PropertyInfo, value, ex); } PropertySetter.Set(entity, property.PropertyInfo, propertyValue); }