Exemple #1
0
        public void Constructing_an_instance_should_initialize_the_instance_type()
        {
            String message         = "Hello world";
            Type   theInstanceType = typeof(String);

            var target = new InstanceNotFoundInEnvironmentConfigurationException(theInstanceType, message);

            target.RequestedType.Should().Be(theInstanceType);
        }
Exemple #2
0
        public void Constructing_an_instance_should_initialize_the_inner_exception()
        {
            String aMessage          = "Hello world";
            Type   aInstanceType     = typeof(String);
            var    theInnerException = new Exception();

            var target = new InstanceNotFoundInEnvironmentConfigurationException(aInstanceType, aMessage, theInnerException);

            target.InnerException.Should().Be(theInnerException);
        }
Exemple #3
0
        public void It_should_be_serializable()
        {
            var  aMessage      = "Hello world";
            Type aInstanceType = typeof(String);

            var theException = new InstanceNotFoundInEnvironmentConfigurationException(aInstanceType, aMessage);
            InstanceNotFoundInEnvironmentConfigurationException deserializedException = null;

            using (var buffer = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(buffer, theException);

                buffer.Seek(0, SeekOrigin.Begin);
                deserializedException = (InstanceNotFoundInEnvironmentConfigurationException)formatter.Deserialize(buffer);
            }

            deserializedException.Should().NotBeNull();
        }