/// <summary> /// Creates an exception based on the current state of the configuration. /// </summary> /// <param name="innerException">Inner exception</param> /// <returns>FluentConfigurationException with state</returns> private FluentConfigurationException CreateConfigurationException(Exception innerException) { var ex = new FluentConfigurationException(ExceptionMessage, innerException); if (!dbSet) { ex.PotentialReasons.Add(ExceptionDatabaseMessage); } if (!mappingsSet) { ex.PotentialReasons.Add(ExceptionMappingMessage); } return(ex); }
public void ShouldSerializeFluentConfigurationExceptionCorrectly() { var original = new FluentConfigurationException("Test", new Exception()); original.PotentialReasons.Add("reason 1"); original.PotentialReasons.Add("reason 2"); var formatter = new BinaryFormatter(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, original); stream.Position = 0; var result = formatter.Deserialize(stream) as FluentConfigurationException; original.Message.ShouldEqual(result.Message); CollectionAssert.AreEquivalent(original.PotentialReasons, result.PotentialReasons); } }
/// <summary> /// Creates an exception based on the current state of the configuration. /// </summary> /// <param name="innerException">Inner exception</param> /// <returns>FluentConfigurationException with state</returns> private FluentConfigurationException CreateConfigurationException(Exception innerException) { var ex = new FluentConfigurationException(ExceptionMessage, innerException); if (!dbSet) ex.PotentialReasons.Add(ExceptionDatabaseMessage); if (!mappingsSet) ex.PotentialReasons.Add(ExceptionMappingMessage); return ex; }