Ejemplo n.º 1
0
        public void SetSlotCountShouldSetSlotLength()
        {
            RepositoryRing ring = new RepositoryRing();

            ring.SetArcCount(2);
            Expect.AreEqual(2, ring.Arcs.Length);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
     });
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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();
        }