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(); }
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)); }
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)); }
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)); }
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); }); }