public AtmMachine(IWithdrawalStrategy withdrawalStrategy, IAtmInventory atmInventory) { if (withdrawalStrategy == null) { throw new ArgumentNullException(nameof(withdrawalStrategy)); } if (atmInventory == null) { throw new ArgumentNullException(nameof(atmInventory)); } _withdrawalStrategy = withdrawalStrategy; _atmInventory = atmInventory; }
public void ConstructWithNullWithdrawalStrategyShouldThrow() { // Arrange IWithdrawalStrategy testWithdrawalStrategy = null; var testInventory = new Moq.Mock <IAtmInventory>(); // Act var actualException = Assert.Throws <ArgumentNullException>(() => { #pragma warning disable RECS0026 // Possible unassigned object created by 'new' new ATMMachine.Entities.AtmMachine(testWithdrawalStrategy, testInventory.Object); #pragma warning restore RECS0026 // Possible unassigned object created by 'new' }); // Assert Assert.Contains("Value cannot be null", actualException.Message); }