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

fluentassertions / fluentassertions.datasets / 12413638127

19 Dec 2024 01:27PM UTC coverage: 94.362%. First build
12413638127

Pull #5

github

web-flow
Merge e71ce3c7f into daac80f4c
Pull Request #5: GitHub actions

458 of 498 branches covered (91.97%)

Branch coverage included in aggregate %.

1266 of 1329 relevant lines covered (95.26%)

2324.28 hits per line

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

88.89
/Src/FluentAssertions.DataSets/Equivalency/ConstraintCollectionEquivalencyStep.cs
1
using System.Collections.Generic;
2
using System.Data;
3
using System.Linq;
4
using FluentAssertions.DataSets.Common;
5
using FluentAssertions.Equivalency;
6
using FluentAssertions.Execution;
7

8
namespace FluentAssertions.DataSets.Equivalency;
9

10
public class ConstraintCollectionEquivalencyStep : EquivalencyStep<ConstraintCollection>
11
{
12
    protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalencyValidationContext context,
13
        IValidateChildNodeEquivalency nestedValidator)
14
    {
15
        var assertionChain = AssertionChain.GetOrCreate().For(context);
412✔
16

17
        if (comparands.Subject is not ConstraintCollection)
412!
18
        {
19
            assertionChain
×
20
                .FailWith("Expected a value of type ConstraintCollection at {context:Constraints}, but found {0}",
×
21
                    comparands.Subject.GetType());
×
22
        }
23
        else
24
        {
25
            var subject = (ConstraintCollection)comparands.Subject;
412✔
26
            var expectation = (ConstraintCollection)comparands.Expectation;
412✔
27

28
            var subjectConstraints = subject.Cast<Constraint>().ToDictionary(constraint => constraint.ConstraintName);
1,340✔
29
            var expectationConstraints = expectation.Cast<Constraint>().ToDictionary(constraint => constraint.ConstraintName);
1,344✔
30

31
            IEnumerable<string> constraintNames = subjectConstraints.Keys.Union(expectationConstraints.Keys);
412✔
32

33
            foreach (var constraintName in constraintNames)
2,712✔
34
            {
35
                assertionChain
944✔
36
                    .ForCondition(subjectConstraints.TryGetValue(constraintName, out Constraint subjectConstraint))
944✔
37
                    .FailWith("Expected constraint named {0} in {context:Constraints collection}{reason}, but did not find one",
944✔
38
                        constraintName);
944✔
39

40
                assertionChain
944✔
41
                    .ForCondition(expectationConstraints.TryGetValue(constraintName, out Constraint expectationConstraint))
944✔
42
                    .FailWith("Found unexpected constraint named {0} in {context:Constraints collection}", constraintName);
944✔
43

44
                if (subjectConstraint is not null && expectationConstraint is not null)
944✔
45
                {
46
                    Comparands newComparands = new()
916✔
47
                    {
916✔
48
                        Subject = subjectConstraint,
916✔
49
                        Expectation = expectationConstraint,
916✔
50
                        CompileTimeType = typeof(Constraint)
916✔
51
                    };
916✔
52

53
                    IEquivalencyValidationContext nestedContext = context.AsCollectionItem<Constraint>(constraintName);
916✔
54
                    nestedValidator.AssertEquivalencyOf(newComparands, nestedContext);
916✔
55
                }
56
            }
57
        }
58

59
        return EquivalencyResult.EquivalencyProven;
412✔
60
    }
61
}
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

© 2025 Coveralls, Inc