Inheritance: FluentMappingSource
コード例 #1
0
        public void MappingTester_should_throw_for_incorrectly_mapped_collection()
        {
            var brokenMappings = new TestMappingSource();
            //Remove the customer.Orders mapping.
            var customerMapping = brokenMappings.OfType<Mapping<Customer>>().Cast<IMapping>().Single();
            customerMapping.Mappings.RemoveAt(2);

            DataContextFactory = () => new TestDataContext(brokenMappings);

            Assert.Throws<MappingException>(() => {
                using (var test = Verify<Customer>()) {
                    test.TestCollection(x => x.Orders, new Order() { OrderDate = DateTime.Now });
                }
            });
        }
コード例 #2
0
        public void MappingTester_should_throw_for_incorrectly_mapped_proprty()
        {
            var brokenMappings = new TestMappingSource();

            //Remove the Customer.Name mapping.
            var customerMapping= brokenMappings.OfType<Mapping<Customer>>().Cast<IMapping>().Single();
            customerMapping.Mappings.RemoveAt(1);

            DataContextFactory = () => new TestDataContext(brokenMappings);

            Assert.Throws<MappingException>(() => {
                using (var test = Verify<Customer>()) {
                    test.TestProperty(x => x.Name, "Jeremy");
                }
            });
        }
コード例 #3
0
        public void MappingTester_should_throw_for_incorrectly_mapped_proprty()
        {
            var brokenMappings = new TestMappingSource();

            //Remove the Customer.Name mapping.
            var customerMapping = brokenMappings.OfType <Mapping <Customer> >().Cast <IMapping>().Single();

            customerMapping.Mappings.RemoveAt(1);

            DataContextFactory = () => new TestDataContext(brokenMappings);

            Assert.Throws <MappingException>(() => {
                using (var test = Verify <Customer>()) {
                    test.TestProperty(x => x.Name, "Jeremy");
                }
            });
        }
コード例 #4
0
        public void MappingTester_should_throw_for_incorrectly_mapped_collection()
        {
            var brokenMappings = new TestMappingSource();
            //Remove the customer.Orders mapping.
            var customerMapping = brokenMappings.OfType <Mapping <Customer> >().Cast <IMapping>().Single();

            customerMapping.Mappings.RemoveAt(2);

            DataContextFactory = () => new TestDataContext(brokenMappings);

            Assert.Throws <MappingException>(() => {
                using (var test = Verify <Customer>()) {
                    test.TestCollection(x => x.Orders, new Order()
                    {
                        OrderDate = DateTime.Now
                    });
                }
            });
        }