public void Test_increment_IncrementsTheCounter() { SequenceCounter counter = new SequenceCounter(); Assert.Equal("0", counter.AsString()); counter.Increment(); Assert.Equal("1", counter.AsString()); counter.Increment(); Assert.Equal("2", counter.AsString()); }
public void Test_counter_WhenThereIsOneParent() { SequenceCounter parent = new SequenceCounter(); parent.Increment(); Assert.AreEqual("1", parent.AsString()); SequenceCounter child = new SequenceCounter(parent); child.Increment(); Assert.AreEqual("1.1", child.AsString()); child.Increment(); Assert.AreEqual("1.2", child.AsString()); }
public virtual string AsString() { if (Parent == null) { return("" + Sequence); } else { return(Parent.AsString() + "." + Sequence); } }
public void Test_counter_WhenThereAreTwoParents() { SequenceCounter parent = new SequenceCounter(); parent.Increment(); Assert.AreEqual("1", parent.AsString()); SequenceCounter child = new SequenceCounter(parent); child.Increment(); Assert.AreEqual("1.1", child.AsString()); SequenceCounter grandchild = new SequenceCounter(child); grandchild.Increment(); Assert.AreEqual("1.1.1", grandchild.AsString()); grandchild.Increment(); Assert.AreEqual("1.1.2", grandchild.AsString()); }
internal string GetNext() { _counter.Increment(); return(_counter.AsString()); }