gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
public class PlayerBankBuilder : IBankBuilder { private readonly long minInitBalance;…
- User
public class PlayerBankBuilder : IBankBuilder { private readonly long _minInitBalance; private readonly long _maxInitBalance;
codeprivate Bank _currentInstanceOfBank; private readonly Random _rnd; public PlayerBankBuilder(long minInitBalance, long maxInitBalance) { if (minInitBalance < 1) throw new ArgumentException($"{nameof(minInitBalance)} must be positive and not 0"); if (maxInitBalance < 1) throw new ArgumentException($"{nameof(maxInitBalance)} must be positive and not 0"); if (minInitBalance > maxInitBalance) throw new ArgumentException($"{nameof(minInitBalance)} must be lower or equal {nameof(maxInitBalance)}"); _minInitBalance = minInitBalance; _maxInitBalance = maxInitBalance; _currentInstanceOfBank = new Bank(); _rnd = new Random(); } public void BuildBalance() { _currentInstanceOfBank.AddMoney(_rnd.NextInt64(_minInitBalance, _maxInitBalance)); } public Bank GetBank() { return _currentInstanceOfBank; } public void ResetInstance() { _currentInstanceOfBank = new Bank(); }} write tests xunit
- Assistant
Sure, here's an example of how you can write tests for the PlayerBankBuilder class using xUnit:
csharp