private static void DateTimeSqlPrecisionComparer(IAssertionContext <DateTime> ctx) { var retrieved = ctx.Subject; var expected = ctx.Expectation; retrieved.Should().BeCloseTo(expected, 1000); }
public static void CustomDateComparison(IAssertionContext <object> context) { var actualValue = (DateTime)context.Subject; var expectedValue = (string)context.Expectation; var expectedDateTime = DateTime.Parse(expectedValue); actualValue.Should().Be(expectedDateTime); }
private static void EntityReferenceComparer(IAssertionContext <EntityReference> ctx) { var retrieved = ctx.Subject; var expected = ctx.Expectation; retrieved.Id.Should().Be(expected.Id); retrieved.Description.Should().Be(expected.Description); }
public static IAssertionTool ContextSet(this IAssertionTool assertTool, IAssertionContext ctx) { IAssertionContext tmp; if (_CONTEXT.TryGetValue(assertTool, out tmp)) { _CONTEXT.Remove(assertTool); } _CONTEXT.Add(assertTool, ctx); return(assertTool); }
private static void ShouldBeWithinOneMillisecond(IAssertionContext <DateTime?> context) { // Cassandra Timestamps are recorded with an accuracy down to the millisecond if (context.Expectation.HasValue) { context.Subject.Should().BeCloseTo(context.Expectation.Value, 1); } else { context.Subject.Should().NotHaveValue(); } }
private void CheckList(IAssertionContext <IEnumerable> a) { if (a.Expectation == null) { a.Subject.Should().BeEmpty(); } else { a.Subject.ShouldBeEquivalentTo(a.Expectation, opt => opt .Using <IEnumerable>(CheckList) .When(info => typeof(IEnumerable).IsAssignableFrom(info.CompileTimeType))); } }
private static void CustomCompare(IAssertionContext <object> a) { if (a.Expectation != null) { if (a.Expectation is ExchangeQualityMessage msgExp && a.Subject is ExchangeQualityMessage msgSubj) { msgSubj.ExchangeName.Should().Be(msgExp.ExchangeName); } else { a.Subject.Should().BeEquivalentTo(a.Expectation, o => o.WithStrictOrdering().Using <object>(CustomCompare).When(s => true)); } }
private void StringMatching(IAssertionContext <string> a, string expectationReference) { if (a.Expectation == null) { a.Subject.Should().BeNull(); } else { if (ReferenceEquals(a.Expectation, expectationReference)) { a.Subject.Should().Match(a.Expectation); } else { a.Subject.Should().Be(a.Expectation); } } }
private void IsGuid(IAssertionContext <string> a) { if (a.Expectation == null) { a.Subject.Should().BeNull(); } else { if (a.Expectation == Check_if_its_a_Guid) { Guid guid = Guid.Parse(a.Subject); guid.Should().NotBe(Guid.Empty); } else { a.Subject.Should().Be(a.Expectation); } } }