示例#1
0
        /// <summary>
        /// Verifies that the passed-in assertion refers to a <see cref="ReferenceTypeAssertions{TSubject, TAssertions}.Subject"/>
        /// that is a Fake.
        /// </summary>
        /// <param name="assertion">A FluentAssertions assertion that has been initiated on a subject.</param>
        public static void BeAFake(this ReferenceTypeAssertions <object, ObjectAssertions> assertion)
        {
            Guard.AgainstNull(assertion, "assertion");

            assertion
            .NotBeNull("because fakes aren't null").And
            .Match(subject => Fake.GetFakeManager(subject) != null, "fakes have a FakeManager");
        }
示例#2
0
        /// <summary>
        /// Verifies that the passed-in assertion refers to a <see cref="ReferenceTypeAssertions{TSubject, TAssertions}.Subject"/>
        /// that is a Fake.
        /// </summary>
        /// <param name="assertion">A FluentAssertions assertion that has been initiated on a subject.</param>
        public static void BeAFake(this ReferenceTypeAssertions <object, ObjectAssertions> assertion)
        {
            if (assertion == null)
            {
                throw new ArgumentNullException(nameof(assertion));
            }

            assertion
            .NotBeNull("because fakes aren't null").And
            .Match(subject => Fake.GetFakeManager(subject) is object, "fakes have a FakeManager");
        }
示例#3
0
        public static ExceptionAssertions <TExpectedException> BeAnExceptionAssignableTo <TExpectedException>(this ReferenceTypeAssertions <object, ObjectAssertions> assertion) where TExpectedException : Exception
        {
            Guard.AgainstNull(assertion, "assertion");

            assertion
            .NotBeNull("because it must be a valid exception").And
            .BeAssignableTo <TExpectedException>();

            var exception = (TExpectedException)assertion.Subject;

            return(new MyExceptionAssertions <TExpectedException>(exception));
        }
示例#4
0
        public static ExceptionAssertions <TExpectedException> BeAnExceptionAssignableTo <TExpectedException>(this ReferenceTypeAssertions <object, ObjectAssertions> assertion) where TExpectedException : Exception
        {
            if (assertion == null)
            {
                throw new ArgumentNullException(nameof(assertion));
            }

            assertion
            .NotBeNull("because it must be a valid exception").And
            .BeAssignableTo <TExpectedException>();

            var exception = (TExpectedException)assertion.Subject;

            return(new MyExceptionAssertions <TExpectedException>(exception));
        }