Пример #1
0
        static void Main(string[] args)
        {
            var sdk = new CraftDevice();

            sdk.Connect(Process.GetCurrentProcess(), ApplicationId).Wait();
            sdk.CrownTouched += OnCrownTouched;
            sdk.CrownTurned  += OnCrownTurned;

            Console.WriteLine("Press A to select Tool A");
            Console.WriteLine("Press B to select Tool B");
            Console.WriteLine("Use the Craft keyboard Crownd");
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.A:
                    sdk.ChangeTool("ToolA").Wait();
                    break;

                case ConsoleKey.B:
                    sdk.ChangeTool("ToolB").Wait();
                    break;
                }
            }while (key.Key != ConsoleKey.Escape);

            sdk.Disconnect();
        }
Пример #2
0
        public void GetByID_OneItem_ReturnsCraftDevice()
        {
            // Arrange
            CraftDevice entity = new CraftDevice {
                ID = 1
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity));

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(1));
        }
Пример #3
0
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            CraftDevice entity1 = new CraftDevice {
                ID = 1
            };
            CraftDevice entity2 = new CraftDevice {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity2));

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(1));
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
Пример #4
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            CraftDevice entity1 = new CraftDevice {
                ID = 1
            };
            CraftDevice entity2 = new CraftDevice {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <CraftDevice>(entity1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
Пример #5
0
        public void GetByID_NoItems_ThrowsKeyNotFoundException()
        {
            // Arrange
            CraftDevice entity1 = new CraftDevice {
                ID = 1
            };
            CraftDevice entity2 = new CraftDevice {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <CraftDevice>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <CraftDevice>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <CraftDevice>(entity2));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(2); });
        }