示例#1
0
        private void Reciever()
        {
            bool once = true;


            while (_cont)
            {
                recieverHandler = Import.CreateFile(
                    "\\\\.\\pipe\\ParkingFinePipe",
                    Types.EFileAccess.GenericRead,
                    Types.EFileShare.Read,
                    0,
                    Types.ECreationDisposition.OpenExisting,
                    0,
                    0);

                if (once)
                {
                }

                byte[] buff        = new byte[64];
                uint   bytesToRead = 0;

                if (Import.ReadFile(recieverHandler, buff, Convert.ToUInt32(buff.Length), ref bytesToRead, 0))         // выполняем запись последовательности байт в канал
                {
                    if (bytesToRead > 1)
                    {
                        string message = Encoding.Unicode.GetString(buff);
                        string cutted  = message.Substring(0, (int)(bytesToRead / 2));

                        UpdateCalled?.Invoke(cutted);
                    }
                }
                if (Import.CloseHandle(recieverHandler))
                {
                    recieverHandler = -1;
                }

                Thread.Sleep(100);
            }
        }
        public SelfUpdateService(bool isSelfUpdate, Package updatePackage)
        {
            Mock <ISelfUpdateService> mock = new Mock <ISelfUpdateService>();

            mock
            .SetupGet(s => s.IsSelfUpdate)
            .Callback(() => IsSelfUpdateCalled.Increment())
            .Returns(isSelfUpdate);

            mock
            .Setup(s => s.Update(It.Is <IPackage>(p => p == UpdatePackages[UpdateCalled])))
            .Callback(() => UpdateCalled.Increment());

            mock
            .Setup(s => s.RunNewInstance(It.Is <IPackage>(p => p == UpdatePackages[RunNewInstanceCalled])))
            .Callback(() => RunNewInstanceCalled.Increment());

            if (updatePackage != null)
            {
                UpdatePackages.Add(updatePackage.Object);
            }

            Object = mock.Object;
        }
 public void Update()
 {
     UpdateCalled.Invoke();
 }