protected override void OnStart(string[] args)
 {
     try {
         AppDomain.CurrentDomain.SetData("FairburnWindowsService", this);
         _Host = new WcfSelfHost(_ServiceType);
         LogEntry("Agent service host started.");
     } catch (Exception ex) {
         LogError("Service start failed." + Environment.NewLine + ex.ToString());
     }
 }
 protected override void OnStart(string[] args)
 {
     try {
         AppDomain.CurrentDomain.SetData("FairburnWindowsService", this);
         _Host = new WcfSelfHost(_ServiceType);
         LogEntry("Agent service host started.");
     } catch (Exception ex) {
         LogError("Service start failed." + Environment.NewLine + ex.ToString());
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing) {
         if (_Host != null) {
             _Host.Dispose();
             _Host = null;
         }
     }
     base.Dispose(disposing);
 }
 public void GetTaskTest_InputTestMode1_ExpectTaskRecord()
 {
     WcfSelfHost host = new WcfSelfHost(typeof(Service));
     IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task();
     var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x);
     x.Initialise(new Host(), 0);
     privateObject.SetField("_TestMode", 1);
     bool ok = Convert.ToBoolean(privateObject.Invoke("GetTask"));
     Assert.IsFalse(ok);
     host.Dispose();
     host = null;
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_Host != null)
         {
             _Host.Dispose();
             _Host = null;
         }
     }
     base.Dispose(disposing);
 }
 protected override void OnStop()
 {
     try {
         if (_Host != null) {
             _Host.Dispose();
             _Host = null;
         }
         AppDomain.CurrentDomain.SetData("FairburnWindowsService", null);
         LogEntry("Agent service host stopped.");
     } catch (Exception ex) {
         LogError("Service stop failed." + Environment.NewLine + ex.ToString());
     }
 }
 public void PostResultsTests_InputTestMode1_OutputSuccess()
 {
     WcfSelfHost host = new WcfSelfHost(typeof(Service));
     IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task();
     var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x);
     x.Initialise(new Host(), 0);
     PostResultsRequest req = new PostResultsRequest();
     req.TestMode = 1;
     privateObject.SetField("_Results", req);
     privateObject.Invoke("PostResults");
     //privateObject.Invoke("APrivateMethod", new object[] { param1, param2}); -- Call Private method with parameters
     host.Dispose();
     host = null;
 }
 protected override void OnStop()
 {
     try {
         if (_Host != null)
         {
             _Host.Dispose();
             _Host = null;
         }
         AppDomain.CurrentDomain.SetData("FairburnWindowsService", null);
         LogEntry("Agent service host stopped.");
     } catch (Exception ex) {
         LogError("Service stop failed." + Environment.NewLine + ex.ToString());
     }
 }
        public void GetTaskTest_InputTestMode1_ExpectTaskRecord()
        {
            WcfSelfHost host = new WcfSelfHost(typeof(Service));

            IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task();
            var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x);

            x.Initialise(new Host(), 0);
            privateObject.SetField("_TestMode", 1);
            bool ok = Convert.ToBoolean(privateObject.Invoke("GetTask"));

            Assert.IsFalse(ok);
            host.Dispose();
            host = null;
        }
        public void PostResultsTests_InputTestMode1_OutputSuccess()
        {
            WcfSelfHost host = new WcfSelfHost(typeof(Service));

            IET.Inspec.Fairburn.AgentTemplate.Task x = new IET.Inspec.Fairburn.AgentTemplate.Task();
            var privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(x);

            x.Initialise(new Host(), 0);
            PostResultsRequest req = new PostResultsRequest();

            req.TestMode = 1;
            privateObject.SetField("_Results", req);
            privateObject.Invoke("PostResults");
            //privateObject.Invoke("APrivateMethod", new object[] { param1, param2}); -- Call Private method with parameters
            host.Dispose();
            host = null;
        }
 public void MyTestCleanup()
 {
     _Host.Dispose();
     _Host = null;
 }
 public void MyTestInitialize()
 {
     _Host = new WcfSelfHost(typeof(Service));
 }
 public void MyTestInitialize()
 {
     _Host = new WcfSelfHost(typeof(Service));
 }
 public void MyTestCleanup()
 {
     _Host.Dispose();
     _Host = null;
 }