示例#1
0
        public void Init()
        {
            var mockCalculatorsFactory = new Mock <ICalculatorsFactory>();

            mockCalculatorsFactory.Setup(s => s.GetInstance("Normal Item")).Returns(new NormalItemCalculator());

            sut = new StockUpdater(mockCalculatorsFactory.Object);
        }
 // Method		: RunBtn_Click
 // Description	: Starts/Stops thread and updates button for control
 // Parameters	: Generic sender information
 // Returns		: None
 private void RunBtn_Click(object sender, EventArgs e)
 {
     // If the application is currently running an update loop
     if (loop)
     {
         // Shut it off and allow option to start
         RunBtn.Text = "START";
         StockUpdater.CancelAsync();
         loop = false;
     }
     else
     {
         // Turn it on and allow option to finish
         RunBtn.Text = "STOP";
         StockUpdater.RunWorkerAsync();
         loop = true;
     }
 }
示例#3
0
        static async Task Main(string[] args)
        {
            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

            Action <string> consoleLog = Console.WriteLine;

            timeTracker = new TimeTracker();

            stockUpdater = new StockUpdater();

            stockUpdater.Subscribe(timeTracker, UpdateStock);

            vinylTracker = new VinylTracker();

            vinylObserver = new VinylObserver();

            vinylObserver.Subscribe(vinylTracker, (x) => { _ = CurrentConnection.SendAsync(MessageParser.Create("OnNext", x, x.GetType().Name)); });

            await CreateServer();
        }