public void TestAttributes_HoldLookedUpValuesInMemory()
        {
            using (var _dbContext = new VehicleIncidentContext(CreateNewContextOptions()))
            {
                VINAttributes    attributes;
                VINDecodeService decodeService = new VINDecodeService();
                string           vinToLookup   = "1FTNW21P04EB82562";

                attributes = decodeService.GetAttributes(vinToLookup).Result;
                _dbContext.VINAttributes.Add(attributes);
                _dbContext.SaveChanges();

                _dbContext.ContainsAttributes(vinToLookup).Should().BeTrue();
            }
        }
        public void TestAddIncident()
        {
            using (var _dbContext = new VehicleIncidentContext(CreateNewContextOptions()))
            {
                var newVehicleIncident = new VehicleIncident
                {
                    VIN      = "1FTNW21P04EB82562",
                    DateTime = DateTime.Today,
                    Note     = "Hit a pole",
                    Model    = "F-250",
                    Make     = "FORD",
                    Year     = 2004
                };

                _dbContext.VehicleIncidents.Add(newVehicleIncident);
                _dbContext.SaveChanges();

                var incidents = _dbContext.VehicleIncidents.ToList();
                incidents.Should().ContainSingle(x => x.VIN == "1FTNW21P04EB82562");
            }
        }
コード例 #3
0
 public VehicleIncidentController(VehicleIncidentContext dbContext, IVINDecodeService vinDecodeService, ILogger <VehicleIncidentController> logger)
 {
     _dbContext        = dbContext;
     _vinDecodeService = vinDecodeService;
     _logger           = logger;
 }