예제 #1
0
        public void Should_be_serializable_when_arguments_are_equatable()
        {
            // Arrange
            object collection = new ArgumentCollection(
                new object[] { "first argument" },
                typeof(string).GetMethod("Equals", new[] { typeof(string) }));

            // Act

            // Assert
            collection.Should().BeBinarySerializable();
        }
        public void UsePredicateToValidateArguments_should_configure_matcher_to_pass_arguments_to_the_specified_predicate()
        {
            this.StubMethodInfoManagerToReturn(true);
            ArgumentCollection argumentsPassedToPredicate = null;

            var matcher = this.CreateMatcher <IFoo>(x => x.Bar(null, null));

            matcher.UsePredicateToValidateArguments(x =>
            {
                argumentsPassedToPredicate = x;
                return(true);
            });

            var call = ExpressionHelper.CreateFakeCall <IFoo>(x => x.Bar(1, 2));

            matcher.Matches(call);

            argumentsPassedToPredicate.Should().BeEquivalentTo(1, 2);
        }
        public void Then_All_Arguments_Are_In_The_Collection()
        {
            var expectedArguments = new[]
            {
                ArgumentBuilder.Build("foo", "bloop"),
                ArgumentBuilder.Build("bar", 13),
                ArgumentBuilder.Build("baz", 84.19),
                ArgumentBuilder.Build("foobar"),
                ArgumentBuilder.Build("jorb", false)
            };

            var systemUnderTest = new ArgumentCollection();

            foreach (var arg in expectedArguments)
            {
                systemUnderTest.Add(arg);
            }

            systemUnderTest.Should().BeEquivalentTo(expectedArguments.ToList());
        }
        public void Should_be_serializable_when_arguments_are_equatable()
        {
            // Arrange
            object collection = new ArgumentCollection(
                new object[] { "first argument" },
                typeof(string).GetMethod("Equals", new[] { typeof(string) }));

            // Act

            // Assert
            collection.Should().BeBinarySerializable();
        }