public void ShouldAddSingleInterceptorForAfterQueryExecution()
        {
            //Arrange
            var domain      = new TestDomain();
            var interceptor = new TestEventInterceptor <AfterQuery>(1);

            domain.Events = new List <IInterceptor>
            {
                interceptor
            };
            domain.ConnectionString = Settings.Default.Connection;

            //act
            var repository = new DomainRepositoryFactory(new[] { domain }).Create <TestDomain>();

            repository.Find(new EmptyQuery());

            //assert
            interceptor.WasCalled.Should().BeTrue();
        }
Example #2
0
        public void ShouldRegisterOneEventHandlerForPostSave()
        {
            //arrange
            var domain = new TestDomain();
            var testPreSaveInterceptor = new TestEventInterceptor <AfterSave>(1);

            domain.Events = new List <IInterceptor>
            {
                testPreSaveInterceptor
            };
            domain.ConnectionString = Settings.Default.Connection;

            //act
            var repo = new DomainRepository <TestDomain>(new DomainContext <TestDomain>(domain), domain);

            repo.Context.Commit();

            //assert
            testPreSaveInterceptor.WasCalled.Should().BeTrue();
        }
Example #3
0
        public void ShouldRegisterTwoEventHandlersForPostSaveAndHonorPriority()
        {
            //arrange
            var domain = new TestDomain();
            var testPreSaveInterceptor  = new TestEventInterceptor <AfterSave>(1);
            var testPreSaveInterceptor2 = new TestEventInterceptor <AfterSave>(2);

            domain.Events = new List <IInterceptor>
            {
                testPreSaveInterceptor,
                testPreSaveInterceptor2,
            };
            domain.ConnectionString = Settings.Default.Connection;

            //act
            var repo = new DomainRepository <TestDomain>(new DomainContext <TestDomain>(domain), domain);

            repo.Context.Commit();

            //assert
            testPreSaveInterceptor.WasCalled.Should().BeTrue();
            testPreSaveInterceptor2.WasCalled.Should().BeTrue();
            testPreSaveInterceptor.CallTime.Should().BeBefore(testPreSaveInterceptor2.CallTime);
        }
        public void ShouldAddTwoInterceptorForAfterScalarExecution()
        {
            //Arrange
            var domain         = new TestDomain();
            var interceptor    = new TestEventInterceptor <AfterScalar>(1);
            var interceptorTwo = new TestEventInterceptor <AfterScalar>(2);

            domain.Events = new List <IInterceptor>
            {
                interceptorTwo,
                interceptor
            };
            domain.ConnectionString = Settings.Default.Connection;

            //act
            var repository = new DomainRepositoryFactory(new[] { domain }).Create <TestDomain>();

            repository.Find(new EmptyScalar());

            //assert
            interceptor.WasCalled.Should().BeTrue();
            interceptorTwo.WasCalled.Should().BeTrue();
            interceptor.CallTime.Should().BeBefore(interceptorTwo.CallTime);
        }