public void TestModuleInitialized() { DummyModule.InitializeService(); var module = MobileCore.Instance.GetInstance <IDummyModule>(); Assert.IsNotNull(module); Assert.AreEqual("dummy", module.Type); Assert.AreEqual("Hello world!", module.Data1); Assert.AreEqual(42, module.Data2); Assert.IsTrue(module.Data3); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { sensor = KinectSensor.GetDefault(); frameReader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared); frameReader.MultiSourceFrameArrived += FrameReader_MultiSourceFrameArrived; sensor.Open(); // create a background pipeline and pre-allocate 2 seconds of frames pipeline = new BackgroundPipeline <KinectFrame>(Kinect2Metrics.CameraRate); dummyModule = new DummyModule { IsEnabled = true }; pipeline.Modules.Add(dummyModule); pipeline.Timer.Tick += (sender, args) => { FPS = pipeline.Timer.FPS; Elapsed = pipeline.Timer.ElapsedTime; BackLog = pipeline.Count; var gc1 = GC.CollectionCount(1); var gc2 = GC.CollectionCount(2); var memory = Process.GetCurrentProcess().PrivateMemorySize64 / 100000000; Log += $"{pipeline.Timer.ElapsedTime},{RenderFPS},{FPS},{BackLog},{gc1},{gc2},{memory},{dummyModule.MeanInterval}\n"; }; pipeline.FrameStart += (sender, frame) => { }; // return the frame to the pool pipeline.FrameComplete += (sender, frame) => { frame.Dispose(); }; pipeline.QueueComplete += (sender, args) => { Console.WriteLine($"{DateTime.Now.ToString("ddMMyyyyhhmmssfffff")}: Queue Complete"); File.WriteAllText($"report-{DateTime.Now.ToString("ddMMyyyy-hhmmss")}.csv", Log); }; Start = new RelayCommand(StartPipeline, () => !pipeline.Timer.IsRunning); Stop = new RelayCommand(StopPipeline, () => pipeline.Timer.IsRunning); stopWatch = new Stopwatch(); stopWatch.Start(); RenderFPS = 0; }
public void InitModule() { //Arrange var mocks = new MockRepository(); var module = new DummyModule(); var app = mocks.StrictMock<HttpApplication>(); With.Mocks(mocks).Expecting(() => app.BeginRequest += new DelegateContainer().BeginDummy).Verify(() => MethodThatVerifiesBeginRequest(app)); With.Mocks(mocks).Expecting(() => app.EndRequest += new DelegateContainer().EndDummy).Verify(() => MethodThatVerifiesEndRequest(app)); With.Mocks(mocks).Expecting(() => app.Error += new DelegateContainer().ErrorDummy).Verify(() => MethodThatVerifiesError(app)); With.Mocks(mocks).Expecting(() => app.PostAuthenticateRequest += new DelegateContainer().PostAuthDummy).Verify(() => MethodThatVerifiesPostAuth(app)); //Act module.Init(app); //Assert module.ShouldNotBeNull(); BeginRequestVerified.ShouldBeTrue(); EndRequestVerified.ShouldBeTrue(); ErrorRequestVerified.ShouldBeTrue(); PostAuthRequestVerified.ShouldBeTrue(); }
public void Initialize() { if (Instance != null) { FormUI?.BringToFront(); WindowUI?.Activate(); return; } try { AppDomain.CurrentDomain.AssemblyResolve += _assemblyResolver; if (Type != null) { if (!typeof(IModule).IsAssignableFrom(Type)) { object instance = Activator.CreateInstance(Type); WindowUI = (instance as Window); if (WindowUI != null) { Instance = (IModule)WindowUI.DataContext; } } else { Instance = (IModule)FormatterServices.GetUninitializedObject(Type); } } else { Instance = new DummyModule(this); } Instance.Installer = App.Master; if (Type != null && WindowUI == null) { ConstructorInfo moduleConstructor = Type.GetConstructor(Type.EmptyTypes); moduleConstructor.Invoke(Instance, null); } if (App.Master.Connection.IsConnected) { Instance.Synchronize(App.Master.Game); Instance.Synchronize(App.Master.GameData); } FormUI = (Instance as Form); if (FormUI != null) { FormUI.Show(); FormUI.FormClosed += UserInterface_Closed; } else if (WindowUI != null) { WindowUI.Show(); WindowUI.Closed += UserInterface_Closed; } } catch { Dispose(); } finally { if (Instance != null) { CurrentState = INITIALIZED_STATE; } AppDomain.CurrentDomain.AssemblyResolve -= _assemblyResolver; } }