Skip to content

Commit 076de69

Browse files
committed
Added FluentAssertions, NaughtyAttributes update; Demo gif added
1 parent d4bb577 commit 076de69

514 files changed

Lines changed: 27785 additions & 40 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Plugins/FluentAssertions.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/FluentAssertions/Core.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Diagnostics;
2+
3+
namespace FluentAssertions
4+
{
5+
[DebuggerNonUserCode]
6+
public class AndConstraint<T>
7+
{
8+
private readonly T parentConstraint;
9+
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="T:System.Object"/> class.
12+
/// </summary>
13+
public AndConstraint(T parentConstraint)
14+
{
15+
this.parentConstraint = parentConstraint;
16+
}
17+
18+
public T And
19+
{
20+
get { return parentConstraint; }
21+
}
22+
}
23+
}

Assets/Plugins/FluentAssertions/Core/AndConstraint.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
using FluentAssertions.Common;
6+
using FluentAssertions.Formatting;
7+
8+
namespace FluentAssertions
9+
{
10+
/// <summary>
11+
/// Constraint which can be returned from an assertion which matches a condition and which will allow
12+
/// further matches to be performed on the matched condition as well as the parent constraint.
13+
/// </summary>
14+
/// <typeparam name="TParentConstraint">The type of the original constraint that was matched</typeparam>
15+
/// <typeparam name="TMatchedElement">The type of the matched object which the parent constraint matched</typeparam>
16+
public class AndWhichConstraint<TParentConstraint, TMatchedElement> : AndConstraint<TParentConstraint>
17+
{
18+
private readonly Lazy<TMatchedElement> matchedConstraint;
19+
20+
public AndWhichConstraint(TParentConstraint parentConstraint, TMatchedElement matchedConstraint)
21+
: base(parentConstraint)
22+
{
23+
this.matchedConstraint =
24+
new Lazy<TMatchedElement>(() => matchedConstraint);
25+
}
26+
27+
public AndWhichConstraint(TParentConstraint parentConstraint, IEnumerable<TMatchedElement> matchedConstraint)
28+
: base(parentConstraint)
29+
{
30+
this.matchedConstraint =
31+
new Lazy<TMatchedElement>(
32+
() => SingleOrDefault(matchedConstraint));
33+
}
34+
35+
private static TMatchedElement SingleOrDefault(
36+
IEnumerable<TMatchedElement> matchedConstraint)
37+
{
38+
TMatchedElement[] matchedElements = matchedConstraint.ToArray();
39+
40+
if (matchedElements.Count() > 1)
41+
{
42+
string foundObjects = string.Join(Environment.NewLine,
43+
matchedElements.Select(
44+
ele => "\t" + Formatter.ToString(ele)));
45+
46+
string message = string.Format(
47+
"More than one object found. FluentAssertions cannot determine which object is meant. Found objects:{0}{1}",
48+
Environment.NewLine,
49+
foundObjects);
50+
51+
Services.ThrowException(message);
52+
}
53+
54+
return matchedElements.Single();
55+
}
56+
57+
/// <summary>
58+
/// Returns the single result of a prior assertion that is used to select a nested or collection item.
59+
/// </summary>
60+
public TMatchedElement Which
61+
{
62+
get { return matchedConstraint.Value; }
63+
}
64+
65+
/// <summary>
66+
/// Returns the single result of a prior assertion that is used to select a nested or collection item.
67+
/// </summary>
68+
/// <remarks>
69+
/// Just a convenience property that returns the same value as <see cref="Which"/>.
70+
/// </remarks>
71+
public TMatchedElement Subject
72+
{
73+
get { return Which; }
74+
}
75+
}
76+
}
77+

Assets/Plugins/FluentAssertions/Core/AndWhichConstraint.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#region
2+
3+
using System;
4+
using FluentAssertions.Common;
5+
using FluentAssertions.Equivalency;
6+
7+
#endregion
8+
9+
namespace FluentAssertions
10+
{
11+
/// <summary>
12+
/// Holds any global options that control the behavior of FluentAssertions.
13+
/// </summary>
14+
public static class AssertionOptions
15+
{
16+
private static EquivalencyAssertionOptions defaults = new EquivalencyAssertionOptions();
17+
18+
static AssertionOptions()
19+
{
20+
EquivalencySteps = new EquivalencyStepCollection();
21+
}
22+
23+
public static EquivalencyAssertionOptions<T> CloneDefaults<T>()
24+
{
25+
return new EquivalencyAssertionOptions<T>(defaults);
26+
}
27+
28+
/// <summary>
29+
/// Defines a predicate with which the <see cref="EquivalencyValidator"/> determines if it should process
30+
/// an object's properties or not.
31+
/// </summary>
32+
/// <returns>
33+
/// Returns <c>true</c> if the object should be treated as a value type and its <see cref="object.Equals(object)"/>
34+
/// must be used during a structural equivalency check.
35+
/// </returns>
36+
public static Func<Type, bool> IsValueType = type =>
37+
(type.Namespace == typeof (int).Namespace) &&
38+
!type.IsSameOrInherits(typeof(Exception));
39+
40+
/// <summary>
41+
/// Allows configuring the defaults used during a structural equivalency assertion.
42+
/// </summary>
43+
/// <param name="defaultsConfigurer">
44+
/// An action that is used to configure the defaults.
45+
/// </param>
46+
public static void AssertEquivalencyUsing(
47+
Func<EquivalencyAssertionOptions, EquivalencyAssertionOptions> defaultsConfigurer)
48+
{
49+
defaults = defaultsConfigurer(defaults);
50+
}
51+
52+
/// <summary>
53+
/// Represents a mutable collection of steps that are executed while asserting a (collection of) object(s)
54+
/// is structurally equivalent to another (collection of) object(s).
55+
/// </summary>
56+
public static EquivalencyStepCollection EquivalencySteps { get; private set; }
57+
}
58+
}

Assets/Plugins/FluentAssertions/Core/AssertionOptions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/FluentAssertions/Core/Collections.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)