Exemplo n.º 1
0
 public void OpenDrawer()
 {
     try
     {
         if (srPort.IsOpen)
         {
             LogAdapter.Info("Cash drawer port now opening", "CashDrawer", "OpenDrawer");
             srPort.Write("open");
             srPort.Close();
             LogAdapter.Info("Cash drawer now closed", "CashDrawer", "OpenDrawer");
         }
         else
         {
             LogAdapter.Info("Cash drawer port still closed", "CashDrawer", "OpenDrawer");
         }
     }
     catch (Exception ex) {
         LogAdapter.Error(ex.Message, "CashDrawer", "OpenDrawer");
         if (srPort.IsOpen)
         {
             LogAdapter.Info("Cash drawer port open", "CashDrawer", "OpenDrawer Inside Catch");
             srPort.Close();
             LogAdapter.Info("Cash drawer port closed", "CashDrawer", "OpenDrawer Inside Catch");
         }
     }
 }
Exemplo n.º 2
0
 public RTCashDrawer()
 {
     try
     {
         srPort = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);
         if (!srPort.IsOpen)
         {
             srPort.Open();
         }
     }catch (Exception ex) {
         LogAdapter.Error(ex.Message, "CashDrawer", "Constructor");
     }
 }
Exemplo n.º 3
0
 public PoleDisplay()
 {
     try
     {
         srPort = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
         if (!srPort.IsOpen)
         {
             srPort.Open();
         }
     }
     catch (Exception Ex) {
         LogAdapter.Error(Ex.Message, "PoleDisplay", "Constructor");
     }
 }
        public void SimpleCoverage()
        {
            var innerMessage = "";

            var inner = new TestLogger();
            var adapter = new LogAdapter(inner);
            inner.MethodCalled += (s, e) =>
            {
                innerMessage = e.Message;
            };
            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            Assert.AreEqual("Debug(object message)", innerMessage);



            // Debug Object, Exception
            adapter.Debug(obj, exception);
            Assert.AreEqual("Debug(object message, Exception exception)", innerMessage);





            // Error Object
            adapter.Error(obj);
            Assert.AreEqual("Error(object message)", innerMessage);

            // Error Object, Exception
            adapter.Error(obj, exception);
            Assert.AreEqual("Error(object message, Exception exception)", innerMessage);





            // Fatal Object
            adapter.Fatal(obj);
            Assert.AreEqual("Fatal(object message)", innerMessage);

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            Assert.AreEqual("Fatal(object message, Exception exception)", innerMessage);







            // Info Object
            adapter.Info(obj);
            Assert.AreEqual("Info(object message)", innerMessage);

            // Info Object, Exception
            adapter.Info(obj, exception);
            Assert.AreEqual("Info(object message, Exception exception)", innerMessage);



            // Trace Object
            adapter.Trace(obj);
            Assert.AreEqual("Trace(object message)", innerMessage);

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            Assert.AreEqual("Trace(object message, Exception exception)", innerMessage);


            



            // Warn Object
            adapter.Warn(obj);
            Assert.AreEqual("Warn(object message)", innerMessage);

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            Assert.AreEqual("Warn(object message, Exception exception)", innerMessage);



        }
        public void MockedCoverage()
        {

            var inner = MockRepository.GenerateMock<TestLogger>();


            var adapter = new LogAdapter(inner);

            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            inner.AssertWasCalled(i => i.Debug(obj));


            // Debug Object, Exception
            adapter.Debug(obj, exception);
            inner.AssertWasCalled(i => i.Debug(obj, exception));


 
            // Error Object
            adapter.Error(obj);
            inner.AssertWasCalled(i => i.Error(obj));

            // Error Object, Exception
            adapter.Error(obj, exception);
            inner.AssertWasCalled(i => i.Error(obj, exception));

 


            // Fatal Object
            adapter.Fatal(obj);
            inner.AssertWasCalled(i => i.Fatal(obj));

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            inner.AssertWasCalled(i => i.Fatal(obj, exception));

 




            // Info Object
            adapter.Info(obj);
            inner.AssertWasCalled(i => i.Info(obj));

            // Info Object, Exception
            adapter.Info(obj, exception);
            inner.AssertWasCalled(i => i.Info(obj, exception));

 


            // Trace Object
            adapter.Trace(obj);
            inner.AssertWasCalled(i => i.Trace(obj));

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            inner.AssertWasCalled(i => i.Trace(obj, exception));

      



            // Warn Object
            adapter.Warn(obj);
            inner.AssertWasCalled(i => i.Warn(obj));

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            inner.AssertWasCalled(i => i.Warn(obj, exception));

 
            
        }