public void Test_EventManager() { // Prepare IEventManager manager = this.GetService <IEventManager>(); manager.Start(); ISignalService signals = this.GetService <ISignalService>(); signals.Truncate(); int countBefore = signals.Count(); // Pre-validate // Perform List <string> data = new List <string>(); for (int i = 0; i < 100; i++) { data.Add("{ guid: \"" + Guid.NewGuid().ToString() + "\"}"); } foreach (string signal in data) { manager.RegisterEvent(Signal.New("fooDevice", signal, DateTime.Now)); Thread.Sleep(5); } Thread.Sleep(10 * 1000); // Wait while manager save data to the end // Post-validate int countAfter = signals.Count(); Assert.Equal(0, countAfter); manager.Stop(); }
public void Test_Service_AddScope() { // Prepare ISignalService signals = this.GetService <ISignalService>(); int countBefore = signals.Count(); // Pre-validate // Perform List <Signal> newSignals = new List <Signal>() { Signal.New("fooDevice", "foo", DateTime.Now), Signal.New("barDevice", "bar", DateTime.Now.AddSeconds(1)), Signal.New("bazDevice", "baz", DateTime.Now.AddSeconds(2)) }; signals.Add(newSignals); // Post-validate int countAfter = signals.Count(); Assert.Equal(countBefore + newSignals.Count, countAfter); }
public void Test_Service_Truncate(int rowCount) { // Prepare ISignalService signals = this.GetService <ISignalService>(); int countBefore = signals.Count(); List <Signal> scope = new List <Signal>(); for (int i = 0; i < rowCount; i++) { scope.Add(Signal.New("fooDevice", "foo", DateTime.Now)); } signals.Add(scope); // Pre-validate Assert.Equal(rowCount + countBefore, signals.Count()); // Perform signals.Truncate(); // Post-validate Assert.Equal(0, signals.Count()); }