public void SetupCheckedBets_ShouldSetCorrectLosingBetAccountBalance_WithValidParams(string inputString, FinalResultMarks finalResultMark) { this.ResetParams(); var account = new BetfairAccount(this.accountName, this.accountBalance, this.accountCurrency, this.accountRake); var line = new BetLine(account, this.lineName, this.lineStepAmount, this.decreasingStepValue); var bet = new RegularBet(this.mockedMatch.Object, line, finalResultMark.ToString(), this.amount, this.coefficient, this.mockedTipster.Object); var mockedResult = new Mock <IFinalResult>(); mockedResult.Reset(); mockedResult.Setup(r => r.GetMark()).Returns(inputString); this.mockedMatch.Setup(m => m.Results).Returns(new Dictionary <ResultType, IResult>() { [ResultType.Final] = mockedResult.Object }); var collectionOfBets = new List <IBet>() { bet }; var betController = new BetController(); betController.SetupCheckedBets(collectionOfBets); Assert.AreEqual(startAccountValue - this.amount, bet.Line.Account.Balance); }
public void SetupCheckedBets_ShouldSetBetCheckedProperty_WithValidParams() { this.ResetParams(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var bet = new RegularBet(this.mockedMatch.Object, this.mockedLine.Object, mark.ToString(), this.amount, this.coefficient, this.mockedTipster.Object); var mockedResult = new Mock <IFinalResult>(); mockedResult.Setup(r => r.GetMark()).Returns("_1"); this.mockedMatch.Setup(m => m.Results).Returns(new Dictionary <ResultType, IResult>() { [ResultType.Final] = mockedResult.Object }); var collectionOfBets = new List <IBet>() { bet }; var betController = new BetController(); betController.SetupCheckedBets(collectionOfBets); Assert.IsTrue(bet.IsChecked); }
public void SetupCheckedBets_ShouldSetWinningBetFalse_WithValidParams(string inputString, FinalResultMarks finalResultMark) { this.ResetParams(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); var bet = new RegularBet(this.mockedMatch.Object, this.mockedLine.Object, finalResultMark.ToString(), this.amount, this.coefficient, this.mockedTipster.Object); var mockedResult = new Mock <IFinalResult>(); mockedResult.Setup(r => r.GetMark()).Returns(inputString); this.mockedMatch.Setup(m => m.Results).Returns(new Dictionary <ResultType, IResult>() { [ResultType.Final] = mockedResult.Object }); var collectionOfBets = new List <IBet>() { bet }; var betController = new BetController(); betController.SetupCheckedBets(collectionOfBets); Assert.IsFalse(bet.IsWin); }
public void Constructor_ShouldPass_withValidParams() { this.ResetParameters(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); var regularBet = new RegularBet(this.mockedMatch, this.mockedLine.Object, "_1", 1, 1, this.mockedTipster); Assert.IsInstanceOf <RegularBet>(regularBet); }
public void GetResultType_CorrectlySetResultTypeByConstructor() { this.ResetParameters(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var regularBet = new RegularBet(this.mockedMatch, this.mockedLine.Object, this.mark, this.amount, this.coefficient, this.mockedTipster); Assert.AreEqual(regularBet.ResultType, ResultType.Final); }
public void SetupBalance_ShouldIncreaseAccountBalance_WithWinningBet() { this.ResetParameters(); this.mockedLine.Setup(x => x.Account.Balance).Returns(this.AccountBalance); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var regularBet = new RegularBet(this.mockedMatch, this.mockedLine.Object, this.mark, this.amount, this.coefficient, this.mockedTipster); regularBet.IsWin = true; Assert.IsTrue(regularBet.Line.Account.Balance > this.AccountBalance); }
public void SetupBalance_ShouldThrowArgumentException_WithUncheckedBet() { this.ResetParameters(); this.mockedLine.Setup(x => x.Account.Balance).Returns(this.AccountBalance); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var regularBet = new RegularBet(this.mockedMatch, this.mockedLine.Object, this.mark, this.amount, this.coefficient, this.mockedTipster); regularBet.IsChecked = false; Assert.That( () => regularBet.SetupBalances(), Throws.ArgumentException.With.Message.Contains(EngineConstants.NotCheckedBetErrorMessage)); }
public void Constructor_ShouldAddRegularBet_WhenAddRegularBetWithMatchWithHalfTimeResult() { this.ResetParams(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var mockedResult = new Mock <IResult>(); this.mockedMatch.Setup(m => m.Results).Returns(new Dictionary <ResultType, IResult>() { [ResultType.FirstHalf] = mockedResult.Object }); var regularBet = new RegularBet(this.mockedMatch.Object, this.mockedLine.Object, mark.ToString(), this.amount, this.coefficient, this.mockedTipster.Object); Assert.IsInstanceOf <RegularBet>(regularBet); }
public void SetupCheckedBets_ShouldSetBetCheckedPropertyFalse_WithMatchWithoutResults() { this.ResetParams(); this.mockedLine.Setup(x => x.Account.Balance).Returns(100m); this.mockedLine.Setup(x => x.LeftValueToBeBet()).Returns(this.lineValueToBeWin); var firstBet = new RegularBet(this.mockedMatch.Object, this.mockedLine.Object, mark.ToString(), this.amount, this.coefficient, this.mockedTipster.Object); var collectionOfBets = new List <IBet>() { firstBet }; var betController = new BetController(); betController.SetupCheckedBets(collectionOfBets); Assert.IsFalse(firstBet.IsChecked); }