Exemplo n.º 1
0
        public void Can_get_entity_by_type()
        {
            var model = new Model();
            var entityType = new EntityType(typeof(Customer));
            model.AddEntityType(entityType);

            Assert.Same(entityType, model.GetEntityType(typeof(Customer)));
            Assert.Same(entityType, model.TryGetEntityType(typeof(Customer)));
            Assert.Null(model.TryGetEntityType(typeof(string)));

            Assert.Equal(
                Strings.FormatEntityTypeNotFound("String"),
                Assert.Throws<ModelItemNotFoundException>(() => model.GetEntityType(typeof(string))).Message);
        }
Exemplo n.º 2
0
        public void Can_get_entity_by_name()
        {
            var model      = new Model();
            var entityType = new EntityType(typeof(Customer));

            model.AddEntityType(entityType);

            Assert.Same(entityType, model.GetEntityType("Customer"));
            Assert.Same(entityType, model.TryGetEntityType("Customer"));
            Assert.Null(model.TryGetEntityType(typeof(string)));

            Assert.Equal(
                Strings.FormatEntityTypeNotFound("String"),
                Assert.Throws <ModelItemNotFoundException>(() => model.GetEntityType("String")).Message);
        }
Exemplo n.º 3
0
        public void Can_add_and_remove_entity()
        {
            var model = new Model();
            var entityType = new EntityType(typeof(Customer));

            Assert.Null(entityType.Model);

            model.AddEntityType(entityType);

            Assert.NotNull(model.TryGetEntityType(typeof(Customer)));
            Assert.Same(model, entityType.Model);

            model.RemoveEntityType(entityType);

            Assert.Null(model.TryGetEntityType(typeof(Customer)));
            Assert.Null(entityType.Model);
        }
Exemplo n.º 4
0
        public void Can_add_and_remove_entity()
        {
            var model      = new Model();
            var entityType = new EntityType(typeof(Customer));

            Assert.Null(entityType.Model);

            model.AddEntityType(entityType);

            Assert.NotNull(model.TryGetEntityType(typeof(Customer)));
            Assert.Same(model, entityType.Model);

            model.RemoveEntityType(entityType);

            Assert.Null(model.TryGetEntityType(typeof(Customer)));
            Assert.Null(entityType.Model);
        }
Exemplo n.º 5
0
        public void Can_get_entity_builder_for_entity_type_name()
        {
            var model        = new Model();
            var modelBuilder = new ModelBuilder(model);

            var entityBuilder = modelBuilder.Entity("Customer");

            Assert.NotNull(entityBuilder);
            Assert.NotNull(model.TryGetEntityType("Customer"));
        }
Exemplo n.º 6
0
        public void Can_get_entity_builder_for_entity_type_name()
        {
            var model = new Model();
            var modelBuilder = new ModelBuilder(model);

            var entityBuilder = modelBuilder.Entity("Customer");

            Assert.NotNull(entityBuilder);
            Assert.NotNull(model.TryGetEntityType("Customer"));
        }
Exemplo n.º 7
0
        public void Members_check_arguments()
        {
            var model = new Model();

            Assert.Equal(
                "entityType",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => model.AddEntityType(null)).ParamName);

            Assert.Equal(
                "entityType",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => model.RemoveEntityType(null)).ParamName);

            Assert.Equal(
                "type",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => model.TryGetEntityType((Type)null)).ParamName);
        }
Exemplo n.º 8
0
        public void Members_check_arguments()
        {
            var model = new Model();

            Assert.Equal(
                "entityType",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() => model.AddEntityType(null)).ParamName);

            Assert.Equal(
                "entityType",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() => model.RemoveEntityType(null)).ParamName);

            Assert.Equal(
                "type",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() => model.TryGetEntityType((Type)null)).ParamName);
        }