public void TestStatusHasOneErrors() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT status.AddError("This is an error"); //VERIFY status.HasErrors.ShouldBeTrue(); status.Message.ShouldEqual("Failed with 1 error"); status.GetAllErrors().ShouldEqual("This is an error"); }
public void TestCombineStatusesWithErrors() { //SETUP var status1 = new StatusGenericHandler(); var status2 = new StatusGenericHandler(); //ATTEMPT status1.AddError("This is an error"); status2.CombineErrors(status1); //VERIFY status2.HasErrors.ShouldBeTrue(); status2.Message.ShouldEqual("Failed with 1 error"); status2.GetAllErrors().ShouldEqual("This is an error"); }
/// <summary> /// This is designed to add one DTO to an existing SpecificUseData /// </summary> /// <typeparam name="TDto">This should be the type of a class that has the <see cref="ILinkToEntity{TEntity}"/> applied to it</typeparam> /// <param name="utData"></param> /// <returns></returns> public static SpecificUseData AddSingleDto <TDto>(this SpecificUseData utData) { var status = new StatusGenericHandler(); var typesInAssembly = typeof(TDto).Assembly.GetTypes(); var dtoRegister = new RegisterOneDtoType(typeof(TDto), typesInAssembly, utData.PublicConfig); status.CombineStatuses(dtoRegister); if (!status.IsValid) { throw new InvalidOperationException($"SETUP FAILED with {status.Errors.Count} errors. Errors are:\n" + status.GetAllErrors()); } SetupDtosAndMappings.SetupMappingForDto(dtoRegister, utData.ReadProfile, utData.SaveProfile); return(utData); }