Exemplo n.º 1
0
            public void When_an_object_is_not_binary_serializable_it_should_fail()
            {
                // Arrange
                var subject = new UnserializableClass
                {
                    Name = "John"
                };

                // Act
                Action act = () => subject.Should().BeBinarySerializable("we need to store it on {0}", "disk");

                // Assert
                act.Should().Throw <XunitException>()
                .WithMessage("*to be serializable because we need to store it on disk, but serialization failed with:*UnserializableClass*");
            }
        public void When_an_object_is_not_binary_serializable_it_should_fail()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new UnserializableClass
            {
                Name = "John"
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().BeBinarySerializable("we need to store it on {0}", "disk");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
            .ShouldThrow <AssertFailedException>()
            .Where(ex =>
                   ex.Message.Contains("to be serializable because we need to store it on disk, but serialization failed with:") &&
                   ex.Message.Contains("marked as serializable"));
        }
        public void When_an_object_is_not_binary_serializable_it_should_fail()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new UnserializableClass
            {
                Name = "John"
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().BeBinarySerializable("we need to store it on {0}", "disk");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
                .ShouldThrow<AssertFailedException>()
                .Where(ex =>
                    ex.Message.Contains("to be serializable because we need to store it on disk, but serialization failed with:") &&
                    ex.Message.Contains("marked as serializable"));
        }