Exemplo n.º 1
0
        public void ConvertFromProviderExpression_WhenIntegerIsProvided_ItShouldReturnIdentifierWithInternalInteger()
        {
            // Arrange
            const int id = 20;

            var identifierValueConverter = new IdentifierValueConverter <int>(new ConverterMappingHints());

            // Act
            var result = identifierValueConverter.ConvertFromProviderExpression.Compile().Invoke(id);

            // Assert
            Assert.Equal(id, result.GetValue());
        }
Exemplo n.º 2
0
        public void ConvertToProviderExpression_WhenIdentifierWithInternalNullIsProvidedForTypeGuid_ItShouldReturnDefaultGuid()
        {
            // Arrange
            var identifier = new Identifier(null);


            var identifierValueConverter = new IdentifierValueConverter <Guid>(new ConverterMappingHints());

            // Act
            var result = identifierValueConverter.ConvertToProviderExpression.Compile().Invoke(identifier);

            // Assert
            Assert.Equal(Guid.Empty, result);
        }
Exemplo n.º 3
0
        public void ValueGeneratorFactory_WhenValueGeneratedIsNeeded_ItShouldReturnIdentifierValueGenerator()
        {
            // Arrange
            var identifierValueConverter = new IdentifierValueConverter <int>(new ConverterMappingHints());

            var      conventionSet = new ConventionSet();
            var      entityType    = new EntityType(typeof(IdentifierSqlServerAnnotationProviderTests.Entity), new Model(conventionSet), ConfigurationSource.DataAnnotation);
            Property property      = new Property("Id", typeof(int), null, null, entityType, ConfigurationSource.DataAnnotation, null);


            // Act
            var result = identifierValueConverter.MappingHints.ValueGeneratorFactory.Invoke(property, entityType);

            // Assert
            Assert.Equal(typeof(IdentifierValueGenerator <int>), result.GetType());
        }
Exemplo n.º 4
0
        public static IValueConverter Or <T>(this IValueConverter primary, String keyword, T value)
        {
            var identifier = new IdentifierValueConverter <T>(keyword, value);

            return(new OrValueConverter(primary, identifier));
        }