public void NewTest1()
        {
            // Setup
            DataStore dataStore = new DataStore();
            IUserRepository userRepository = new CarTrackr.Tests.Repository.UserRepository(dataStore);
            ICarRepository carRepository = new CarTrackr.Tests.Repository.CarRepository(dataStore);
            IRefuellingRepository refuellingRepository = new CarTrackr.Tests.Repository.RefuellingRepository(dataStore);

            RefuellingController target = new RefuellingController(userRepository, carRepository, refuellingRepository);

            // Execute
            string licensePlate = "testplate1";

            ViewResult result = target.New(licensePlate) as ViewResult;

            // Verify
            Assert.AreEqual(
                carRepository.RetrieveByLicensePlate(licensePlate),
                ((NewRefuellingViewData)result.ViewData.Model).Car
            );
        }
        public void NewTest2()
        {
            // Setup
            DataStore dataStore = new DataStore();
            IUserRepository userRepository = new CarTrackr.Tests.Repository.UserRepository(dataStore);
            ICarRepository carRepository = new CarTrackr.Tests.Repository.CarRepository(dataStore);
            carRepository.User = userRepository.RetrieveByUserName("testuser1");
            IRefuellingRepository refuellingRepository = new CarTrackr.Tests.Repository.RefuellingRepository(dataStore);

            RefuellingController target = new RefuellingController(userRepository, carRepository, refuellingRepository);
            target.SetFakeControllerContext();
            target.Request.SetHttpMethodResult("POST");

            // Execute
            string licensePlate = "testplate1";
            FormCollection formCollection = new FormCollection();
            formCollection.Add("Date",DateTime.Now.ToString());
            formCollection.Add("ServiceStation","teststation3");
            formCollection.Add("Kilometers", "300");
            formCollection.Add("Liters", "100");
            formCollection.Add("PricePerLiter", "2");
            formCollection.Add("Total", "200");
            formCollection.Add("Usage", "100");

            RedirectToRouteResult result = target.New(licensePlate, formCollection) as RedirectToRouteResult;

            // Verify
            Assert.AreEqual(3,
                refuellingRepository.List(
                    carRepository.RetrieveByLicensePlate(licensePlate)
                ).Count
            );
        }
        public void RemoveTest()
        {
            // Setup
            DataStore dataStore = new DataStore();
            IUserRepository userRepository = new CarTrackr.Tests.Repository.UserRepository(dataStore);
            ICarRepository carRepository = new CarTrackr.Tests.Repository.CarRepository(dataStore);
            IRefuellingRepository refuellingRepository = new CarTrackr.Tests.Repository.RefuellingRepository(dataStore);

            RefuellingController target = new RefuellingController(userRepository, carRepository, refuellingRepository);

            // Execute
            Guid id = dataStore.Refuellings[0].Id;

            RedirectToRouteResult result = target.Remove(id) as RedirectToRouteResult;

            // Verify
            Assert.IsNull(refuellingRepository.RetrieveById(id));
        }