private static void ShouldHaveViolation <TMember>(IReadOnlyList <NotThreadSafeMemberInfo> result, ThreadSafetyViolationType violationType, string memberName = "member", int?expectedCount = null) { result.Should().NotBeNullOrEmpty(); if (expectedCount != null) { result.Should().HaveCount(expectedCount.Value, because: FormatBecause(result)); } result.Should().Contain(x => x.ViolationType == violationType && x.Member.GetType().IsSameOrInherits(typeof(TMember)) && x.Member.Name == memberName); }
public static string GetDescription(this ThreadSafetyViolationType value) { switch (value) { case ThreadSafetyViolationType.NonSingletonRegistration: return("Member has non singleton registration"); case ThreadSafetyViolationType.EventFound: return("Event found"); case ThreadSafetyViolationType.NonReadonlyMember: return("Non readonly member"); case ThreadSafetyViolationType.MutableReadonlyMember: return("Mutable readonly member"); default: throw new NotSupportedException($"value: {value}"); } }
public NotThreadSafeMemberInfo(MemberInfo member, ThreadSafetyViolationType violationType) { this.Member = member; this.ViolationType = violationType; }