Exemple #1
0
        private void Start <T>()
            where T : TestBaseModule, new ()
        {
            //Create container
            using ManualResetEventSlim initializedTrigger = new(false);
            scenarioContext.Set(initializedTrigger, StringConstants.InitializedMessageReceived);
            ContainerBuilder builder = new();

            builder.RegisterModule <T>();
            builder.RegisterInstance(scenarioContext);
            IContainer container = builder.Build();

            //Start agent community
            Action startAction = () =>
            {
                IMessageBoard messageBoard = container.Resolve <IMessageBoard>();
                Agent[]       agents       = container.Resolve <IEnumerable <Agent> >().ToArray();
                messageBoard.Register(agents);
                messageBoard.Start();

                scenarioContext.Set(container);
                scenarioContext.Set(messageBoard);
                scenarioContext.Set(container.Resolve <FileSystemSimulator>());
            };

            startAction.Should().NotThrow <Exception>("agent community was not created.");
            initializedTrigger.Wait();
        }
Exemple #2
0
        public void Setup()
        {
            messageBoard = new MessageBoard();
            SpinWaiter waiter = new SpinWaiter(messageBoard, () => finishedEvent.Set(), false);

            messageBoard.Register(waiter);
            messageBoard.Start();
            File.Delete("log.json");
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Verbose()
                         .WriteTo.Async(l => l.File(new CompactJsonFormatter(), "log.json"))
                         .CreateLogger();
        }
        public void Setup()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterModule(new ParallelThreadSleepModule(() =>
            {
                finishedEvent.Set();
            }));
            container    = builder.Build();
            messageBoard = container.Resolve <IMessageBoard>();
            Agent[] agents = container.Resolve <IEnumerable <Agent> >().ToArray();
            messageBoard.Register(agents);
            messageBoard.Start();
        }
Exemple #4
0
 public void Setup()
 {
     {
         messageBoard = new MessageBoard();
         SpinWaiter waiter = new SpinWaiter(messageBoard, () => finishedEvent.Set(), false);
         messageBoard.Register(waiter);
         messageBoard.Start();
     }
     {
         messageBoardReuse = new MessageBoard();
         SpinWaiter waiter = new SpinWaiter(messageBoardReuse, () => finishedEventReuse.Set(), true);
         messageBoardReuse.Register(waiter);
         messageBoardReuse.Start();
     }
 }
 private void SetupCommunities()
 {
     {
         ContainerBuilder builder = new ContainerBuilder();
         builder.RegisterModule(new FileManipulationModule(() => { finishedEvent.Set(); }));
         container    = builder.Build();
         messageBoard = container.Resolve <IMessageBoard>();
         Agent[] agents = container.Resolve <IEnumerable <Agent> >().ToArray();
         messageBoard.Register(agents);
         messageBoard.Start();
     }
     {
         ContainerBuilder builder = new ContainerBuilder();
         builder.RegisterModule(new ParallelForEachModule(() => { parallelForEachFinishedEvent.Set(); }));
         parallelForEachContainer    = builder.Build();
         parallelForEachMessageBoard = parallelForEachContainer.Resolve <IMessageBoard>();
         Agent[] agents = parallelForEachContainer.Resolve <IEnumerable <Agent> >().ToArray();
         parallelForEachMessageBoard.Register(agents);
         parallelForEachMessageBoard.Start();
     }
 }