示例#1
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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();
     }
 }
示例#6
0
 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)));
     }
 }
示例#7
0
 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));
         }
     }
示例#8
0
 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);
         }
     }
 }
示例#9
0
 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);
         }
     }
 }