• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 6237307473

19 Sep 2023 04:02PM UTC coverage: 57.015% (-0.4%) from 57.44%
6237307473

push

github

web-flow
Feature/rc4 (#1570)

* Syntax tidying
* Dependency updates
* Event handling singletons (ThrowImmediately and co)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: James A Sutherland <>
Co-authored-by: James Friel <jfriel001@dundee.ac.uk>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

10734 of 20259 branches covered (0.0%)

Branch coverage included in aggregate %.

5922 of 5922 new or added lines in 565 files covered. (100.0%)

30687 of 52390 relevant lines covered (58.57%)

7361.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/Rdmp.Core/ReusableLibraryCode/Checks/ThrowImmediatelyCheckNotifier.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8

9
namespace Rdmp.Core.ReusableLibraryCode.Checks;
10

11
/// <summary>
12
/// ICheckNotifier which converts failed CheckEventArgs into Exceptions.  Can optionally also throw on Warning messages.  By default all messages are written
13
/// to the Console.  The use case for this is any time you want to run Checks programmatically (i.e. without user intervention via a UI component) before running
14
/// and you don't expect any Checks to fail but want to make sure.  Or when you are in a Test and you want to make sure that a specific configuration bombs
15
/// when Checked with an appropriate failure message.
16
/// </summary>
17
public class ThrowImmediatelyCheckNotifier : ICheckNotifier
18
{
19
    public static readonly ThrowImmediatelyCheckNotifier Quiet = new(false, false);
4✔
20
    public static readonly ThrowImmediatelyCheckNotifier Noisy = new(true, false);
4✔
21
    public static readonly ThrowImmediatelyCheckNotifier QuietPicky = new(false, true);
4✔
22
    public static readonly ThrowImmediatelyCheckNotifier NoisyPicky = new(true, true);
4✔
23

24
    private ThrowImmediatelyCheckNotifier(bool write, bool picky)
16✔
25
    {
26
        WriteToConsole = write;
16✔
27
        ThrowOnWarning = picky;
16✔
28
    }
16✔
29

30
    [Obsolete("Use the singleton Luke")]
31
    public ThrowImmediatelyCheckNotifier()
×
32
    {
33
    }
×
34

35
    public virtual bool OnCheckPerformed(CheckEventArgs args)
36
    {
37
        if (WriteToConsole)
2,228!
38
            Console.WriteLine(args.Message);
×
39

40
        return args.Result switch
2,228✔
41
        {
2,228✔
42
            CheckResult.Fail => throw new Exception(args.Message, args.Ex),
166✔
43
            CheckResult.Warning when ThrowOnWarning => throw new Exception(args.Message, args.Ex),
144✔
44
            _ => false
2,050✔
45
            //do not apply fixes to warnings/success
2,228✔
46
        };
2,228✔
47
    }
48

49
    /// <summary>
50
    /// By default this class will only throw Fail results but if you set this flag then it will also throw warning messages
51
    /// </summary>
52
    public readonly bool ThrowOnWarning;
53

54
    /// <summary>
55
    /// By default this class will not log to the Console. Set to true to get a console flood
56
    /// </summary>
57
    public readonly bool WriteToConsole;
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc