public void Setup()
        {
            db = new AutoResolveContext();

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
           /* server = new HttpServer(config);

            client = new HttpClient(server);*/

            client = new HttpClient();
            client.BaseAddress = new Uri(baseApiUrl);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
/*            client.BaseAddress = new Uri("http://baseaddress.com");*/

            recordsPriorCount = db.Customers.Count();

        }
        public CustomersController(IAsyncRepository<Customer> repo, IAuthoriseAccessToData<Customer> dataAccessAuthoriser, AutoResolveContext db) : base(db)
        {
            __loggingResourceName = "Customer";
            _repo = repo;
            _dataAccessAuthoriser = dataAccessAuthoriser;

        }
            public async Task should_add_new_customer__and_then_access_that_customer_and_it_should_have_the_same_properties_I_added()
            {

                _db = new AutoResolveContext();
                SUT = new CustomerAsyncRepository(_db);

                iAmANewCustomerEveryTime = new Customer
                {
                    FirstName = "IAmTheUnitTests",
                    LastName = "UnitTests",
                    Email = "*****@*****.**",
                    Telephone = "07368 27272",
                    Title = "Mr",
                };
              

                var originalName = iAmANewCustomerEveryTime.FirstName;
                var originalTele = iAmANewCustomerEveryTime.Telephone;
                var orginalEmai = iAmANewCustomerEveryTime.Email;

                var result = await SUT.Add(iAmANewCustomerEveryTime);


                result.FirstName.ShouldEqual(originalName);
                result.Email.ShouldEqual(orginalEmai);
                result.Telephone.ShouldEqual(originalTele);


            }
        public NotificationsController(IAsyncRepository<ExternalNotification> repo, IAuthoriseAccessToData<Customer> dataAccessAuthoriser, AutoResolveContext db) : base(db)
        {
            __loggingResourceName = "Notification";
            _db = db;
            _repo = repo;
            customerRepo = new CustomerAsyncRepository(_db);
            accidentRepo = new AccidentAsyncRepository(_db);
            otherDriversRepo = new OtherDriverAsyncRepository(_db);
            _dataAccessAuthoriser = dataAccessAuthoriser;

        }
            public async Task should_add_new_customer__and_return_id()
            {

                _db = new AutoResolveContext();
                SUT = new CustomerAsyncRepository(_db);

                //some context
                iAmANewCustomerEveryTime = new Customer
                {
                    FirstName = "IAmTheUnitTests",
                    LastName = "UnitTests",
                    Email = "*****@*****.**",
                    Telephone = "07368 27272",
                    Title = "Mr",
                };

                var result = await SUT.Add(iAmANewCustomerEveryTime);
                result.ShouldBeType<Customer>();                                 // returns ID
            }
        public ActionResult GetRecentAccidentLocations(string Hours = "0")
        {
            int parsedHours = 0;

            using (var db = new AutoResolveContext())
            {
                if (Int32.TryParse(Hours, out parsedHours))
                {
                    //query is hours

                }
                else
                {
                    //get all time

                }

                var locations = db.Accidents
                     .Where(x => x.Latitude != 0 && x.Longitude != 0)
                     .Select(x => new MappingLocation
                     {
                         Name = x.Customer.FirstName + " " + x.Customer.LastName,
                         AccidentDateTime = x.AccidentDateTime,
                         MapColor = "F7FF03",
                         Email = x.Customer.Email,
                         Telephone = x.Customer.Telephone,
                         Address = x.HouseNameOrNumber + " " + x.StreetName + ", " + x.PostCode,
                         Lat = x.Latitude,
                         Lng = x.Longitude
                     }).ToList();

                foreach (var location in locations)
                {
                    location.MapColor = GetMapColor(location.AccidentDateTime);
                }

                var callback = new { callback = locations};

                return new JsonpResult(callback);
            }
        }
        public void Setup()
        {
            db = new AutoResolveContext();

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/bson"));
            client.BaseAddress = new Uri("http://localhost:51108/");

            var cus = db.Customers.First();

        }
        public void Given()
        {
            _db = new AutoResolveContext();
            SUT = new AccidentAsyncRepository(_db);

            IAmAnExistingCustomer = _db.Customers.First();
            iAmAnExistingAccident = _db.Accidents.First();

            iAmANewAccidentEveryTime = new Accident
            {
                AccidentDateTime = DateTime.Now.AddDays(-1),
                Latitude = 1.000,
                Longitude = -0.1232,               
                HouseNameOrNumber = " VIA REPO 1a Test Accident",
                StreetName = "VIA REPO AccidentTest Place",
                Town = "VIA REPO AccidentTest Town",
                Country = "VIA REPO AccidentTest Country",
                PostCode = "VIA REPO Accident T1ST"              
             
            };
        }
        public void should_add_a_customer()
        {
            db = new AutoResolveContext();

            var customer = new Customer
            {

                Title = "Mr",
                FirstName = "TestCustomer",
                LastName = "Test",
                Updated = now,
                Created = now,
                Email = "test",
                Telephone = "09484 49493"

            };

            db.Customers.Add(customer);
            var result = db.SaveChanges();
            result.ShouldEqual(1);
            ;

        }
 public void Setup()
 {
     db = new AutoResolveContext();
 }
 public BaseController(AutoResolveContext db)
 {
     __db = db;
     _loggingService = new LoggingService();
     InitLogger();
 }