Пример #1
0
        public void AfterInsertThrowsArgumentNullExceptionForNullInstance()
        {
            var listener = new IdentifierStrategyListener();

            var exception = Assert.Throws <ArgumentNullException>(() => listener.AfterInsert(null, 1));

            Assert.Equal("instance", exception.ParamName);
        }
Пример #2
0
        public void AfterInsertDoesNotThrowArgumentNullExceptionForNullExecuteScalarResultIfIdentifierStrategyAssigned()
        {
            ObjectInfo.MappingConvention = new ConventionMappingConvention(
                UnitTest.GetConventionMappingSettings(IdentifierStrategy.Assigned));

            var listener = new IdentifierStrategyListener();

            Assert.DoesNotThrow(() => listener.AfterInsert(new Customer(), null));
        }
Пример #3
0
        public void AfterInsertDoesNotSetIdentifierIfExecuteScalarResultIsNullAndIdentifierStrategySequence()
        {
            ObjectInfo.MappingConvention = new ConventionMappingConvention(
                UnitTest.GetConventionMappingSettings(IdentifierStrategy.Sequence));

            var listener = new IdentifierStrategyListener();
            var customer = new Customer();

            Assert.DoesNotThrow(() => listener.AfterInsert(customer, null));

            Assert.Equal(0, customer.Id);
        }
Пример #4
0
        public void AfterInsertSetsIdentifierValueForIdentifierStrategySequence()
        {
            ObjectInfo.MappingConvention = new ConventionMappingConvention(
                UnitTest.GetConventionMappingSettings(IdentifierStrategy.Sequence));

            var customer     = new Customer();
            int scalarResult = 4354;

            var listener = new IdentifierStrategyListener();

            listener.AfterInsert(customer, scalarResult);

            Assert.Equal(scalarResult, customer.Id);
        }
Пример #5
0
        public void AfterInsertSetsIdentifierValueConvertingItToThePropertyType()
        {
            ObjectInfo.MappingConvention = new ConventionMappingConvention(
                UnitTest.GetConventionMappingSettings(IdentifierStrategy.DbGenerated));

            var     customer     = new Customer();
            decimal scalarResult = 4354;

            var listener = new IdentifierStrategyListener();

            listener.AfterInsert(customer, scalarResult);

            Assert.Equal(Convert.ToInt32(scalarResult), customer.Id);
        }