1 /** 2 The standard result types from a BDD 3 */ 4 module tagion.behaviour.BehaviourResult; 5 6 public import tagion.communication.HiRPC : ResultOk; 7 import tagion.hibon.Document; 8 import tagion.hibon.HiBONRecord; 9 10 static Document result_ok = result(ResultOk()).toDoc; /// This 11 12 /** 13 * Contains the Exception information 14 */ 15 @safe 16 @recordType("BDDError") 17 struct BehaviourError { 18 string msg; /// Error message in the Exception 19 string[] trace; ///. Exception line trace of in the exception 20 ulong line; 21 string file; 22 mixin HiBONRecord!(q{ 23 this(Throwable e) nothrow @trusted { 24 import std.exception : assumeWontThrow; 25 import std.stdio; 26 import std.string : splitLines; 27 msg = e.msg; 28 trace = assumeWontThrow(e.toString.splitLines); 29 line = e.line; 30 file = e.file; 31 } 32 }); 33 } 34 35 /** 36 * Stores the result from a BDD Action, Senario or Feature 37 */ 38 @safe 39 @recordType("BDDResult") 40 struct Result { 41 Document outcome; /// BDD test return document 42 mixin HiBONRecord!(); 43 } 44 45 /** 46 * 47 * Params: 48 * doc = to encapsulated in the result 49 * Returns: document wrapped as a Result 50 */ 51 @safe 52 Result result(const Document doc) nothrow { 53 Result result; 54 result.outcome = Document(doc.data); 55 return result; 56 } 57 58 /** 59 * ditto but takes a HiBONRecord instead of a Document 60 */ 61 @safe 62 Result result(T)(T hibon_record) if (isHiBONRecord!T) { 63 return result(hibon_record.toDoc); 64 }