Example #1
0
        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());
        }
Example #2
0
        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");
        }
Example #3
0
        public void WhenAddingFillupEntry_ThenFillupAssignedNewId()
        {
            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);

            Assert.NotEqual(0, fillupEntry.FillupEntryId);
        }
Example #4
0
        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");
        }
        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");
        }
        public void WhenAddingFillupEntry_ThenFillupAssignedNewId()
        {
            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);

            Assert.NotEqual(0, fillupEntry.FillupEntryId);
        }
        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 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());
        }