//------------------------------------------------------------------------------------------------------------------------ // Initialize() //------------------------------------------------------------------------------------------------------------------------ public void Initialize() { var itemGenerator = new Generator(new NormalItemFactory()); //Set up the model and controller _shopModel = new ShopModel(itemGenerator.CreateRandomItems(Globals.ItemsPerShop)); _shopController = new ShopController(_shopModel); //get view from children _shopView = GetComponentInChildren <ShopView>(); _shopView.Subscribe(_shopModel); Debug.Assert(_shopView != null); //get mesageview from children _shopMessageView = GetComponentInChildren <ShopMessageView>(); _shopMessageView.Subscribe(_shopModel); Debug.Assert(_shopMessageView != null); //get itemInfoView from children _shopItemInfoView = GetComponentInChildren <ShopItemInfoView>(); _shopItemInfoView.Subscribe(_shopModel); //setup model and controller //link them _shopView.Initialize(_shopController, Game.PlayerHumanoid); //view1 _shopMessageView.Initialize(_shopModel); //view2 }
private void Start() { if (SC == null) { SC = this; } }
void Start() { Localization(); _controller = new ShopController(this); _controller.SendRequestRefreshGold(); if (GameManager.Status == GameStatus.ShopHero) { shopRoot.SetActive(false); randomHeroRoot.gameObject.SetActive(true); } _activeTab = ActiveTab.None; _isBuyHero = true; setGoldSivler(); if (BUYGOLD) { OnChangeTab(ActiveTab.Vault); BUYGOLD = false; } else { OnChangeTab(ActiveTab.Support); } }
public async Task Index_Success(int categoryId, int productsCount) { //Arrange var productServiceMock = new ProductServiceMock(); var cookieProviderMock = new CookieProviderMock(categoryId); var sessionMock = new SessionMock(); var context = new DefaultHttpContext { Session = sessionMock.Object }; var controller = new ShopController(productServiceMock.Object, cookieProviderMock.Object) { ControllerContext = new ControllerContext() { HttpContext = context } }; //Act var result = await controller.Index(); //Assert var view = Assert.IsType <ViewResult>(result); var model = Assert.IsType <ShopPageViewModel>(view.Model); Assert.Equal(productsCount, model.Products.Count); Assert.Equal(4, model.Categories.Count); Assert.Equal(categoryId, model.CategoryId); }
public void DeleteProductTest() { // Arrange - обьявлени var shopName = "shop"; string productName = "grechka"; DateTime expDate = DateTime.Now.AddDays(60); Random rnd = new Random(); int amount = rnd.Next(); bool contains = true; // Act - действие var shopcontroller = new ShopController(shopName); shopcontroller.AddNewProduct(productName, expDate, amount); shopcontroller.DeleteProduct(shopcontroller.CurrentShop, productName); foreach (Product P in shopcontroller.CurrentShop.Products) { if (P.Name != productName) { contains = false; } } // Assert - результат Assert.AreEqual(false, contains); }
void Awake() { if (instance == null) { instance = this; } }
public void SingleProductViewResultNotNull() { ShopController controller = new ShopController(); ViewResult result = controller.SingleProduct("45") as ViewResult; Assert.IsNotNull(result); }
public void IndexViewResultNotNull() { ShopController controller = new ShopController(); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); }
public ActionResult step02(string fName, string lName, string address, string mob, string city, string country, int bill, int dc) { string userID = "0"; userID = Session["uID"].ToString(); Session["fName"] = fName; Session["address"] = address; Session["mob"] = mob; Session["city"] = city; Session["country"] = country; Session["bill"] = bill; Session["dc"] = dc; ViewBag.dc = dc; ViewBag.bill = bill; //Verification Page string tt = ShopController.GetTotalCount(userID); string[] arr = tt.Split('-'); ViewBag.count = arr[0]; ViewBag.total = arr[1]; //Session["bill"] = arr[1]; Session["bill-count"] = arr[0]; using (linqDBContext db = new linqDBContext()) { string content = ""; string sectionsPath = Server.MapPath("~/data/templates/" + "cart-verification" + ".txt"); content = System.IO.File.ReadAllText(sectionsPath); string cartContent = ""; var cart = (from us in db.tblCarts join it in db.tblItems on us.itemID equals it.id join cat in db.tblCategories on it.subCategory equals cat.id where us.userMob == userID orderby it.id ascending select new { us, it, cat }).ToList(); if (cart != null) { foreach (var item in cart) { cartContent += content; cartContent = cartContent.Replace("#itemNameHere", item.it.itemName + " - " + item.us.size); cartContent = cartContent.Replace("#itemCatHere", item.cat.name); cartContent = cartContent.Replace("#itemQtyHere", item.us.itemQty.Value.ToString()); cartContent = cartContent.Replace("#itemPriceHere", "-"); cartContent = cartContent.Replace("#itemUnitPrice", "-"); } ViewBag.data = cartContent; } } return(View()); }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); BoostController = new BoostController(_boostView); MoneyController = new MoneyController(_moneyView, BoostController); ShopController = new ShopController(_listOfBoosts, _shopView); ManagerController = new ManagerController(_listOfManagers, _managerView); if (_useClearSavegame) { PlayerPrefs.SetFloat("money", 3000); } float oldMoney = PlayerPrefs.GetFloat("money"); MoneyController.AddMoney(oldMoney); }
public void GenerateShopItem(ShopController shopController, CardClass card, bool isInventoryItem = false) { ShopController = shopController; Card = card; IsInInventory = isInventoryItem; TextItemName.text = card.CardName; Sprite img; switch (card.Type) { case CardClass.CardType.ATK: default: img = Resources.Load <Sprite>("card_player/attack"); break; case CardClass.CardType.GOLD: img = Resources.Load <Sprite>("card_player/money"); break; case CardClass.CardType.POTION: img = Resources.Load <Sprite>("card_player/health"); break; } ImageCard.sprite = img; if (IsInInventory) { TextPrice.text = Mathf.FloorToInt(card.Price * 0.3f).ToString(); BuyButtonObject.GetComponentInChildren <Text>().text = "Sell"; } else { TextPrice.text = card.Price.ToString(); BuyButtonObject.GetComponentInChildren <Text>().text = "Add"; } }
private void button1_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(id.Text); if (string.IsNullOrEmpty(id.Text)) { MessageBox.Show("Give Information", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { var result = ShopController.DeleteShop(Id); if (result) { MessageBox.Show("Shop Remove", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.None); id.Text = null; var shop = ShopController.GetAllShop(); dataGridView1.DataSource = shop; } else { MessageBox.Show("No shop found", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (FormatException) { MessageBox.Show("Enter restaurnat id in correct formate", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void BuyBonus() { ShopController shopController = FindObjectOfType <ShopController>(); SceneController sceneController = FindObjectOfType <SceneController>(); BonusController bonusController = FindObjectOfType <BonusController>(); m_profile = FindObjectOfType <Profile>(); if (sceneController.Score >= bonusController.GetPrice(m_type)) { int currScore = sceneController.Score; int count = m_profile.GetBoughtBonus(Type); count += m_bonusCountMultiplier; currScore -= (m_price * m_bonusCountMultiplier); m_profile.SetScore(currScore); m_profile.SetBoughtBonus(Type, count); m_profile.Save(); sceneController.Score = currScore; shopController.BuyBonus(m_type); } else { Debug.Log("You don't have enough Points!"); } }
public ShopReg() { InitializeComponent(); var shop = ShopController.GetAllShop(); dataGridView1.DataSource = shop; }
//------------------------------------------------------------------------------------------------------------------------ // ShopView() //------------------------------------------------------------------------------------------------------------------------ public ShopView(ShopController pShopController, Actor pCustomer) : base(340, 340) { _shopController = pShopController; _commandManager = ServiceLocator.Instance.GetService <CommandManager>(); _items = new List <Item>(); _customer = pCustomer; x = (game.width - width) / 2; y = (game.height - height) / 2; //----------------------------- Create Commands --------------------------------// var moveSelectionLeft = new MoveSelectionCommand(_shopController, this, -1, 0); var moveSelectionRight = new MoveSelectionCommand(_shopController, this, 1, 0); var moveSelectionUp = new MoveSelectionCommand(_shopController, this, 0, -1); var moveSelectionDown = new MoveSelectionCommand(_shopController, this, 0, 1); var buyItem = new BuyItemCommand(_shopController, _customer); //-------------------------- Add Commands to list ------------------------------// _keyCommands = new List <KeyCommand>() { new KeyCommand((int)Key.LEFT, moveSelectionLeft), new KeyCommand((int)Key.RIGHT, moveSelectionRight), new KeyCommand((int)Key.UP, moveSelectionUp), new KeyCommand((int)Key.DOWN, moveSelectionDown), new KeyCommand((int)Key.SPACE, buyItem), }; }
public ShopList() { InitializeComponent(); var result = ShopController.GetAllShop(); dataGridView1.DataSource = result; }
//------------------------------------------------------------------------------------------------------------------------ // Initialize() //------------------------------------------------------------------------------------------------------------------------ public void Initialize() { //Set up the model and controller shopModel = new ShopModel(); shopController = new ShopController(shopModel); //get view from children shopView = GetComponentInChildren <ShopView>(); Debug.Assert(shopView != null); //get mesageview from children shopMessageView = GetComponentInChildren <ShopMessageView>(); Debug.Assert(shopMessageView != null); //setup model and controller //link them shopView.Initialize(shopModel, shopController); //view1 shopMessageView.Initialize(shopModel); //view2 shopView.Subscribe(shopModel); }
public void Show_All_Products() { var products = new Product[] { new Product() { Name = "Name1" }, new Product() { Name = "Name4" }, new Product() { Name = "Name8" }, new Product() { Name = "Name3" }, }; var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.Products.GetAllItems()).Returns(products); var target = new ShopController(unitOfWorkMock.Object); var resultModel = ((target.Index() as ViewResult).Model as IEnumerable <Product>).ToArray(); Assert.True(resultModel[0].Name == "Name1"); Assert.True(resultModel[1].Name == "Name4"); Assert.True(resultModel[2].Name == "Name8"); Assert.True(resultModel[3].Name == "Name3"); }
private void Start() { if (ShopController.shop == null) { ShopController.shop = this; } else { Destroy(this.gameObject); } allShopCards = new List <Card>(); chosenCards = new List <Card>(); foreach (ShopCardController card in shopCards) { for (int j = 0; j < 100; j++) { Card thisCard = LootController.loot.GetCard(); if (!allShopCards.Contains(thisCard) && CollectionController.collectionController.GetCountOfCardInCollection(thisCard) < 4) //Ensures that all rewards are unique { card.GetComponent <CardController>().SetCard(thisCard, false); card.SetCard(card.GetComponent <CardController>()); allShopCards.Add(thisCard); card.SetPrice(ResourceController.resource.commonCardPrice); break; } } card.ResetBuyable(); } }
//------------------------------------------------------------------------------------------------------------------------ // ShopBrowseState() //------------------------------------------------------------------------------------------------------------------------ public ShopBrowseState(List <Item> items, Actor pCustumer) { //create shop ShopModel shop = new ShopModel(items); //create controller _shopController = new ShopController(shop); //create shop view _shopView = new ShopView(_shopController, pCustumer); _shopView.Subscribe(shop); AddChild(_shopView); Helper.AlignToCenter(_shopView, true, true); //create item info view _itemInfoView = new ItemInfoView(); _itemInfoView.Subscribe(shop); AddChild(_itemInfoView); //create message view _shopMessageView = new ShopMessageView(); _shopMessageView.Subscribe(shop); AddChild(_shopMessageView); Helper.AlignToCenter(_shopMessageView, true, false); }
public void Controller_Shop_EditName_Data_Valid_Should_Pass() { // Arrange DataSourceBackend.Instance.Reset(); ShopController controller = new ShopController(); var data = new ShopTruckInputModel { StudentId = DataSourceBackend.Instance.StudentBackend.GetDefault().Id, TruckName = DataSourceBackend.Instance.StudentBackend.GetDefault().Truck.TruckName }; // Get the Student Record var myStudent = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); var expect = myStudent.Truck.TruckName; // select item var mySelect = (RedirectToRouteResult)controller.EditName(data); // Act ViewResult result = controller.EditName(data) as ViewResult; var myStudent2 = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(expect, myStudent2.Truck.TruckName, TestContext.TestName); }
public void Controller_Shop_Edit_Data_Valid_Position_Wheels_Should_Pass() { // Arrange ShopController controller = new ShopController(); var data = new ShopTruckInputModel { StudentId = DataSourceBackend.Instance.StudentBackend.GetDefault().Id, ItemId = DataSourceBackend.Instance.FactoryInventoryBackend.GetDefaultTruckFullItem(FactoryInventoryCategoryEnum.Wheels).Id, Position = FactoryInventoryCategoryEnum.Wheels }; // Get the Student Record var myStudent = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); var expect = myStudent.Truck.Wheels; // select item var mySelect = (RedirectToRouteResult)controller.Edit(data); // Act ViewResult result = controller.Edit(data) as ViewResult; var myStudent2 = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(expect, myStudent2.Truck.Wheels, TestContext.TestName); }
private static void IncreaseInventory() { shopController = new ShopController(userController.CurrentUser); shopController.MessagesEventSuccess += MessagesEventSuccess; shopController.MessagesEventFail += MessagesEventFail; shopController.IncreaseInventory(); }
/*public override void Pickup(PlayerController player) * { * player.OnItemPurchased += Restocker; * base.Pickup(player); * } * * public override DebrisObject Drop(PlayerController player) * { * player.OnItemPurchased -= Restocker; * return base.Drop(player); * }*/ private void Restocker(PlayerController arg1, ShopItemController arg2) { arg2.item.PersistsOnPurchase = true; if (!arg2.gameObject || !arg2) { ETGModConsole.Log("my coffins all i see"); } ETGModConsole.Log("time to drop"); FieldInfo _parentShop = typeof(ShopItemController).GetField("m_parentShop", BindingFlags.NonPublic | BindingFlags.Instance); ShopController shop = (ShopController)_parentShop.GetValue(arg2); if (shop) { arg2.Initialize(Gungeon.Game.Items["psm:randy"], shop); } else { ETGModConsole.Log("loosen up"); FieldInfo _parentBaseShop = typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.NonPublic | BindingFlags.Instance); BaseShopController baseShop = (BaseShopController)_parentBaseShop.GetValue(arg2); if (baseShop) { ETGModConsole.Log("dont forget about it"); arg2.Initialize(Gungeon.Game.Items["psm:randy"], baseShop); } else { ETGModConsole.Log("f**k shit up"); } } }
public void Shop_Returns_CorrectView() { var products = new[] { new ProductDTO(1, "Product1", 1, 10m, "Iamge1.png", new BrandDTO(1, "Brand1", 1, 1), new SectionDTO(1, "Section1", 1, null, 1)), new ProductDTO(2, "Product2", 2, 20m, "Iamge2.png", new BrandDTO(2, "Brand2", 1, 1), new SectionDTO(2, "Section2", 2, null, 1)), new ProductDTO(3, "Product3", 3, 30m, "Iamge3.png", new BrandDTO(3, "Brand3", 1, 1), new SectionDTO(3, "Section3", 3, null, 1)), }; const int expected_section_id = 1; const int expected_brand_id = 3; var product_data_mock = new Mock <IProductData>(); product_data_mock .Setup(x => x.GetProducts(It.IsAny <ProductFilter>())) .Returns(products); var controller = new ShopController(product_data_mock.Object); var result = controller.ShopIndex(expected_brand_id, expected_section_id); var view_result = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <CatalogViewModel>(view_result.ViewData.Model); Assert.Equal(products.Length, model.Product.Count()); Assert.Equal(expected_brand_id, model.BrandId); Assert.Equal(expected_section_id, model.SectionId); }
public InventoryView(InventoryController pInventoryController, ShopController pShopController = null) : base(560, 340) { _keyCommands = new List <KeyCommand>(); _items = new List <Item>(); _shopController = pShopController; _controller = pInventoryController; _commandManager = ServiceLocator.Instance.GetService <CommandManager>(); //----------------------------- Create Commands --------------------------------// var moveSelectionLeft = new MoveInventorySelectionCommand(_controller, this, -1, 0); var moveSelectionRight = new MoveInventorySelectionCommand(_controller, this, 1, 0); var moveSelectionUp = new MoveInventorySelectionCommand(_controller, this, 0, -1); var moveSelectionDown = new MoveInventorySelectionCommand(_controller, this, 0, 1); var equipItem = new EquipItemCommand(MyGame.Player, _controller); var drinkItem = new DrinkItemCommand(MyGame.Player, _controller); var sellItem = new SellItemCommand(pInventoryController, pShopController); //-------------------------- Add Commands to list ------------------------------// _keyCommands = new List <KeyCommand>() { new KeyCommand((int)Key.LEFT, moveSelectionLeft), new KeyCommand((int)Key.RIGHT, moveSelectionRight), new KeyCommand((int)Key.UP, moveSelectionUp), new KeyCommand((int)Key.DOWN, moveSelectionDown), new KeyCommand((int)Key.E, equipItem), new KeyCommand((int)Key.Q, drinkItem), new KeyCommand((int)Key.SPACE, sellItem) }; RegisterCommands(); }
void MakeInstance() { if (instance == null) { instance = this; } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(id.Text)) { MessageBox.Show("Please enter shop Id", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { int Id = Convert.ToInt32(id.Text); var result = ShopController.GetShop(Id); if (result != null) { panel1.Visible = true; name.Text = String.Format(result.Name); location.Text = String.Format(result.Location); } } catch (FormatException) { MessageBox.Show("Please enter shop Id in correct formate", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Start() { this.canvasController = this.canvas.GetComponent <CanvasController>(); this.shopController = this.shop.GetComponent <ShopController>(); StartCoroutine(DisableImageTargets()); }
public async void CannotReturnShopDetailsWithBadID() { var options = new DbContextOptionsBuilder <ProductDbContext>() .UseInMemoryDatabase(databaseName: "testDb") .Options; var builder = new ConfigurationBuilder().AddEnvironmentVariables(); var config = builder.Build(); using (var context = new ProductDbContext(options)) { context.Product.AddRange( new Product { Name = "test1", Price = 12.99, Description = "first test item", ImagePath = "test/path", StudentSale = false }, new Product { Name = "test2", Price = 78.99, Description = "second test item", ImagePath = "test/path2", StudentSale = false }, new Product { Name = "test3", Price = 2.99, Description = "third test item", ImagePath = "test/path3", StudentSale = true, SalePrice = 1.99 } ); context.SaveChanges(); var controller = new ShopController(context); var result = await controller.Details(99); Assert.IsType <RedirectToActionResult>(result); } }
void Awake() { g_instance = this; Items = new Item[ITEM_NUM]; // TODO - add more items to be done here Items[0] = new Item(0, "The ultimate range weapon crossbow can shoot 3 arrows at a time!"); Items[1] = new Item(1, "The axe wielder can do attack on both sides."); Items[2] = new Item(2, "Buy a combo of [00ff00]10[-] blizzard spells. The blizzard can freeze up all enemies for a long while."); Items[3] = new Item(3, "Buy a combo of [00ff00]5[-] apocalypse spells. The spell can virtually hurt all enemies on sight."); }
void Start() { mainController = GameObject.Find("Central Controller").GetComponent<Controller>(); shopController = GameObject.Find("ShopController").GetComponent<ShopController>(); animator = GetComponent<Animator>(); attributeImages = staffAttributePanel.GetComponentsInChildren<Image>(); attributeTexts = staffAttributePanel.GetComponentsInChildren<Text>(); }
// used to initialise the variables void Start() { string plat = Application.platform.ToString(); Debug.Log(plat); // find and set the variables closeBtn = GameObject.Find("Close Shop"); mainController = GameObject.Find("Central Controller").GetComponent<Controller>(); shopController = GameObject.Find("ShopController").GetComponent<ShopController>(); }
// runs once at startup of script void Start() { // set up all variables mainController = GameObject.Find("Central Controller").GetComponent<Controller>(); shopController = GameObject.Find("ShopController").GetComponent<ShopController>(); popupController = GameObject.Find("PopupController").GetComponent<Popup_Controller>(); financeController = GameObject.Find("FinanceController").GetComponent<Finance_Controller>(); theConfirmPanel = popupController.confirmationPanel; textElements = theConfirmPanel.GetComponentsInChildren<Text>(); imageElements = theConfirmPanel.GetComponentsInChildren<Image>(); }