public void WhenGettingAllFillups_ThenReturnsAllFillups() { var repository = new FillupRepository(); var fillupEntry1 = new FillupEntry { Date = DateTime.Now, Odometer = 3000, PricePerUnit = 3.24d, TotalUnits = 13.01d, }; repository.Create(defaultTestUser.UserId, defaultVehicle.VehicleId, fillupEntry1); var fillupEntry2 = new FillupEntry { Date = DateTime.Now, Odometer = 3001, PricePerUnit = 3.24d, TotalUnits = 13.01d, }; repository.Create(defaultTestUser.UserId, defaultVehicle.VehicleId, fillupEntry2); var fillups = repository.GetFillups(defaultVehicle.VehicleId); Assert.NotNull(fillups); Assert.Equal(2, fillups.Count()); }
public void WhenAddingFillupEntryWithAllData_ThenPersistsToTheDatabase() { var repository = new FillupRepository(); 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(defaultTestUser.UserId, defaultVehicle.VehicleId, fillupEntry); // Verification var repositoryForVerification = new FillupRepository(); var enteredFillup = repositoryForVerification.GetFillups(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 WhenGettingAllFillupsForNewVehicle_ThenReturnsEmptyCollection() { var repository = new FillupRepository(); var fillups = repository.GetFillups(defaultVehicle.VehicleId); Assert.NotNull(fillups); Assert.Equal(0, fillups.Count()); }
public void WhenAddingMinimalFillupEntry_ThenPersistsToTheDatabase() { var repository = new FillupRepository(); var fillupEntry = new FillupEntry { Date = DateTime.Now, Odometer = 3000, PricePerUnit = 3.24d, TotalUnits = 13.01d, }; repository.Create(defaultTestUser.UserId, defaultVehicle.VehicleId, fillupEntry); // Verification var repositoryForVerification = new FillupRepository(); var retrievedFillup = repositoryForVerification.GetFillups(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"); }