/// <summary> /// Create an error message given the code. /// </summary> /// <param name="action"></param> /// <returns></returns> internal static string CreateMessage(interfaces.EventError action) { switch (action) { case interfaces.EventError.General: return("General error"); case interfaces.EventError.Memory: return("Guarded risk of memory corruption"); case interfaces.EventError.Overflow: return("Guarded risk of memory overflow"); case interfaces.EventError.Aborted: return("Monitoring was aborted"); case interfaces.EventError.CannotStart: return("Unable to start monitoring"); case interfaces.EventError.Access: return("Unable to access the given file/folder"); case interfaces.EventError.NoFileData: return("The raised event did not have any valid file name"); case interfaces.EventError.CannotStop: return("There was an issue trying to stop the watcher(s)"); case interfaces.EventError.None: return("No Error"); default: return($"An unknown error code was returned: {(int)action}"); } }
public void ValuesAreSaved() { var utc = DateTime.UtcNow; const interfaces.EventError code = interfaces.EventError.Aborted; var err = new EventError(code, utc); Assert.AreEqual(err.Code, code); Assert.AreEqual(err.DateTimeUtc, utc); }
public EventError(interfaces.EventError error, DateTime utc) { // the date of the event. DateTimeUtc = utc; // checkthat the given enum value is valid. if (!Enum.IsDefined(typeof(interfaces.EventError), error)) { throw new ArgumentOutOfRangeException(nameof(error), error, "Unknown Event Error code."); } Code = error; }
public Event(bool isFile, string name, string oldName, EventAction action, interfaces.EventError error, DateTime dateTimeUtc ) { IsFile = isFile; Name = name; OldName = oldName; Action = action; Error = error; DateTimeUtc = dateTimeUtc; }
public EventError(interfaces.EventError error, DateTime utc) { DateTimeUtc = utc; Code = error; Message = CreateMessage(error); }