public void IsValid() { var item = new BmiDto() { Height = 300, Weight = 500, }; Assert.IsTrue(item.IsValid()); }
public void IsInvalid_TooTiny() { var item = new BmiDto() { Height = 1, Weight = 150, }; Assert.IsFalse(item.IsValid()); }
public void IsInvalid_TooLight() { var item = new BmiDto() { Weight = 0.999F, Height = 150, }; Assert.IsFalse(item.IsValid()); }
public void IsInvalid_TooHeavy() { var item = new BmiDto() { Weight = 501, Height = 150, }; Assert.IsFalse(item.IsValid()); }
private void AddBmi() { Assert.IsNotNull(PluginContext.Host, "PluginContext.Host"); Assert.IsNotNull(PluginContext.Host.SelectedPatient, "SelectedPatient"); Assert.IsNotNull(this.CurrentBmi, "CurrentBmi"); try { this.component.CreateBmi(this.CurrentBmi, PluginContext.Host.SelectedPatient); PluginContext.Host.WriteStatus(StatusType.Info, Messages.Msg_BmiAdded); this.CurrentBmi = new BmiDto(); } catch (Exception ex) { this.Handle.Error(ex, Messages.Msg_ErrAddBmi); } this.Close(); }
/// <summary> /// Adds a bmi entry to the specified patient. /// </summary> /// <param name="bmi">The bmi.</param> /// <param name="forPatient">The patient.</param> public void Create(BmiDto bmi, LightPatientDto forPatient) { var entity = this.Session.Get<Patient>(forPatient.Id); if (entity != null) { entity.Height = bmi.Height; entity.BmiHistory.Add(Mapper.Map<BmiDto, Bmi>(bmi)); this.Session.Update(entity); forPatient.Height = bmi.Height; } else { throw new EntityNotFoundException(typeof(Bmi)); } }