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