public void CanReserveIsConsistentAccrossReplays(Capacity sut, Guid id) { var remaining = sut.Remaining; sut.Reserve(remaining, id); var result = sut.CanReserve(remaining, id); Assert.True(result); }
public void ConsumeDoesNotForwardReplayedEvent( [Frozen]Mock<ICapacityRepository> repositoryMock, [Frozen]Mock<IChannel<CapacityReservedEvent>> capacityChannelMock, [Frozen]Mock<IChannel<SoldOutEvent>> soldOutChannelMock, CapacityGate sut, RequestReservationCommand command, Capacity originalCapacity) { var requestWithinCapacity = command.WithQuantity(originalCapacity.Remaining - 1); var newCapacity = originalCapacity.Reserve(requestWithinCapacity.ReserveCapacity()); repositoryMock .Setup(r => r.Read(command.Date.Date)) .Returns(new[] { newCapacity }); sut.Consume(requestWithinCapacity); repositoryMock.Verify(r => r.Write(requestWithinCapacity.Date.Date, It.IsAny<CapacityReservedEvent>()), Times.Never()); capacityChannelMock.Verify(r => r.Send(It.IsAny<CapacityReservedEvent>()), Times.Never()); soldOutChannelMock.Verify(r => r.Send(It.IsAny<SoldOutEvent>()), Times.Never()); }
public void ReserveReturnsEquivalentInstanceWhenReplayed(Guid id, int quantity, Capacity sut) { var expected = sut.Reserve(quantity, id); var result = sut.Reserve(quantity, id); Assert.Equal(expected, result); }
public void ReserveDoesNotThrowWhenQuantityIsLessThanRemaining(Capacity sut, Guid id) { var lesserQuantity = sut.Remaining - 1; Assert.DoesNotThrow(() => sut.Reserve(lesserQuantity, id)); }
public void ReserveDoesNotThrowWhenQuantityIsEqualToRemaining(Capacity sut, Guid id) { Assert.DoesNotThrow(() => sut.Reserve(sut.Remaining, id)); }
public void ReserveDoesNotHaveSideEffects(Guid id, int quantity, Capacity sut) { var result = sut.Reserve(quantity, id); Assert.NotEqual(result, sut); }
public void ReserveThrowsWhenQuantityIsGreaterThanRemaining(Capacity sut, Guid id) { var greaterQuantity = sut.Remaining + 1; Assert.Throws<ArgumentOutOfRangeException>(() => sut.Reserve(greaterQuantity, id)); }
public void ReserveReturnsInstanceWithWithoutDecrementingRemainingWhenIdAlreadyExists([Frozen]Guid[] ids, int quantity, Capacity sut) { var existingId = ids.First(); var expectedRemaining = sut.Remaining; var result = sut.Reserve(quantity, existingId); Assert.Equal(expectedRemaining, result.Remaining); }
public void ReserveReturnsInstanceWithCorrectlyDecrementedRemaining(Guid id, int quantity, Capacity sut) { var expected = sut.Remaining - quantity; var result = sut.Reserve(quantity, id); Assert.Equal(expected, result.Remaining); }