public void IndexExceptionCase() { #region mockPurchaseRepository = new Mock <IPurchaseRepository>(); // Prepare the return data for GetAllQuotation() method. var purchaseQuotationList = new List <PurchaseQuotation>(); purchaseQuotationList.Add(new PurchaseQuotation { Purchase_Quote_Id = 1, Quotation_Status = "Completed" }); // Mock up the GetAllQuotation() repository method with expected return values. mockPurchaseRepository.Setup(m => m.GetAllQuotation()).Returns(purchaseQuotationList); // Prepare the return data for the GetAddressList() method. var branchList = new List <BranchList>(); branchList.Add(new BranchList { Branch_Id = 1, Branch_Name = "MADURAI MAIN" }); // Mock up the GetAddressList() repository method with expected return value. //mockPurchaseRepository.Setup(m => m.GetAddressList()).Returns(branchList); purchaseController = new PurchaseController(mockPurchaseRepository.Object, mockManufacturerRepository.Object); #endregion // Now invoke the Index action. var actionResult = purchaseController.Index() as ViewResult; // Validate the expected result. ViewResult expectedResult = new ViewResult(); Assert.AreEqual("Error", actionResult.ViewName); }
//Методы public PurchaseWindow(Clientas client, string num) { InitializeComponent(); this.client = client; numOperations = num; controller = new PurchaseController(this); }
public void Setup() { mockPurchaseRepository = new Mock <IPurchaseRepository>(); mockManufacturerRepository = new Mock <IManufacturerRepository>(); purchaseController = new PurchaseController(mockPurchaseRepository.Object, mockManufacturerRepository.Object); }
public TestPurchaseController() { #region load dummy data storeAppContext = new TestDbPOS(); storeAppContext.Purchases.Add(new Purchase() { Id = new Guid("3bc4d343-1a0d-432f-a190-d8f76ebb1ab9"), SupplierId = new Guid("890f2f7c-5442-4c8b-aedf-9baa6839fc78"), UserId = new Guid("839b0da7-50f7-4af0-98bf-4bd746cfa192"), Supplier = new Supplier(), User = new User() { UserRoles = new List <UserRole>() } }); storeAppContext.Purchases.Add(new Purchase() { Id = new Guid("ed08a51b-8e08-4e71-8b28-db1ec5ce3d0b"), SupplierId = new Guid("e349b832-46da-4543-a3eb-9e697f7207e3"), UserId = new Guid("5b13ea1f-dfb9-4f56-9636-b45a8036d7ca"), Supplier = new Supplier(), User = new User() { UserRoles = new List <UserRole>() } }); #endregion #region load controller purchaseController = new PurchaseController(storeAppContext); #endregion }
public OrderProductDialog(UserController userController, ConversationState conversationState, IPrestashopApi prestashopApi, IConfiguration configuration, PurchaseController purchaseController) : base(nameof(OrderProductDialog), userController, conversationState) { AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new TextPrompt("CardValidator", CardJsonValidator)); AddDialog(new NumberPrompt <int>(nameof(NumberPrompt <int>))); AddDialog(new TextPrompt("ProductValidator", ValidateProductAsync)); AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { CheckPermissionStepAsync, LuisConversionStepAsync, ProductStepAsync, SelectionCardStepAsync, DisableCardStepAsync, AmountStepAsync, ConfirmLineStepAsync, AddToCartStepAsync, })); InitialDialogId = nameof(WaterfallDialog); PermissionLevel = PermissionLevels.Representative; PrestashopApi = prestashopApi; Configuration = configuration; PurchaseController = purchaseController; }
public void OnConfirmPurchasePanelButtonClicked(bool isConfirmed) { confirmPanel.SetActive(false); if (isConfirmed) { PurchaseController.BuyProductId(_coinToPurchase.ProductId); } }
public void OnRestorePurchaseConfirmPanelButtonClicked(bool isConfirmed) { if (isConfirmed) { PurchaseController.RestorePurchase(); } restorePurchaseConfirmPanel.SetActive(false); }
public void ReturnAnInstance_WhenParametersAreNotNull() { // Arrange var userServiceMock = new Mock <IApplicationUserService>(); PurchaseController controller = new PurchaseController(userServiceMock.Object); Assert.IsNotNull(controller); }
public void PostPurchase_InvalidItemNameReturnsError() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "NotAnItem"; var result = controller.Post(itemName); Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); }
public TripsModel(IStorage storage) { _trips = new TripController(storage); _photos = new PhotoController(storage); _places = new PlaceController(storage); _goals = new GoalController(storage); _goods = new GoodController(storage); _purchases = new PurchaseController(storage); }
public void OnConfirmSubscriptionPanelButtonClicked(bool isConfirmed) { confirmPanel.SetActive(false); if (isConfirmed) { PurchaseController.PurchaseASubscription(GameDataController.GetGameData().CurSubscriptionObj, _subscriptionToSubscribe); } }
public PurchaseModule(OrmLiteConnectionFactory db) : base("/purchases") { { const string obj = "Purchase"; Get["/"] = _ => { var controller = new PurchaseController(db); return(View[obj + "List", controller.ListAll()]); }; Get["/{id}"] = req => { var controller = new PurchaseController(db); var item = controller.Get(req.id); if (item == null) { return(404); } return(View[obj + "Detail", item]); }; Get["/create"] = _ => { var model = new { Movies = (new MovieController(db)).ListAll().Movies, Showings = (new ShowingsController(db)).ListAll(), Customers = new List <Customer>(), Promotions = (new PromotionController(db)).ListAll(), }; var selects = new { Movies = model.Movies.Select(movie => new SelectListItem(movie.Title, movie.MovieId.ToString(), false)), Showings = model.Showings.Select(showing => new SelectListItem(showing.Time.ToString(), showing.ShowingId.ToString(), false)), Customers = model.Customers.Select(showing => new SelectListItem(showing.Name.ToString(), showing.CustomerId.ToString(), false)), Promotions = model.Promotions.Select(showing => new SelectListItem(showing.PromotionName.ToString(), showing.PromotionId.ToString(), false)), }; return(View["New" + obj, selects]); }; Post["/create"] = _ => { var item = this.Bind <Purchase>(); LogTo.Debug("Adding purchase: {0}", item); var controller = new PurchaseController(db); var newId = controller.Add(item); return(Response.AsRedirect(ModulePath + "/" + newId)); }; Post["/update/{id}"] = _ => { return(500); }; } }
public static void CheckSubscriptionPriceChange() { var values = new Dictionary <string, string> { }; ServerResponseModel serverResponse = sendUnityWebRequest(values, CHECK_SUBSCRIPTION_PRICE_CHANGE); if (serverResponse.success) { PurchaseController.confirmSubscriptionPriceChange(serverResponse.result); } }
public static void verifyAndSaveUserPurchase(Product product) { var values = new Dictionary <string, string> { ["receipt"] = product.receipt }; ServerResponseModel serverResponse = sendUnityWebRequest(values, VERIFY_AND_SAVE_TOKEN_URL); PurchaseController.ConfirmPendingPurchase(product, serverResponse.success); }
public void PostPurchase_DecrementsInventory() { var repo = new MockItemRepository(); var startingCount = repo.GetInventory().Count; var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var item = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; var newCount = repo.GetInventory().Count; Assert.IsTrue(startingCount == (newCount + 1)); }
public void Initialize() { purchaseRepository = new Mock <IPurchaseRepository>(); purchaseService = new Mock <IPurchaseService>(); logger = new Mock <ILogger <PurchaseController> >(); purchaseController = new PurchaseController(logger.Object); configuration = new Mock <IConfiguration>(); configuration.Setup(t => t["Configurations:DefautCpf.Cpf"]).Returns("01234567890"); GlobalSettings.Configuration = configuration.Object; purchase = new Purchase("4d5sa4", 456, "*****@*****.**", "01234567890"); response = new Response(); }
public PurchaseModule(OrmLiteConnectionFactory db) : base("/purchases") { { const string obj = "Purchase"; Get["/"] = _ => { var controller = new PurchaseController(db); return View[obj + "List", controller.ListAll()]; }; Get["/{id}"] = req => { var controller = new PurchaseController(db); var item = controller.Get(req.id); if (item == null) return 404; return View[obj + "Detail", item]; }; Get["/create"] = _ => { var model = new { Movies = (new MovieController(db)).ListAll().Movies, Showings = (new ShowingsController(db)).ListAll(), Customers = new List<Customer>(), Promotions = (new PromotionController(db)).ListAll(), }; var selects = new { Movies = model.Movies.Select(movie => new SelectListItem(movie.Title, movie.MovieId.ToString(), false)), Showings = model.Showings.Select(showing => new SelectListItem(showing.Time.ToString(), showing.ShowingId.ToString(), false)), Customers = model.Customers.Select(showing => new SelectListItem(showing.Name.ToString(), showing.CustomerId.ToString(), false)), Promotions = model.Promotions.Select(showing => new SelectListItem(showing.PromotionName.ToString(), showing.PromotionId.ToString(), false)), }; return View["New" + obj, selects]; }; Post["/create"] = _ => { var item = this.Bind<Purchase>(); LogTo.Debug("Adding purchase: {0}", item); var controller = new PurchaseController(db); var newId = controller.Add(item); return Response.AsRedirect(ModulePath + "/" + newId); }; Post["/update/{id}"] = _ => { return 500; }; } }
public void PostPurchase_ReturnsSame() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var item = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; Assert.IsNotNull(item); Assert.AreEqual(item.RouteName, "GetItemByName"); Assert.AreEqual(item.RouteValues["itemName"], item.Content.Name); Assert.AreEqual(item.Content.Name, itemName); }
public void TestAdd() { var mockRepo = new Mock <ECommerceContext>(); mockRepo.Setup(repo => repo.Orders) .ReturnsAsync(); var controller = new PurchaseController(mockRepo.Object); var returnedValue = controller.Get("123456"); Assert.True(returnedValue == "success"); }
public void SelectUserCart() { // Arrange var customerService = new Mock <ICustomerService>(); var purchaseService = new Mock <IPurchaseService>(); PurchaseController controller = new PurchaseController(purchaseService.Object, customerService.Object); // Act ViewResult result = controller.SelectUserCart() as ViewResult; // Assert Assert.IsNotNull(result); }
private void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextboxFname.Text) == true) { MessageBox.Show("Please Enter Name"); TextboxFname.Focus(); } if (string.IsNullOrEmpty(textBoxAddress.Text) == true) { MessageBox.Show("Please Enter Address"); TextboxFname.Focus(); textBoxAddress.Focus(); } if (string.IsNullOrEmpty(textBoxPhone.Text) == true) { MessageBox.Show("Please Enter Phone"); textBoxAddress.Focus(); } if (string.IsNullOrEmpty(textBoxCusname.Text) == true) { MessageBox.Show("Please Enter Category"); textBoxCusname.Focus(); } else { PurchaseController.NewPurchases(TextboxFname.Text, textBoxAddress.Text, textBoxPhone.Text, textBoxCusname.Text); string message = "Do you want to confirm this program..?"; string title = "Alert"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { this.Hide(); UserType f = new UserType(); f.Show(); } else { // Do something } } }
public void PostPurchase_ReturnsPopulatedItem() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var response = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; Assert.IsNotNull(response); var newItem = response.Content; Assert.AreEqual(newItem.Name, itemName); Assert.AreEqual(newItem.Description, "Tuna melt on rye"); Assert.AreEqual(newItem.Price, 5); }
public void OnConfirmPurchasePanelButtonClicked(bool isConfirmed) { confirmPanel.SetActive(false); if (isConfirmed) { // If the item sales in coins, buy the product through the client side. if (_carToPurchaseObj.IsRealMoneyPurchase) { PurchaseController.BuyProductId(_carToPurchaseObj.ProductId); } else { GameDataController.GetGameData().PurchaseCar(_carToPurchaseObj); } } }
private void ButtonLogin_Click(object sender, EventArgs e) { var result = DeliverymansController.AuthenticateUser(textBoxUname.Text, textBoxPass.Text); if (result == true) { MessageBox.Show("Success", "Alert"); this.Hide(); var Purchases = PurchaseController.GetAllOrder(); DeliveryManpanel l = new DeliveryManpanel(Purchases); l.Show(); } else { MessageBox.Show("Failed", "Alert"); } }
public void GoToLevel(int levelIndex, bool monsterSelection = true) { GameplayController.Instance.CurrentLevelIndex = Mathf.Min(levelIndex, GameplayController.Instance.NumOfLevels - 1); if (!m_bought) { //already bought stored locally - just keep playing if (levelIndex > 7) { PurchaseController purchase_cont = gameObject.GetComponent <PurchaseController> (); bool bought = purchase_cont.InitStates(); if (bought) { PostCheckBuy(levelIndex, monsterSelection); } else { purchase_cont.ShowBuyScreen(true, (bool success) => { if (success) { purchase_cont.ShowBuyScreen(false); PostCheckBuy(levelIndex, monsterSelection); } else { purchase_cont.ShowBuyScreen(false); ShowMapPanel(); } }); } } else { PostCheckBuy(levelIndex, monsterSelection); } } else { PostCheckBuy(levelIndex, monsterSelection); } }
public void TestTshirt() { // Given IProduct tshirt = new Tshirt(); PurchaseController controller = new PurchaseController(); ICommand order = new OrderCommand(tshirt); controller.InsertCommand(order); ICommand buy = new BuyCommand(tshirt); controller.InsertCommand(buy); // When var order_t = order.Execute(); var buy_t = buy.Execute(); // Then Assert.AreEqual("T-shirt", order_t); Assert.AreEqual("19.99", buy_t); }
public ConfirmOrderDialog(UserController userController, ConversationState conversationState, PurchaseController purchaseController, IPrestashopApi prestashopApi) : base(nameof(ConfirmOrderDialog), userController, conversationState) { AddDialog(new TextPrompt(nameof(TextPrompt), CardJsonValidator)); AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { CheckPermissionStepAsync, CheckOrderStepAsync, ShowCardStepAsync, DisableCardStepAsync, ProcessValueStepAsync, FinalStepAsync })); PermissionLevel = PermissionLevels.Representative; InitialDialogId = nameof(WaterfallDialog); PurchaseController = purchaseController; PrestashopApi = prestashopApi; }
public void TestShoes() { // Given IProduct shoes = new Shoes(); PurchaseController controller = new PurchaseController(); ICommand order = new OrderCommand(shoes); controller.InsertCommand(order); ICommand buy = new BuyCommand(shoes); controller.InsertCommand(buy); // When var order_t = order.Execute(); var buy_t = buy.Execute(); // Then Assert.AreEqual("Shoes", order_t); Assert.AreEqual("39.99", buy_t); }
public void RefreshRecordList() { if (controllers.ContainsKey(ChildIndex.PurchaseRecordController)) { PurchaseRecordController prc = controllers[ChildIndex.PurchaseRecordController].GetComponent <PurchaseRecordController>(); if (prc != null) { prc.FreshUI(); } } if (controllers.ContainsKey(ChildIndex.PurchaseController)) { PurchaseController pc = controllers[ChildIndex.PurchaseController].GetComponent <PurchaseController>(); if (pc != null) { pc.UpdateFirst(); pc.RefreshUI(false); } } }
public PurchaseControllerTests() { this.errorLogger = new Mock <IErrorLogger>(); this.purchaseService = new Mock <IPurchaseService>(); this.linkBuilderFactory = new Mock <ILinkBuilderFactory>(); this.linkBuilder = new Mock <ILinkBuilder>(); this.linkBuilder.Setup(l => l.BuildLinks()).Returns(new List <Link>() { new Link("https://testing/v1.0/test", "REL", "TEST_TYPE") }); this.linkBuilderFactory.Setup(x => x.Create(It.IsAny <Type>(), It.IsAny <object>())).Returns(this.linkBuilder.Object); this.linkBuilderFactory.Setup(x => x.Create(It.IsAny <Type>())).Returns(this.linkBuilder.Object); purchaseController = new PurchaseController( this.purchaseService.Object, this.errorLogger.Object, this.linkBuilderFactory.Object); }
public void TestPurchaseGetByIdNotFound() { // Arrange var id = Guid.NewGuid(); var mockBusinessLogic = new Mock <ISportStoreBusinessLogic>(); mockBusinessLogic .Setup(bl => bl.Purchase.GetById(id)) .Returns(null as Purchase); var controller = new PurchaseController(mockBusinessLogic.Object); // Act var result = controller.Get(id); // Assert mockBusinessLogic.VerifyAll(); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }