private void ReceiverOthers(Player caller, bool showMessage) { GameSession session = GameplayController.instance.session; BankingController banking = GameplayController.instance.banking; for (int i = 0; i < session.playerCount; i++) { Player p = session.FindPlayer(i); if (!p.GetName().Equals(caller.GetName())) { /* * Jedynie takie płatności mają sens: * Bank => Others * Player => Others * Wszystkie inne skutkowałyby przelewaniem swoich pieniędzy do siebie i pokazywaniem zbędnych komunikatów */ if (payer == MoneyActor.Player) { banking.Pay(caller, p, amount); } else if (payer == MoneyActor.Bank) { p.IncreaseMoney(amount); ShowReceiveFromBankMessage(p); } } } }
public async Task BankingInfoControllerTest_GetAnException() { //Arrange MockBankingInfoRepository repository = new MockBankingInfoRepository(); var expectedResult = repository.GetMockBankingInfo(); IDistributedCache _cache = FakeCache(); string lid = "756122"; IBankingInfoRepository mockRepo = Substitute.For <IBankingInfoRepository>(); IBankingApi dAPI = Substitute.For <IBankingApi>(); ILoggingFacade fakeLogger = FakeLogger(); IOperation fakeOperation = FakeOperation(_cache); dAPI.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ThrowsForAnyArgs(new System.Exception()); BankingController controller = FakeController(dAPI, _cache, fakeOperation, fakeLogger); // Act var dinfo = await controller.GetBankingInfo(Helper.LIDTypes.TerminalNbr, "0"); var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo); // Assert Assert.Equal(actualRecord.StatusCode, 500); Assert.Equal(actualRecord.Value, "Error occured"); }
private void ReceiverPlayer(Player caller, bool showMessage) { GameSession session = GameplayController.instance.session; BankingController banking = GameplayController.instance.banking; /* * Źródłem pieniędzy dla gracza mogą być jedynie Bank i Others. * Nie może być nim Player, ponieważ przelałby sam sobie pieniądze. * Nie mogą być nim też All, ponieważ uwzględnia to w sobie Player */ if (payer == MoneyActor.Bank) { caller.IncreaseMoney(amount); if (showMessage) { ShowReceiveFromBankMessage(caller); } } else if (payer == MoneyActor.Others) { for (int i = 0; i < session.playerCount; i++) { Player p = session.FindPlayer(i); if (!p.GetName().Equals(caller.GetName())) { banking.Pay(p, caller, amount); ShowPayToPlayerMessage(p, caller); } } } }
public async Task BankingInfoControllerTest_Success() { //Arrange MockBankingInfoRepository repository = new MockBankingInfoRepository(); var expectedResult = repository.GetMockBankingInfo(); IDistributedCache _cache = FakeCache(); string lid = "756122"; IBankingInfoRepository mockRepo = Substitute.For <IBankingInfoRepository>(); IBankingApi dAPI = Substitute.For <IBankingApi>(); ILoggingFacade fakeLogger = FakeLogger(); IOperation fakeOperation = FakeOperation(_cache); dAPI.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult); BankingController controller = FakeController(dAPI, _cache, fakeOperation, fakeLogger); //Act var dinfo = await controller.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid); var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value; //Assert Assert.Equal(actualRecord, expectedResult.Result); }
public Money MakeWithdrawal(string accountHolder, Money money) { var request = new MakeWithdrawalRequest() { AccountHolder = accountHolder, Money = money }; var controller = new BankingController(); var result = _controller.MakeWithdrawal(request); return(result.Balance); }
private BankingController GetBankingController() { var mockBankingService = new Mock <IBankingService>(); mockBankingService.Setup(bank => bank.Withdraw(It.IsAny <BankOperation>())) .Returns(invaliOperationDetails); mockBankingService.Setup(bank => bank.Withdraw(It.Is <BankOperation>(us => us.Amount == validUser.Amount))) .Returns(valiOperationDetails); mockBankingService.Setup(bank => bank.Deposit(It.IsAny <BankOperation>())) .Returns(invaliOperationDetails); mockBankingService.Setup(bank => bank.Deposit(It.Is <BankOperation>(us => us.Amount == validUser.Amount))) .Returns(valiOperationDetails); mockBankingService.Setup(bank => bank.Transfer(It.IsAny <BankOperation>())) .Returns(invaliOperationDetails); mockBankingService.Setup(bank => bank.Transfer(It.Is <BankOperation>(us => us.Equals(validTransferUser)))) .Returns(valiOperationDetails); mockBankingService.Setup(bank => bank.GetBankOperationMinAmoun()) .Returns(1); var mockidentityServise = new Mock <IUserIdentityService>(); var controller = new BankingController(mockBankingService.Object, mockidentityServise.Object); var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("UserId", "0"), })); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; return(controller); }
public void BankingInfoControllerTest_ModelState_Invalid() { MockBankingInfoRepository repository = new MockBankingInfoRepository(); var expectedResult = repository.GetMockBankingInfo(); IDistributedCache _cache = FakeCache(); string lid = "756122"; IBankingInfoRepository mockRepo = Substitute.For <IBankingInfoRepository>(); IBankingApi dAPI = Substitute.For <IBankingApi>(); ILoggingFacade fakeLogger = FakeLogger(); IOperation fakeOperation = FakeOperation(_cache); dAPI.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult); BankingController controller = FakeController(dAPI, _cache, fakeOperation, fakeLogger); //Act controller.ModelState.AddModelError("key", "error message"); var dinfo = controller.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).Result; //Assert Assert.Equal(((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).StatusCode.ToString(), "400"); }
public async Task Start(BankingController controller) { this._controller = controller; _databaseProxy = new DatabaseProxy(); if (!(await _databaseProxy.CustomersExist())) { var customerDataTask = DataSeedApiProxy.RetrieveCustomerData(); var loginDataTask = DataSeedApiProxy.RetrieveLoginData(); var(customers, accounts, transactions) = await customerDataTask; // Due to table constraints these need to occur synchronously await _databaseProxy.AddCustomerBulk(customers); await _databaseProxy.AddAccountBulk(accounts); await _databaseProxy.AddTransactionBulk(transactions); var loginData = await loginDataTask; _databaseProxy.AddLoginBulk(loginData); } }
public void Start(BankingController controller) { Console.WriteLine("Welcome to MCBA Banking Application"); this.Controller = controller; }
private void Cheats(GameplayController gameplayController) { cheatsOpen = EditorGUILayout.BeginFoldoutHeaderGroup(cheatsOpen, "\n CHEATS \n"); if (cheatsOpen) { EditorGUILayout.LabelField("Add Money"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Player Name"); EditorGUILayout.LabelField("Amount"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); AddMoneyPlayerName = EditorGUILayout.TextField(AddMoneyPlayerName); AddMoneyAmount = EditorGUILayout.FloatField(AddMoneyAmount); if (GUILayout.Button("GO")) { if (gameplayController.session.FindPlayer(AddMoneyPlayerName) != null) { gameplayController.session.FindPlayer(AddMoneyPlayerName).IncreaseMoney(AddMoneyAmount); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Decrease Money"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Player Name"); EditorGUILayout.LabelField("Amount"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DecreaseMoneyPlayerName = EditorGUILayout.TextField(DecreaseMoneyPlayerName); DecreaseMoneyAmount = EditorGUILayout.FloatField(DecreaseMoneyAmount); if (GUILayout.Button("GO")) { if (gameplayController.session.FindPlayer(DecreaseMoneyPlayerName) != null) { gameplayController.session.FindPlayer(DecreaseMoneyPlayerName).DecreaseMoney(DecreaseMoneyAmount); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Give Building"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Player Name"); EditorGUILayout.LabelField("Place ID"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GiveBuildingPlayerName = EditorGUILayout.TextField(GiveBuildingPlayerName); GiveBuildingPlaceID = EditorGUILayout.IntField(GiveBuildingPlaceID); if (GUILayout.Button("GO")) { if (gameplayController.session.FindPlayer(GiveBuildingPlayerName) != null && gameplayController.board.GetOwner(GiveBuildingPlaceID) == null && GiveBuildingPlaceID < Keys.Board.PLACE_COUNT) { gameplayController.banking.AquireBuilding(gameplayController.session.FindPlayer(GiveBuildingPlayerName), GiveBuildingPlaceID); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Give Range Buildings"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Player Name"); EditorGUILayout.LabelField("Place start ID"); EditorGUILayout.LabelField("Place end ID"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GiveRangeBuildingPlayerName = EditorGUILayout.TextField(GiveRangeBuildingPlayerName); GiveRangeBuildingStartPlaceID = EditorGUILayout.IntField(GiveRangeBuildingStartPlaceID); GiveRangeBuildingEndPlaceID = EditorGUILayout.IntField(GiveRangeBuildingEndPlaceID); if (GUILayout.Button("GO")) { if (gameplayController.session.FindPlayer(GiveRangeBuildingPlayerName) != null && GiveRangeBuildingStartPlaceID.IsBetween(0, Keys.Board.PLACE_COUNT) && GiveRangeBuildingEndPlaceID.IsBetween(0, Keys.Board.PLACE_COUNT) && GiveRangeBuildingStartPlaceID <= GiveRangeBuildingEndPlaceID) { for (int i = GiveRangeBuildingStartPlaceID; i <= GiveRangeBuildingEndPlaceID; i++) { if (gameplayController.board.GetOwner(i) == null) { gameplayController.banking.AquireBuilding(gameplayController.session.FindPlayer(GiveRangeBuildingPlayerName), i); } } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Warp player"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Dice Roll 1"); EditorGUILayout.LabelField("Dice Roll 2"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); ChangeDiceRoll1 = EditorGUILayout.IntField(ChangeDiceRoll1); ChangeDiceRoll2 = EditorGUILayout.IntField(ChangeDiceRoll2); if (GUILayout.Button("GO")) { GameplayController.instance.board.dice.SetLast(ChangeDiceRoll1, ChangeDiceRoll2); } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Teleport Player"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Player name"); EditorGUILayout.LabelField("Place Id"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); TeleportPlayerName = EditorGUILayout.TextField(TeleportPlayerName); TeleportPlaceId = EditorGUILayout.IntField(TeleportPlaceId); if (GUILayout.Button("GO")) { GameSession session = GameplayController.instance.session; Player player = session.FindPlayer(TeleportPlayerName); if (player != null) { GameplayController.instance.board.TeleportPlayer(player, TeleportPlaceId); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Next tier"); EditorGUILayout.LabelField("Place Id"); EditorGUILayout.BeginHorizontal(); nextTierPlaceId = EditorGUILayout.IntField(nextTierPlaceId); if (GUILayout.Button("GO")) { BankingController bankingController = GameplayController.instance.banking; FlowController flowController = gameplayController.flow; bankingController.UpgradeBuilding(flowController.CurrentPlayer, nextTierPlaceId); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndFoldoutHeaderGroup(); }
/// <summary> /// Komenda odpowiedzialna za inicjalizację BankingControllera /// </summary> /// <param name="banking">Obiekt przechowujący BankingController</param> public BankingControllerCommand(BankingController banking, Action <Command> onStageStarted = null, Action <Command> onStageFinished = null) : base("BankingController", onStageStarted, onStageFinished) { this.banking = banking; }
public HostNodeRequestService() { _bank = new BankingController(); _responseBuilder = new BankMessageBuilder(); }