public void setup() { _sName = "PlayerX"; _uiAmount = 100; _uiColor = 0; _cbTestObj = new ColorBet(_sName,_uiAmount, _uiColor); _fsFieldStub = new FieldStub(); }
public void CreateColorBet_AddAllRedTiles_18TilesAdded() { var amount = 10; Game game = new Game(); Player player = new Player(game, 500, "Test"); Bet bet = new ColorBet(player, amount, "red"); Assert.AreEqual(18, bet.Tiles.Count); }
/// <summary> /// Constructs a dto object of the specified bet /// Checks which bet type it is and maps this to dto object. /// </summary> /// <param name="bet"></param> /// <returns></returns> private IBetDTO MakeBetDTO(IBet bet) { var info = bet.GetBetSpecificInfo(); IBetDTO output = null; if (bet.Type == BetType.Color) { if (info.TryGetValue("Color", out object temp)) { int color = (int)temp; output = new ColorBet((IPocketColor)color) { Id = bet.Id, Stake = bet.Stake, }; } } else if (bet.Type == BetType.EvenUneven) { if (info.TryGetValue("IsEven", out object temp)) { bool isEven = (bool)temp; output = new EvenUnevenBet(isEven) { Id = bet.Id, Stake = bet.Stake, }; } } else if (bet.Type == BetType.Neighbour) { if (info.TryGetValue("FirstNumber", out object temp) && info.TryGetValue("SecondNumber", out object temp2)) { int firstNumber = (int)temp; int secondNumber = (int)temp2; output = new NeighbourBet((IPocketNumber)firstNumber, (IPocketNumber)secondNumber) { Id = bet.Id, Stake = bet.Stake, }; } } else if (bet.Type == BetType.Single) { if (info.TryGetValue("Number", out object temp)) { int number = (int)temp; output = new SingleNumberBet((IPocketNumber)number) { Id = bet.Id, Stake = bet.Stake, }; } } return(output); }
public void FailPlayTest() { var bet = new ColorBet(250, _testBot, Color.Red); bet.Play(new Field(2, Color.Green)); Assert.AreEqual(1000, _testBot.Money); Assert.Pass(); }
public void SuccessPlayTest() { var bet = new ColorBet(250, _testBot, Color.Red); bet.Play(new Field(2, Color.Red)); Assert.AreEqual(1500, _testBot.Money); Assert.Pass(); }
public void PlaceBet_Enter5000Bet_TableLimitExceeded() { Game game = new Game(); game.StartTurn(); game.Table.TotalLimit = 500; Player player = new Player(game, 5000, "TestNaam"); Bet bet = new ColorBet(player, 5000, "red"); player.PlaceBet(bet); }
public void PlaceBet_Enter5Bet_BetToLow() { Game game = new Game(); game.StartTurn(); game.Table.MinimumBet = 10; Player player = new Player(game, 1000, "TestNaam"); Bet bet = new ColorBet(player, 5, "red"); player.PlaceBet(bet); }
public void ToString_Amount10ColorRed_10AndRedInString() { //Arrange ColorBet uut = new ColorBet("Otto Leisner", 10, Field.Red); //amount = 10, color = red //Act var returnValue = uut.ToString(); //Assert Assert.AreEqual("10$ color bet on red", returnValue); }
[Test] // red, black, green public void WonAmount_FieldColorIsGreenAndBetColorIsGreenAndAmountEquals10_ResultEquals20() { //Arrange ColorBet uut = new ColorBet("Otto Leisner", 10, Field.Green); //amount = 10, color = 0 Field testField = new Field(25, Field.Green); // Number = 25, Color = 0 //Act var returnValue = uut.WonAmount(testField); //Assert Assert.AreEqual(20, returnValue); }
public void WonAmount_FieldColorDoesNotEqualBetColor_ResultEqualsZero() // test for every color combination? { //Arrange ColorBet uut = new ColorBet("Otto Leisner", 10, Field.Red); //amount = 10, color = 0 Field testField = new Field(5, Field.Black); // Number = 5, Color = 1 //Act var returnValue = uut.WonAmount(testField); //Assert Assert.AreEqual(0, returnValue); }
public void GetInfo_ShouldReturnPropNameAndValue2() { // Arrange IBet bet = new ColorBet(PocketColor.Black, null) { ID = 1, Stake = 20 }; // Act var propsinfo = bet.GetInfo(); }
public void PlaceBet_Enter50Bet_Success() { Game game = new Game(); game.StartTurn(); game.Table.TotalLimit = 500; Player player = new Player(game, 5000, "TestNaam"); Bet bet = new ColorBet(player, 50, "red"); var betPlaced = player.PlaceBet(bet); Assert.AreEqual(true, betPlaced); }
public void GetInfo_ShouldReturnPropNameAndValue() { // Arrange IBetDTO bet = new ColorBet(IPocketColor.Black) { Id = 2, Stake = 20 }; // Act //IBetDAL dal = InMemRepository.CreateTestBetDAL(); //bool x = dal.Save(bet); }
public void CanBlackWin() { Field field = new Field(1, 1); var game = new RouletteGame.Legacy.RouletteGame(new FakeRoulette(field)); game.OpenBets(); Bet bet = new ColorBet("Fake Player", 100, 1); game.PlaceBet(bet); game.CloseBets(); game.SpinRoulette(); game.PayUp(); Assert.That(game.FakePayUp(bet).Equals(bet.WonAmount(field))); }
public void Setup() { _fakeOutput = Substitute.For <IOutput>(); _fakeRandomizer = Substitute.For <IRandomizer>(); _fieldFactory = new StandardFieldFactory(); _roulette = new Roulette.Roulette(_fieldFactory, _fakeRandomizer); _rouletteGame = new Game.Game(_roulette, _fakeOutput); _fieldBet = new FieldBet("Bente", 100, 2); _colorBet = new ColorBet("Bjarne", 100, FieldColor.Black); _evenOddBet = new EvenOddBet("Berit", 100, Parity.Even); }
public void GetInfo_ShouldReturnPropNameAndValue() { // Arrange IBetDTO bet = new ColorBet(PocketColor.Black, null) { ID = 2, Stake = 20 }; // Act IBetDAL dal = Factory.CreateBetDAL(); bool x = dal.Save(bet); }
private IBet MakeBetObject(IBetDTO bet) { var info = bet.GetBetSpecificInfo(); IBet output = null; if (info.TryGetValue("Color", out object tempcolor)) { int color = (int)tempcolor; output = new ColorBet((IPocketColor)color) { Id = bet.Id, Stake = bet.Stake, }; } else if (info.TryGetValue("IsEven", out object tempEven)) { bool isEven = (bool)tempEven; output = new EvenUnevenBet(isEven) { Id = bet.Id, Stake = bet.Stake, }; } else if (info.TryGetValue("FirstNumber", out object first) && info.TryGetValue("SecondNumber", out object second)) { int firstNumber = (int)first; int secondNumber = (int)second; output = new NeighbourBet((IPocketNumber)firstNumber, (IPocketNumber)secondNumber) { Id = bet.Id, Stake = bet.Stake, }; } else if (info.TryGetValue("Number", out object tempNumber)) { int number = (int)tempNumber; output = new SingleNumberBet((IPocketNumber)number) { Id = bet.Id, Stake = bet.Stake, }; } return(output); }
public override StrategyResult Execute(RouletteGame rouletteGame, int betStartAmount) { W = betStartAmount; D = 0; double minBet = betStartAmount, maxBet = betStartAmount, startBudget = Player.Budget, minBudget = Player.Budget, maxBudget = Player.Budget; List <double> bets = new List <double>(); for (int i = 0; i < Cycles; i++) { Bet bet = new ColorBet(W, PocketColor.Red); W = PreventImpossibleBet(Player.Budget, W); double result = SpinRouletteWithExceptionHandling(rouletteGame, new ColorBet(W, PocketColor.Red)); UpdateWagerAndStraightWinsAccordingToResult(betStartAmount, result); Player.Budget += result; CyclesRan++; CollectStats(W, bets, ref maxBet, ref minBet, ref minBudget, ref maxBudget, Player.Budget); if (Player.IsBroke) { break; } } return(new StrategyResult() { EndBudget = Player.Budget, Strategy = "1-3-2-6", CyclesRan = Cycles, MaxBet = maxBet, MinBet = minBet, AllBets = bets, StartBudget = startBudget, Name = Player.Name, MaxBudget = maxBudget, MinBudget = minBudget }); }
public void PlaceBet_ShouldReturnFalse() { // Arrange User user = new User("Test", repo.CreateUserDAL(), repo.CreateBetDAL()); IBet bet = new ColorBet(InterfaceLayerBD.Bet.IPocketColor.Black) { Stake = 200 }; using (TransactionScope scope = new TransactionScope()) { // Act // No user id is specified, so this should return false. bool validCall = user.MakeBet(bet); // Assert Assert.False(validCall); Assert.NotEqual(bet, user.CurrentBet); } }
private static void ColorBet(Player player, ref Bet bet) { System.Console.WriteLine("Enter color to bet on:"); System.Console.WriteLine("[1] Red"); System.Console.WriteLine("[2] Black"); var value = System.Console.ReadLine()?.ToLower(); switch (value) { case "1": bet = new ColorBet(player, "red"); break; case "2": bet = new ColorBet(player, "black"); break; default: _error = "Invalid color, please try [1] for Red or [2] for Black!"; break; } }
public void PlaceBet_ShouldWork() { // Arrange User user = new User("Test", repo.CreateUserDAL(), repo.CreateBetDAL()) { Id = 50 }; IBet bet = new ColorBet(InterfaceLayerBD.Bet.IPocketColor.Black) { Stake = 200 }; using (TransactionScope scope = new TransactionScope()) { // Act bool validCall = user.MakeBet(bet); // Assert Assert.True(validCall); Assert.Equal(bet, user.CurrentBet); } }
public void WonAmount_OnRed_GetMoney() { _cbTestObj = new ColorBet(_sName, _uiAmount, Field.Red); _fsFieldStub.Color = Field.Red; Assert.Greater(_cbTestObj.WonAmount(_fsFieldStub), 0); }
public void teardown() { _cbTestObj = null; _fsFieldStub = null; }
public void WonAmount_ColorChosen_CorrectAmount(string name, uint amount, uint color, uint expectedReturn) { _uut = new ColorBet(name, amount, color); Assert.That(_uut.WonAmount(new Field(2, color)), Is.EqualTo(expectedReturn)); }
public void Abstract_Bet_GetAmount() { Bet uut = new ColorBet("Colorbet", 50u, Field.Black); Assert.That(uut.WonAmount(new Field(20u, Field.Black)), Is.EqualTo(100u)); }
public void ToString_ReturnColor_ColorIsCorrect(string name, uint amount, uint color, string expectedReturn) { _uut = new ColorBet(name, amount, color); Assert.That(_uut.ToString(), Is.EqualTo(amount + "$ color bet on " + expectedReturn)); }
public void CreateTest() { var bet = new ColorBet(250, _testBot, Color.Red); Assert.Pass(); }