Esempio n. 1
0
    public static void CreateWithNoData()
    {
        var data  = new BooleanData();
        var style = new CSharpStylePatternLocalOverAnonymousFunctionStyle(data);

        Assert.That(style.Data, Is.SameAs(data), nameof(style.Data));
        Assert.That(style.GetSetting(), Is.EqualTo(string.Empty), nameof(style.GetSetting));
    }
Esempio n. 2
0
    public static void CreateWithCustomSeverity()
    {
        const Severity suggestion = Severity.Suggestion;
        var            data       = new BooleanData();
        var            style      = new CSharpStylePatternLocalOverAnonymousFunctionStyle(data, suggestion);

        Assert.That(style.Severity, Is.EqualTo(suggestion), nameof(style.Data));
    }
Esempio n. 3
0
 public override CSharpStylePatternLocalOverAnonymousFunctionStyle Add(CSharpStylePatternLocalOverAnonymousFunctionStyle style)
 {
     if (style is null)
     {
         throw new ArgumentNullException(nameof(style));
     }
     return(new CSharpStylePatternLocalOverAnonymousFunctionStyle(this.Data.Add(style.Data), this.Severity));
 }
Esempio n. 4
0
    public static void CreateWithMoreTrueData()
    {
        var data  = new BooleanData(1u, 1u, 0u);
        var style = new CSharpStylePatternLocalOverAnonymousFunctionStyle(data);

        Assert.That(style.Data, Is.SameAs(data), nameof(style.Data));
        Assert.That(style.GetSetting(), Is.EqualTo(
                        $"{CSharpStylePatternLocalOverAnonymousFunctionStyle.Setting} = true:{style.Severity.GetDescription()}"), nameof(style.GetSetting));
    }
Esempio n. 5
0
    public static void Add()
    {
        var style1 = new CSharpStylePatternLocalOverAnonymousFunctionStyle(new BooleanData(3u, 1u, 2u));
        var style2 = new CSharpStylePatternLocalOverAnonymousFunctionStyle(new BooleanData(30u, 10u, 20u));
        var style3 = style1.Add(style2);

        var data = style3.Data;

        Assert.That(data.TotalOccurences, Is.EqualTo(33u), nameof(data.TotalOccurences));
        Assert.That(data.TrueOccurences, Is.EqualTo(11u), nameof(data.TrueOccurences));
        Assert.That(data.FalseOccurences, Is.EqualTo(22u), nameof(data.FalseOccurences));
    }
Esempio n. 6
0
    public static void AddWithNull()
    {
        var style = new CSharpStylePatternLocalOverAnonymousFunctionStyle(new BooleanData());

        Assert.That(() => style.Add(null !), Throws.TypeOf <ArgumentNullException>());
    }