public TripControllerTests(ControllerFixture fixture) { Context = fixture.Context; TripRepository = fixture.TripRepository; CalendarRepository = fixture.CalendarRepository; CompanyRepository = fixture.CompanyRepository; NeighborhoodRepository = fixture.NeighborhoodRepository; PatternAreaRepository = fixture.PatternAreaRepository; PaymentTypeRepository = fixture.PaymentTypeRepository; VehicleRepository = fixture.VehicleRepository; VehicleTypeRepository = fixture.VehicleTypeRepository; }
public ControllerFixture() { Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); }); DbContextOptions <ScootertownDbContext> options; var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseInMemoryDatabase("API"); options = builder.Options; var context = new ScootertownDbContext(options, new VehicleStoreOptions()); var cache = new Mock <IMemoryCache>(); var entry = new Mock <ICacheEntry>(); int expectedKey = 1; object expectedValue = expectedKey; cache .Setup(x => x.TryGetValue(It.IsAny <object>(), out expectedValue)) .Returns(true); cache .Setup(m => m.CreateEntry(It.IsAny <object>())) .Returns(entry.Object); DeploymentRepository = new DeploymentRepository(context); TripRepository = new TripRepository(context); CollisionRepository = new CollisionRepository(context); ComplaintRepository = new ComplaintRepository(context); CalendarRepository = new CalendarRepository(context, cache.Object); CompanyRepository = new CompanyRepository(context, cache.Object); NeighborhoodRepository = new NeighborhoodRepository(context, cache.Object); PatternAreaRepository = new PatternAreaRepository(context, cache.Object); PaymentTypeRepository = new PaymentTypeRepository(context, cache.Object); PlacementReasonRepository = new PlacementReasonRepository(context, cache.Object); RemovalReasonRepository = new RemovalReasonRepository(context, cache.Object); StatusRepository = new StatusRepository(context, cache.Object); VehicleRepository = new VehicleRepository(context, cache.Object); VehicleTypeRepository = new VehicleTypeRepository(context, cache.Object); Context = context; }