示例#1
0
 public static void BeValidNotificationId(this ReferenceTypeAssertions <string, StringAssertions> assertions, string because = " ", params object[] becauseArgs)
 {
     Execute.Assertion
     .ForCondition(IsValidId(assertions.Subject))
     .BecauseOf(because, becauseArgs)
     .FailWith("Notification id [{0}] should not be null, empty, whitespace or equal to empty GUID and should be a valid GUID", assertions.Subject);
 }
示例#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)
        {
            Guard.AgainstNull(assertion, "assertion");

            assertion
            .NotBeNull("because fakes aren't null").And
            .Match(subject => Fake.GetFakeManager(subject) != null, "fakes have a FakeManager");
        }
示例#3
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");
        }
        public static AndConstraint <ReferenceTypeAssertions <T, TAssertions> > BeLike <T, TAssertions>(
            this ReferenceTypeAssertions <T, TAssertions> o,
            T expected,
            params Expression <Func <T, object> >[] skippedPropertiesOrFields)
            where TAssertions : ReferenceTypeAssertions <T, TAssertions>
        {
            var result = ObjectGraph.Compare(expected, o.Subject, skippedPropertiesOrFields);

            result.ExceededDifferences.Should().BeFalse(result.DifferencesString);
            return(new AndConstraint <ReferenceTypeAssertions <T, TAssertions> >(o));
        }
示例#5
0
        DependOnChain <TThisType, TAssertions>(
            this ReferenceTypeAssertions <TThisType, TAssertions> o,
            params object[] values)
            where TAssertions : ReferenceTypeAssertions <TThisType, TAssertions>
        {
            var objectTreePaths = new ObjectGraphPaths();

            new ObjectGraphNodeFactory(NoLogging, DefaultTerminalNodeConditions()).Root(o.Subject)
            .CollectPathsInto(objectTreePaths);
            objectTreePaths.AssertContainNonRootSubPath(values);
            return(new AndConstraint <ReferenceTypeAssertions <TThisType, TAssertions> >(o));
        }
示例#6
0
        public static AndConstraint <ReferenceTypeAssertions <TThisType, TAssertions> > DependOn <
            TAssertions, TDependency, TThisType>(
            this ReferenceTypeAssertions <TThisType, TAssertions> o,
            TDependency value)
            where TAssertions : ReferenceTypeAssertions <TThisType, TAssertions>
        {
            var objectTreePaths = new ObjectGraphPaths();

            new ObjectGraphNodeFactory(NoLogging, DefaultTerminalNodeConditions()).Root(o.Subject)
            .CollectPathsInto(objectTreePaths);
            objectTreePaths.AssertContainNonRoot(value);
            return(new AndConstraint <ReferenceTypeAssertions <TThisType, TAssertions> >(o));
        }
 public static void SynchronizeAccessTo <T, TAssertions>(
     this ReferenceTypeAssertions <T, TAssertions> assertions,
     Action <T> callToCheck,
     ILockAssertions lockAssertions,
     T wrappedObjectMock)
     where T : class
     where TAssertions : ReferenceTypeAssertions <T, TAssertions>
 {
     SynchronizationAssertions.Synchronizes(
         assertions.Subject,
         callToCheck,
         lockAssertions,
         wrappedObjectMock);
 }
示例#8
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));
        }
示例#9
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));
        }
示例#10
0
 public static AndConstraint <TAssertions> HaveExactlyOneConstructorWithoutOptionalParameters <TSubject, TAssertions>(this ReferenceTypeAssertions <TSubject, TAssertions> referenceTypeAssertions)
     where TAssertions : ReferenceTypeAssertions <TSubject, TAssertions>
 {
     referenceTypeAssertions.Subject.GetType().Should().HaveExactlyOneConstructorWithoutOptionalParameters();
     return(new AndConstraint <TAssertions>((TAssertions)referenceTypeAssertions));
 }