Ejemplo n.º 1
0
        public void IsDisposable()
        {
            var disposable = new BooRepository(null, null);

            Assert.True(ReflectionUtils.IsDisposable(disposable, out _));
            Assert.True(ReflectionUtils.IsDisposableType(disposable.GetType()));
        }
Ejemplo n.º 2
0
        public void DisposeValuesIfDisposable_Array()
        {
            var collection    = new IRepository[1];
            var booRepository = new BooRepository(null, null);

            collection[0] = booRepository;

            CollectionUtils.DisposeValuesIfDisposable(collection);
            Assert.True(booRepository.Disposed);
        }
Ejemplo n.º 3
0
        public void DisposeValuesIfDisposable_Dictionary()
        {
            var collection    = new Dictionary <int, IRepository>();
            var booRepository = new BooRepository(null, null);

            collection.Add(1, booRepository);

            CollectionUtils.DisposeValuesIfDisposable(collection);
            Assert.True(booRepository.Disposed);
        }
Ejemplo n.º 4
0
        public void DisposeValuesIfDisposable_List()
        {
            var collection    = new List <IRepository>();
            var booRepository = new BooRepository(null);

            collection.Add(booRepository);

            CollectionUtils.DisposeValuesIfDisposable(collection);

            booRepository.Disposed.Should().BeTrue();
        }
Ejemplo n.º 5
0
        public void DisposeValuesIfDisposable_Array()
        {
            var collection    = new IRepository[1];
            var booRepository = new BooRepository(null);

            collection[0] = booRepository;

            CollectionUtils.DisposeValuesIfDisposable(collection);

            booRepository.Disposed.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public void DisposeValuesIfDisposable_ConcurrentDictionary()
        {
            var collection    = new ConcurrentDictionary <int, IRepository>();
            var booRepository = new BooRepository(null);

            collection.TryAdd(1, booRepository);

            CollectionUtils.DisposeValuesIfDisposable(collection);

            booRepository.Disposed.Should().BeTrue();
        }
Ejemplo n.º 7
0
        public void Init()
        {
            var repository = new BooRepository(null, null);

            _queries       = new Query[Count];
            _queriesStruct = new Ping[Count];

            _requests       = new GetBooRequest[Count];
            _requestsStruct = new StructRequest[Count];

            for (var i = 0; i < Count; i++)
            {
                repository.AddElement(new Boo {
                    Id = i, Int = i
                });

                _queries[i]       = new Query(i);
                _queriesStruct[i] = new Ping(i);

                _requests[i] = new GetBooRequest {
                    Id = i
                };
                _requestsStruct[i] = new StructRequest(i.ToString());
            }

            _mediator = MediatorBuilder.BuildMediatR(repository);

            _mediatorWithBehaviour = MediatorBuilder.BuildMediatR(repository, services =>
                                                                  services.AddSingleton <GetBooRequestBehaviour>());

            _mediatorWithFullPipeline = MediatorBuilder.BuildMediatR(repository, services =>
                                                                     services
                                                                     .AddSingleton(typeof(IPipelineBehavior <,>), typeof(RequestPreProcessorBehavior <,>))
                                                                     .AddSingleton(typeof(IPipelineBehavior <,>), typeof(RequestPostProcessorBehavior <,>))
                                                                     .AddSingleton <IPipelineBehavior <GetBooRequest, Boo>, GetBooRequestBehaviour>()
                                                                     .AddSingleton <IRequestPreProcessor <GetBooRequest>, GetBooPreProcessor>()
                                                                     .AddSingleton <IRequestPostProcessor <GetBooRequest, Boo>, GetBooPostProcessor>());

            _emitter = _emitterWithBehaviour = MediatorBuilder.BuildEmitter(repository);

            _emitterWithBehaviour = MediatorBuilder.BuildEmitter(repository, services =>
                                                                 services.AddQueryBehaviour <Behaviour>());

            _emitterWithFullPipeline = MediatorBuilder.BuildEmitter(repository, services =>
                                                                    services
                                                                    .AddQueryBehaviour <Behaviour>()
                                                                    .AddQueryProcessor <PreProcessor>()
                                                                    .AddQueryProcessor <PostProcessor>());
        }
        public void Init()
        {
            _emitterNotifications  = new PlusNotification[Count];
            _mediatorNotifications = new Notification[Count];

            for (var i = 0; i < Count; i++)
            {
                _emitterNotifications[i]  = new PlusNotification();
                _mediatorNotifications[i] = new Notification();
            }

            var repository = new BooRepository(null, null);

            _mediator = MediatorBuilder.BuildMediatR(repository, services => services
                                                     .AddSingleton <INotificationHandler <Notification>, NotificationHandler>(), 5);

            _emitter = MediatorBuilder.BuildEmitter(repository, services => services
                                                    .AddNotificationProcessor <PlusNotificationProcessor>(), 5);
        }