private static bool EqualsWithDiagnostics <TSource, TDestination>(Likeness <TSource, TDestination> likeness, TDestination value) { try { likeness.ShouldEqual(value); DiagnosticsWriterLocator.DiagnosticsWriter.WriteMessage("The source and destination values are equal."); return(true); } catch (LikenessException ex) { DiagnosticsWriterLocator.DiagnosticsWriter.WriteMessage(String.Format("The source and destination values are not equal. Details: {0}", ex.Message)); return(false); } }
public void ObjectsShuldEqual() { var flintlockDto = new FlintlockDTO() { GName = "name", AdditionalProperty = "whatever", SharedPropertyName = "prop name" }; var flintlock = new Flintlock(flintlockDto); Likeness <Flintlock, FlintlockDTO> flintFlockDtoLikeness = flintlock .AsSource().OfLikeness <FlintlockDTO>() .With(dto => dto.GName).EqualsWhen((flintlock1, dto) => flintlock1.GoodName == dto.GName) // you can write an extension method to encapsulate it .Without(dto => dto.AdditionalProperty); // assert flintFlockDtoLikeness.ShouldEqual(flintlockDto); }
public void ThenTheFirstProjectCardContains(string title, string subtitle, string description, string summary, string met, string metKV, string partial, string partialKV, string notMet, string notMetKV) { ProjectCardModel actualModel = landingPage.GetCardDetails(); ProjectCardModel expectedModel = new ProjectCardModel(); expectedModel.Title = title; expectedModel.Subtitle = subtitle; expectedModel.Description = description; expectedModel.RequirementSummary = summary; expectedModel.ReqMet = met; expectedModel.ReqMetKV = metKV; expectedModel.ReqPartiallyMet = partial; expectedModel.ReqPartiallyMetKV = partialKV; expectedModel.ReqNotMet = notMet; expectedModel.ReqNotMetKV = notMetKV; var expectedModelLikeness = new Likeness <ProjectCardModel, ProjectCardModel>(expectedModel); expectedModelLikeness.ShouldEqual(actualModel); }