public void Add_AddsNewNodeToElements(int add, Guid nodeId) { var counter = new PN_Counter(ImmutableHashSet <CounterElement> .Empty, ImmutableHashSet <CounterElement> .Empty); counter = counter.Add(add, nodeId); var element = counter.Additions.FirstOrDefault(e => e.Node.Id == nodeId); Assert.Equal(add, element.Value); }
public void Add_AddsToExistingElement(HashSet <CounterElement> existingElements, int add, Guid nodeId) { var existingElement = new CounterElement(999, nodeId); existingElements.Add(existingElement); var counter = new PN_Counter(existingElements.ToImmutableHashSet(), ImmutableHashSet <CounterElement> .Empty); counter = counter.Add(add, nodeId); var element = counter.Additions.FirstOrDefault(e => e.Node.Id == nodeId); Assert.Equal(999 + add, element.Value); }