public UnitOfWork(DBContext db) { _db = db; Games = new GameRepository(db); Ships = new ShipRepository(db); ActionShipInstalls = new ActionShipInstallRepository(db); ActionMoves = new ActionMoveRepository(db); }
/// <summary> /// Initializes a new instance of the <see cref="ShipRepositoryTest"/> class. /// </summary> public ShipRepositoryTest() { Common.Dependencies.Register(); DataAccess.Dependencies.Register(); DIContainer.Instance.Resolve<IApplicationSetting>().ShipServiceBaseAddress = "http://Localhost/"; DIContainer.Instance.RegisterType<ILocationClient, LocationClient>(); DIContainer.Instance.RegisterType<IStateroomCategoriesClient, StateroomCategoriesClient>(); DIContainer.Instance.RegisterType<IStateroomCategoryTypesClient, StateroomCategoryTypesClient>(); DIContainer.Instance.RegisterType<IStateroomClient, StateroomClient>(); DIContainer.Instance.RegisterType<IShipClient, ShipClient>(); DIContainer.Instance.RegisterType<ISafetyRoleClient, SafetyRoleClient>(); this.repository = new ShipRepository(); }
public void AddEntity() { using (var context = new DataContext()) { IRepository <Dock> dockRepository = new DockRepository(context); IRepository <Engineer> engineerRepository = new EngineerRepository(context); IRepository <Pilot> pilotRepository = new PilotRepository(context); IRepository <Ship> shipRepository = new ShipRepository(context); IRepository <Station> stationRepository = new StationRepository(context); var station = new Station { Name = StationName, Location = StationLocation }; var dock = new Dock { Name = "First dock", CountOfShipsPlaces = 3 }; var engineer = new Engineer { FirstName = "Ivan", MiddleName = "Ivanovich", LastName = "Ivanov", Biography = "Very powerfully engineer", Qualification = "Welder" }; var pilot = new Pilot { FirstName = "Raman", MiddleName = "Igorevich", LastName = "Dzianishchyk", Biography = "Born in bla-bla-bla-blar", ExperienceFlights = 3 }; var ship = new Ship { Name = "Impetuous" }; station.Docks = new List <Dock>() { dock }; station.Engineers = new List <Engineer>() { engineer }; pilot.OwnShip = ship; ship.DockRegistry = dock; dock.Engineers = new List <Engineer>() { engineer }; stationRepository.Add(station); dockRepository.Add(dock); engineerRepository.Add(engineer); pilotRepository.Add(pilot); shipRepository.Add(ship); Assert.IsTrue( stationRepository.Count(null) > 0 && shipRepository.Count(null) > 0 && pilotRepository.Count(null) > 0 && engineerRepository.Count(null) > 0 && dockRepository.Count(null) > 0); } }
public void Setup() { contextMock = new Mock <ApplicationContext>(); repository = new ShipRepository(contextMock.Object); }