public async Task Update(FuelReceipt receipt)
        {
            var results = await firebase.Child(node).OnceAsync <FuelReceipt>();

            var receiptDb = results.FirstOrDefault(r => r.Object.Id == receipt.Id);
            await firebase.Child(node).Child(receiptDb.Key).PutAsync <FuelReceipt>(receipt);
        }
        public async Task Add(FuelReceipt receipt)
        {
            var receipts = await GetAll();

            receipt.Id = receipts.Count() != 0 ? receipts.Max(r => r.Id) + 1 : 1;
            await firebase.Child(node).PostAsync <FuelReceipt>(receipt);
        }
コード例 #3
0
        public void ValidTest()
        {
            //Arrange

            //Act
            FuelReceipt receipt = new FuelReceipt()
            {
                FueledCarId               = 1,
                RefuelingDate             = new DateTime(DateTime.Now.Year, 2, 1),
                PetrolStationName         = "Shell",
                FuelType                  = TypeOfFuel.LPG,
                FuelPrice                 = 2.34M,
                FuelAmount                = 44.05M,
                DistanceFromLastRefueling = 481,
                Comment = "Testowy paragon"
            };

            //Assert
            Assert.AreEqual(1, receipt.Id);
            Assert.AreEqual(1, receipt.FueledCarId);
            Assert.AreEqual(new DateTime(DateTime.Now.Year, 2, 1), receipt.RefuelingDate);
            Assert.AreEqual("Shell", receipt.PetrolStationName);
            Assert.AreEqual(TypeOfFuel.LPG, receipt.FuelType);
            Assert.AreEqual(2.34M, receipt.FuelPrice);
            Assert.AreEqual(44.05M, receipt.FuelAmount);
            Assert.AreEqual(481, receipt.DistanceFromLastRefueling);
            Assert.AreEqual("Testowy paragon", receipt.Comment);
        }
コード例 #4
0
        public async Task <ActionResult> Create(FuelReceipt fuelReceipt)
        {
            if (ModelState.IsValid)
            {
                await dbReceipt.Add(fuelReceipt);

                return(RedirectToAction("Index", new { id = fuelReceipt.FueledCarId }));
            }
            return(RedirectToAction("Create", new { id = fuelReceipt.FueledCarId }));
        }
コード例 #5
0
        public void ReceiptAddsFuel()
        {
            //Arrange
            FuelTank tank    = new FuelTank("Unleaded", 1000);
            ICommand receipt = new FuelReceipt(tank, 500);

            //Act
            receipt.Execute();
            //Assert
            Assert.AreEqual(tank.FuelLevel, 1500);
        }
コード例 #6
0
        public void ManagerHasNoPending()
        {
            //arrange
            FuelManager manager = new FuelManager();
            FuelTank    tank    = new FuelTank("Unl", 1000);
            FuelReceipt reciept = new FuelReceipt(tank, 100);

            manager.Commands.Add(reciept);
            //act
            manager.ExecuteCommands();
            //assert
            Assert.AreEqual(false, manager.HasPendingCommands());
        }
コード例 #7
0
 public static FuelReceiptViewModel ToViewModel(this FuelReceipt entity)
 {
     return(entity.MapTo <FuelReceipt, FuelReceiptViewModel>());
 }