Exemplo n.º 1
0
        public void Deserialize_StoresKeyAndConfig()
        {
            // Arrange
            MissingConfigurationKeyException exception;
            var config = new Configurer();

            try
            {
                throw new MissingConfigurationKeyException("Foo", config);
            }
            catch (MissingConfigurationKeyException ex)
            {
                exception = ex;
            }
            var formatter = new BinaryFormatter();
            var stream    = new MemoryStream();

            formatter.Serialize(stream, exception);
            stream.Seek(0, SeekOrigin.Begin);


            // Act
            var resultException = (MissingConfigurationKeyException)formatter.Deserialize(stream);

            // Assert
            Assert.That(resultException.Key, Is.EqualTo("Foo"));
            Assert.That(resultException.Configuration, Is.EqualTo(config.ToString()));
        }
Exemplo n.º 2
0
        public void Ctor_SetsConfiguration()
        {
            //Arrange
            var config = new Configurer();

            // Act
            var ex = new MissingConfigurationKeyException("Foo", config);

            // Assert
            Assert.That(ex.Configuration, Is.EqualTo(config.ToString()));
        }