コード例 #1
0
        public void ShouldBeAbleToResolveAString()
        {
            //Arrange
            IEasyFieldType fieldType = null;
            IEasyFieldType expectedFieldType = new NVarCharFieldType();

            //Act
            Assert.DoesNotThrow(delegate { fieldType = EasyFieldTypeResolver.Resolve<String>(); });
            Assert.DoesNotThrow(delegate { fieldType = EasyFieldTypeResolver.Resolve<string>(); });

            //Assert
            Assert.NotNull(fieldType);
            Assert.Equal(expectedFieldType.Name, fieldType.Name);
            Assert.Equal(expectedFieldType.DefaultLength, fieldType.DefaultLength);
        }
コード例 #2
0
        public void ShouldBeAbleToMapAProperty()
        {
            //Arrange
            var context = new EmptyDbContext();
            var configuration = new EasyConfiguration(context);
            var expectedType = new NVarCharFieldType();

            //Act
            configuration.Configure<PersonModel>()
                .Map(x => x.FirstName);

            //Assert
            var tableConfiguration = configuration.TableConfigurations.FindByType<PersonModel>();
            var fields = tableConfiguration.Fields;
            var fieldConfiguraton = fields.GetByProperty<PersonModel, String>(x => x.FirstName);

            Assert.Equal(1, fields.Count);
            Assert.NotNull(fieldConfiguraton);
            Assert.Equal("FirstName", fieldConfiguraton.FieldName);
            Assert.Null(fieldConfiguraton.DefaultValue);
            //FieldType validation
            Assert.Equal(expectedType.Name, fieldConfiguraton.FieldType.Name);
            Assert.Equal(expectedType.DefaultLength, fieldConfiguraton.FieldType.DefaultLength);
        }