public void CompletedEvent() { // Arrange bool premature = true; bool eventFired = false; OperationCounter ops = new OperationCounter(); ops.Completed += (sender, eventArgs) => { if (premature) { Assert.True(false, "Event fired too early!"); } if (eventFired) { Assert.True(false, "Event fired multiple times."); } Assert.Equal(ops, sender); Assert.Equal(eventArgs, EventArgs.Empty); eventFired = true; }; // Act & assert ops.Increment(); // should not fire event (will throw exception) premature = false; ops.Decrement(); // should fire event Assert.True(eventFired); ops.Increment(); // should not fire event (will throw exception) }
public void CompletedEvent() { // Arrange bool premature = true; bool eventFired = false; OperationCounter ops = new OperationCounter(); ops.Completed += (sender, eventArgs) => { if (premature) { Assert.True(false, "Event fired too early!"); } if (eventFired) { Assert.True(false, "Event fired multiple times."); } Assert.Equal(ops, sender); Assert.Equal(eventArgs, EventArgs.Empty); eventFired = true; }; // Act & assert ops.Increment(); // should not fire event (will throw exception) premature = false; ops.Decrement(); // should fire event Assert.True(eventFired); ops.Increment(); // should not fire event (will throw exception) }
public void IncrementWithIntegerArgument() { // Arrange OperationCounter ops = new OperationCounter(); // Act int returned = ops.Increment(3); int newCount = ops.Count; // Assert Assert.AreEqual(3, returned); Assert.AreEqual(3, newCount); }
public void IncrementWithNoArguments() { // Arrange OperationCounter ops = new OperationCounter(); // Act int returned = ops.Increment(); int newCount = ops.Count; // Assert Assert.Equal(1, returned); Assert.Equal(1, newCount); }
public void IncrementWithIntegerArgument() { // Arrange OperationCounter ops = new OperationCounter(); // Act int returned = ops.Increment(3); int newCount = ops.Count; // Assert Assert.AreEqual(3, returned); Assert.AreEqual(3, newCount); }
public void Increment() { var exepectedCounts = new Dictionary <TrackedOperation, int> { { TrackedOperation.Create, 0 }, { TrackedOperation.Read, 3 }, { TrackedOperation.List, 1 }, { TrackedOperation.Update, 7 }, { TrackedOperation.Delete, 3 } }; foreach (var entry in exepectedCounts) { for (var i = 0; i < entry.Value; i++) { _counter.Increment(entry.Key); } } Assert.Equal(exepectedCounts, _counter.GetCounts); }
public void Increment() { var exepectedCounts = new Dictionary <TrackedOperation, int> { { TrackedOperation.Create, 1 }, //had to change this from 0 otherwise test would fail (inner for wouldn't be triggered) { TrackedOperation.Read, 3 }, { TrackedOperation.List, 1 }, { TrackedOperation.Update, 7 }, { TrackedOperation.Delete, 3 } }; foreach (var entry in exepectedCounts) { for (var i = 0; i < entry.Value; i++) { _counter.Increment(entry.Key); } } Assert.Equal(exepectedCounts, _counter.GetCounts); }
public void IncrementWithNoArguments() { // Arrange OperationCounter ops = new OperationCounter(); // Act int returned = ops.Increment(); int newCount = ops.Count; // Assert Assert.Equal(1, returned); Assert.Equal(1, newCount); }