public string AddPrice([Bind(Include = "PriceControllerId,ShwarmaId,Price,SellingPointId,Comment")] PriceController priceController) { return(DatabaseQueries.AddPrice(Request.Form["SellingPointTitle"], Request.Form["ShawarmaName"], priceController.Price, priceController.Comment) ? "Success" : "Error"); }
public void getPriceOfItemByOrder() { setUp(); DrinkSize drink = new DrinkSize { Small = 3.0, Large = 5.0, Ultra = 7.50, }; Price price = new Price { Drink_name = "Caffè mocha", Prices = drink }; Order order = new Order { User = "******", Drink = "Caffè mocha", Size = "large", }; PriceController pricecontroller = new PriceController(); pricecontroller.post(price); double priceOfOrder = pricecontroller.getPriceByOrder(order); Assert.Equal(drink.Large, priceOfOrder); }
public void Constructor_NullRepository_Throws() { Assert.Throws <ArgumentNullException>(() => { var _ = new PriceController(null); }); }
/// <summary> /// Gets a complete <see cref="Summary"/> object for the specified <see cref="VehicleFamily"/>. /// </summary> /// <param name="vehicleFamily">The <see cref="VehicleFamily"/> to analyze.</param> public Summary GetCompleteSummary(VehicleFamily vehicleFamily) { var numberOfVehicles = GetNumberOfVehicles(vehicleFamily); var fairingSummary = FairingController.GetFairingSummary(vehicleFamily); var priceSummary = PriceController.GetPriceSummary(vehicleFamily); var capabilitySummary = CapabilityController.GetCapabilitySummary(vehicleFamily).ToList(); return(new Summary(numberOfVehicles, capabilitySummary, fairingSummary, priceSummary)); }
/// <summary> /// Gets a complete <see cref="Summary"/> object for the specified <see cref="LauncherCollection"/>. /// </summary> /// <param name="launcherCollection">The <see cref="LauncherCollection"/> to analyze.</param> public Summary GetCompleteSummary(LauncherCollection launcherCollection) { var numberOfVehicles = launcherCollection.Launchers.Count; var fairingSummary = FairingController.GetFairingSummary(launcherCollection.Launchers); var priceSummary = PriceController.GetPriceSummary(launcherCollection.Launchers); var capabilitySummary = CapabilityController.GetCapabilitySummary(launcherCollection.Launchers).ToList(); return(new Summary(numberOfVehicles, capabilitySummary, fairingSummary, priceSummary)); }
public void GetAllPricesReturnsListOfPrices() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.GetAll()).Returns(productList); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var result = priceController.GetAllPrices(); var contentResult = result as ActionResult <IEnumerable <Product> >; Assert.NotNull(contentResult.Value); }
public void AddingValidPriceReturnsSuccess() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.Save(validProduct)).Returns("Success."); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var result = priceController.AddPrice(validProduct); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Success."); }
public void UpdateValidExistingPriceReturnsSuccess() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.Update(validProduct)).Returns("Success."); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var updateResult = priceController.UpdatePrice(validProduct); var updateContentResult = updateResult as ActionResult <string>; Assert.AreEqual(updateContentResult.Value, "Success."); }
public void Create(DalPriceController e) { var PriceController = new PriceController() { PriceControllerID = e.Id, Price = e.Price, Comment = e.Comment, ShawarmaID = e.ShawarmaID, SellingPointID = e.SellingPointID }; Context.Set <PriceController>().Add(PriceController); }
public void UpdateNonExistentPriceReturnsError() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.Update(nonExistentProduct)) .Returns("Product does not exist, create product before updating price."); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var updateResult = priceController.UpdatePrice(nonExistentProduct); var updateContentResult = updateResult as ActionResult <string>; Assert.AreEqual(updateContentResult.Value, "Product does not exist, create product before updating price."); }
public void UpdateInvalidExistingPriceReturnsError() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.Update(invalidProduct)) .Returns("Error: Price must be bigger than 0."); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var updateResult = priceController.UpdatePrice(invalidProduct); var updateContentResult = updateResult as ActionResult <string>; Assert.AreEqual(updateContentResult.Value, "Error: Price must be bigger than 0."); }
public async Task <ActionResult> Create([Bind(Include = "PriceControllerId,ShwarmaId,Price,SellingPointId,Comment")] PriceController priceController) { if (ModelState.IsValid) { db.PriceControllers.Add(priceController); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ShwarmaId = new SelectList(db.Shawarmas, "ShawarmaId", "ShawarmaName", priceController.ShwarmaId); ViewBag.SellingPointId = new SelectList(db.SellingPoints, "SellingPointId", "Address", priceController.SellingPointId); return(View(priceController)); }
public void AddingInvalidPriceReturnsErrorMessage() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.Save(invalidProduct)) .Returns("Error: Price must be bigger than 0."); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); var result = priceController.AddPrice(invalidProduct); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Price must be bigger than 0."); }
// GET: PriceControllers/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PriceController priceController = await db.PriceControllers.FindAsync(id); if (priceController == null) { return(HttpNotFound()); } return(View(priceController)); }
int calculatePrice() { int newPrice = 0; foreach (Transform child in collection.transform) { PriceController childPrice = child.GetComponent <PriceController>(); if (childPrice != null) { newPrice += childPrice.Price; } } return(newPrice); }
public void GetPriceForSpecificProductReturnsPrice() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.GetAmountByProductName(validProduct.ProductName)).Returns(2.5f); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); string productName = "Can of soup"; var priceResult = priceController.GetPrice(productName); var priceContentResult = priceResult as ActionResult <float>; Assert.AreEqual(priceContentResult.Value, 2.5f); }
public void GetPriceForNonExistentProductReturnsZero() { Mock <IDataAccessor <Product> > mockPriceDataAccessor = new Mock <IDataAccessor <Product> >(); mockPriceDataAccessor.Setup(x => x.GetAmountByProductName(nonExistentProduct.ProductName)).Returns(0); PriceController priceController = new PriceController(mockPriceDataAccessor.Object); string productName = "Bananas"; var priceResult = priceController.GetPrice(productName); var priceContentResult = priceResult as ActionResult <float>; Assert.AreEqual(priceContentResult.Value, 0); }
public override void StartDay(GameDate thisDate) { PriceHistory.Add(Price); if (Buffs.Any(buff => buff is RedBuff)) { //Todo:ChangeToUseAnotherController } PriceController.StartDay(thisDate); TodayAnticipate = PriceController.GetPrice( ); Price = new StockPrice(TodayAnticipate.OpenPrice, TodayAnticipate.OpenPrice, TodayAnticipate.OpenPrice, TodayAnticipate.OpenPrice, 0, 0); }
public void Update(DalPriceController e) { var PriceController = new PriceController() { PriceControllerID = e.Id, Price = e.Price, Comment = e.Comment, ShawarmaID = e.ShawarmaID, SellingPointID = e.SellingPointID }; PriceController = Context.Set <PriceController>().Single(i => i.PriceControllerID == e.Id); PriceController.Price = e.Price; PriceController.Comment = e.Comment; PriceController.ShawarmaID = e.ShawarmaID; PriceController.SellingPointID = e.SellingPointID; }
public async Task When_Price_Is_Given_Null_It_Should_Be_Return_NotFound() { Price nullPrice = null; var priceRepositoryMock = new Mock <IPriceRepository>(); priceRepositoryMock.Setup(p => p.GetPriceByProductId(new PriceRequestModel() { ProductId = 5, RequestDate = DateTime.UtcNow })).Returns(Task.FromResult(nullPrice)); var priceController = new PriceController(priceRepositoryMock.Object); var priceRequestModel = new PriceRequestModel() { ProductId = 5, RequestDate = new DateTime(2020, 5, 5) }; var actionResult = await priceController.GetProductPrice(priceRequestModel); actionResult.Should().BeOfType <NotFoundObjectResult>(); }
public PriceControllerTest() { var connection = "TESTDB"; var options = new DbContextOptionsBuilder <SiCContext>() .UseInMemoryDatabase(connection) .Options; context = new SiCContext(options); List <Price> prices = new List <Price>(); foreach (Price p in context.Price) { prices.Add(p); } if (prices.Count == 0) { Price mock1 = new Price(); mock1.date = DateTime.Parse("2019-01-06"); mock1.designation = "Test_Designation"; mock1.price = 25.55; Price mock2 = new Price(); mock2.date = DateTime.Parse("2019-01-07"); mock2.designation = "Second_Test_Designation"; mock2.price = 50.0; Price mock3 = new Price(); mock3.date = DateTime.Parse("2019-01-08"); mock3.designation = "Test_Designation"; mock3.price = 20.30; context.Price.Add(mock1); context.Price.Add(mock2); context.Price.Add(mock3); context.SaveChanges(); } controller = new PriceController(context); }
bool isNewPrice() { int newNumOfPrices = 0; foreach (Transform child in collection.transform) { PriceController childPrice = child.GetComponent <PriceController>(); if (childPrice != null) { newNumOfPrices++; } } if (newNumOfPrices > numOfPrices) { numOfPrices = newNumOfPrices; return(true); } else { return(false); } }
public async Task When_Price_Is_Given_It_Should_Be_Return_Ok() { Price price = new Price() { Id = "10101", ProductId = 5, Value = 10, CampaignId = 10, IsActive = true }; var priceRequestModel = new PriceRequestModel() { ProductId = 5, RequestDate = DateTime.UtcNow }; var priceRepositoryMock = new Mock <IPriceRepository>(); priceRepositoryMock.Setup(p => p.GetPriceByProductId(priceRequestModel)).Returns(Task.FromResult(price)); var priceController = new PriceController(priceRepositoryMock.Object); var actionResult = await priceController.GetProductPrice(priceRequestModel); actionResult.Should().BeOfType <OkObjectResult>(); }
public void TestMethodControllerCalculateTotalPrice() { Prices price = new Prices(_itemcollect, _discount); PriceController controller = new PriceController(price); // This version uses a mock UrlHelper. // Arrange Item item1 = new Item(1, "SO", 100, 1, "Soap"); Item item2 = new Item(2, "BK", 15, 3, "Book"); Item item3 = new Item(2, "CH", 11, 2, "Chair"); // Act var response = controller.DisplayPrice(item2); OkObjectResult res = new OkObjectResult(200); res.StatusCode = 200; res.Value = 45.0; // Assert // response.Should().Be(res); Assert.AreEqual(res.Value, 45.0); Assert.AreEqual(res.StatusCode, 200); }
void Start() { CreatePlayer(); LoadPlayer(); InitializeShareDict(); funds = localPlayerData.funds; shareDict = localPlayerData.shares; InitializeStockBarDict(); healthBar.SetSize(funds / max_bar); termObjectArr = FindObjectsOfType <TermSetActive>(); priceTuples = new Tuple <string, float> [termObjectArr.Length]; for (int i = 0; i < termObjectArr.Length; i++) { Tuple <string, float> entry = new Tuple <string, float>("TSLA", 100f); priceTuples[i] = entry; termObjectArr[i].SetValue(500f); } priceController = FindObjectOfType <PriceController>(); GetPriceDict(); }
public void Setup() { _mockMediator = new Mock <IMediator>(); _controller = new PriceController(_mockMediator.Object); }
public PriceControllerTests() { _cryptoProviderMock = new Mock <ICryptoProvider>(); _priceHubPoolMock = new Mock <IPriceTaskPool>(); _controller = new PriceController(_cryptoProviderMock.Object, _priceHubPoolMock.Object); }