public void SetSlotCountShouldSetSlotLength() { RepositoryRing ring = new RepositoryRing(); ring.SetArcCount(2); Expect.AreEqual(2, ring.Arcs.Length); }
public void AddComputeNodeShouldAddSlot() { int slotCount = RandomNumber.Between(8, 16); RepositoryRing ring = new RepositoryRing(slotCount); ring.AddArc(new RepositoryService()); Expect.AreEqual(slotCount + 1, ring.Arcs.Length); PrintSlots(ring); }
private static void PrintSlots(RepositoryRing ring) { ring.Arcs.Each((s, i) => { OutLineFormat("Slot {0}", ConsoleColor.Blue, i); OutLineFormat("\tstart angle: {0}", ConsoleColor.White, s.StartAngle); OutLineFormat("\t end angle: {0}", ConsoleColor.Yellow, s.EndAngle); OutLineFormat("\tstart key: {0}", ConsoleColor.Cyan, s.Keyspace.Start); OutLineFormat("\t end key: {0}", ConsoleColor.Cyan, s.Keyspace.End); }); }
public void SlotShouldMakeFullCircleAfterInit13() { RepositoryRing ring = new RepositoryRing(); int slotCount = 13; //RandomNumber.Between(8, 16); ring.SetArcCount(slotCount); PrintSlots(ring); Expect.AreEqual(slotCount, ring.Arcs.Length); double fullCircle = 360; double endAngle = ring.Arcs[ring.Arcs.Length - 1].EndAngle; Expect.AreEqual(fullCircle, endAngle); }
public void SetSlotCountShouldKeepExistingSlots() { Before(); RepositoryRing ring = new RepositoryRing(); RepositoryService node = new RepositoryService(); ring.AddArc(node); Expect.AreEqual(1, ring.Arcs.Length); RepositoryService check = (RepositoryService)ring.Arcs[0].GetServiceProvider(); Expect.IsNotNull(check); ring.SetArcCount(3); Expect.AreEqual(3, ring.Arcs.Length); check = (RepositoryService)ring.Arcs[0].GetServiceProvider(); PrintSlots(ring); After(); }