Пример #1
0
        public void Constructing_an_instance_should_initialize_the_command()
        {
            String   aMessage   = "Hello world";
            ICommand theCommand = MockRepository.GenerateMock <ICommand>();

            var target = new MappingNotFoundException(aMessage, theCommand);

            target.Command.Should().Be(theCommand);
        }
        public Mapping GetMapping(string worksheetName, string colName)
        {
            Dictionary <string, Mapping> mappingDict = GetExtColNameToMappingDict(worksheetName);

            if (!mappingDict.TryGetValue(colName, out Mapping mapping))
            {
                MappingNotFoundException.SetMessageItems(worksheetName, colName);
            }

            return(mapping);
        }
Пример #3
0
        public void entityType_should_be_included_when_serializing_with_DataContract()
        {
            var serializer = new DataContractSerializer(typeof(MappingNotFoundException));
            var ms         = new MemoryStream();

            var sut = new MappingNotFoundException(typeof(string));

            serializer.WriteObject(ms, sut);
            ms.Position = 0;
            var actual = (MappingNotFoundException)serializer.ReadObject(ms);

            actual.EntityTypeName.Should().Be(typeof(string).FullName);
        }
Пример #4
0
        public void message_should_be_included_when_serializing_with_DataContract()
        {
            var serializer = new DataContractSerializer(typeof(MappingNotFoundException));
            var ms         = new MemoryStream();

            var sut = new MappingNotFoundException(typeof(string));

            serializer.WriteObject(ms, sut);
            ms.Position = 0;
            var actual = (MappingNotFoundException)serializer.ReadObject(ms);

            actual.Message.Should().Be("Failed to find mapper for entity 'System.String'.");
        }
Пример #5
0
        public void serialization_works_with_datacontract()
        {
            var serializer = new DataContractSerializer(typeof(MappingNotFoundException));
            var ms         = new MemoryStream();

            var sut = new MappingNotFoundException(typeof(string));

            serializer.WriteObject(ms, sut);
            ms.Position = 0;
            var actual = (MappingNotFoundException)serializer.ReadObject(ms);

            actual.Message.Should().Be("Failed to find mapper for entity 'System.String'.");
            actual.EntityTypeName.Should().Be(typeof(string).FullName);
        }
Пример #6
0
        public void serialization_works_with_BinaryFormatter()
        {
            var serializer = new BinaryFormatter();
            var ms         = new MemoryStream();

            var sut = new MappingNotFoundException(typeof(string));

            serializer.Serialize(ms, sut);
            ms.Position = 0;
            var actual = (MappingNotFoundException)serializer.Deserialize(ms);

            actual.Message.Should().Be("Failed to find mapper for entity 'System.String'.");
            actual.EntityTypeName.Should().Be(typeof(string).FullName);
        }
Пример #7
0
        public void It_should_be_serializable()
        {
            var      aMessage     = "Hello world";
            ICommand aCommand     = MockRepository.GenerateMock <ICommand>();
            var      theException = new MappingNotFoundException(aMessage, aCommand);
            MappingNotFoundException deserializedException = null;

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

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

            deserializedException.Should().NotBeNull();
        }
Пример #8
0
        public void type_is_assigned_to_the_property()
        {
            var sut = new MappingNotFoundException(typeof(string));

            sut.EntityTypeName.Should().Be(typeof(string).FullName);
        }
Пример #9
0
        public void description_is_assigned_to_base()
        {
            var sut = new MappingNotFoundException(typeof(string));

            sut.Message.Should().Be("Failed to find mapper for entity 'System.String'.");
        }