Ejemplo n.º 1
0
        public void Add()
        {
            var worker = Substitute.For <IBackgroundWorker>();

            using var manager = new BackgroundWorkerManager();
            manager.Add(worker);
            manager.BackgroundWorkers.ShouldHaveSingleItem().ShouldBe(worker);
            worker.Received(0).StartAsync();
        }
Ejemplo n.º 2
0
        public void AddByStarted()
        {
            var worker = Substitute.For <IBackgroundWorker>();

            using var manager = new BackgroundWorkerManager();
            Shouldly.Should.NotThrow(() => manager.StartAsync());
            manager.Add(worker);
            manager.BackgroundWorkers.ShouldHaveSingleItem().ShouldBe(worker);
            worker.Received(1).StartAsync();
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            var worker  = Substitute.For <IBackgroundWorker>();
            var manager = new BackgroundWorkerManager();

            manager.Add(worker);
            manager.BackgroundWorkers.ShouldHaveSingleItem().ShouldBe(worker);
            worker.Received(0).StopAsync();
            Shouldly.Should.NotThrow(() => manager.Dispose());
            worker.Received(0).StopAsync();
        }