public void WhenAddingFillupEntryWithAllData_ThenPersistsToTheDatabase()
        {
            var repository = new FillupRepository(this.GetUnitOfWork());

            var fillupEntry = new FillupEntry()
                                  {
                                      Date = DateTime.Now,
                                      Odometer = 3000,
                                      PricePerUnit = 3.24d,
                                      TotalUnits = 13.01d,
                                      Remarks = "Remarkable",
                                      TransactionFee = 1.25d,
                                      Vendor = "Ideal Vendor"
                                  };

            repository.Create(this.defaultTestUser.UserId, this.defaultVehicle.VehicleId, fillupEntry);

            // Verification
            var repositoryForVerification = new FillupRepository(this.GetUnitOfWork());
            var enteredFillup = repositoryForVerification.GetFillups(this.defaultVehicle.VehicleId).First();
            Assert.NotNull(enteredFillup);
            Assert.Equal(fillupEntry.Date.ToShortDateString(), enteredFillup.Date.ToShortDateString());
            // We only care that the dates map.
            AssertExtensions.PropertiesAreEqual(fillupEntry, enteredFillup, "Odometer", "PricePerUnit", "TotalUnits",
                                                "Remarks", "TransactionFee", "Vendor");
        }
        public void WhenAddingFillupEntry_ThenFillupAssignedNewId()
        {
            var repository = new FillupRepository(this.GetUnitOfWork());

            var fillupEntry = new FillupEntry()
                                  {
                                      Date = DateTime.Now,
                                      Odometer = 3000,
                                      PricePerUnit = 3.24d,
                                      TotalUnits = 13.01d,
                                  };

            repository.Create(this.defaultTestUser.UserId, this.defaultVehicle.VehicleId, fillupEntry);

            Assert.NotEqual(0, fillupEntry.FillupEntryId);
        }
        public void WhenAddingMinimalFillupEntry_ThenPersistsToTheDatabase()
        {
            var repository = new FillupRepository(this.GetUnitOfWork());

            var fillupEntry = new FillupEntry()
                                  {
                                      Date = DateTime.Now,
                                      Odometer = 3000,
                                      PricePerUnit = 3.24d,
                                      TotalUnits = 13.01d,
                                  };

            repository.Create(this.defaultTestUser.UserId, this.defaultVehicle.VehicleId, fillupEntry);

            // Verification
            var repositoryForVerification = new FillupRepository(this.GetUnitOfWork());
            var retrievedFillup = repositoryForVerification.GetFillups(this.defaultVehicle.VehicleId).First();

            Assert.NotNull(retrievedFillup);
            Assert.Equal(fillupEntry.Date.ToShortDateString(), retrievedFillup.Date.ToShortDateString());
            // We only care that the dates map.
            AssertExtensions.PropertiesAreEqual(fillupEntry, retrievedFillup, "Odometer", "PricePerUnit", "TotalUnits");
        }
        public void WhenGettingAllFillups_ThenReturnsAllFillups()
        {
            var repository = new FillupRepository(this.GetUnitOfWork());

            var fillupEntry1 = new FillupEntry()
                                   {
                                       Date = DateTime.Now,
                                       Odometer = 3000,
                                       PricePerUnit = 3.24d,
                                       TotalUnits = 13.01d,
                                   };
            repository.Create(this.defaultTestUser.UserId, this.defaultVehicle.VehicleId, fillupEntry1);

            var fillupEntry2 = new FillupEntry()
                                   {
                                       Date = DateTime.Now,
                                       Odometer = 3001,
                                       PricePerUnit = 3.24d,
                                       TotalUnits = 13.01d,
                                   };
            repository.Create(this.defaultTestUser.UserId, this.defaultVehicle.VehicleId, fillupEntry2);

            var fillups = repository.GetFillups(this.defaultVehicle.VehicleId);

            Assert.NotNull(fillups);
            Assert.Equal(2, fillups.Count());
        }
        public void WhenGettingAllFillupsForNewVehicle_ThenReturnsEmptyCollection()
        {
            var repository = new FillupRepository(this.GetUnitOfWork());

            var fillups = repository.GetFillups(this.defaultVehicle.VehicleId);

            Assert.NotNull(fillups);
            Assert.Equal(0, fillups.Count());
        }