public void PrepareTesting() { //Connect manually to the database this._conn = new MySqlConnection( "SERVER=localhost;" + "DATABASE=px3-test;" + "UID=root;" + "PASSWORD=abcd1234;"); this._conn.Open(); //Clean the database manually this.CleanUpAfterEachTest(); //Write to database this.PrepareForEachTest(); //Login DAOFactory.ConnectionString = "SERVER=localhost;" + "DATABASE=px3-test;" + "UID=root;" + "PASSWORD=abcd1234;"; VoterListApp.CurrentUser = User.GetUser("jdmo", "12345"); _dao = DAOFactory.getDAO(VoterListApp.CurrentUser); //Clean the database manually this.CleanUpAfterEachTest(); }
public void GetShopList() { IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); var result = database.GetShopList("Test"); }
public DAOPermissionProxy(User u, IDataAccessObject dao) { Contract.Requires(u != null); Contract.Requires(dao != null); _user = u; _dao = dao; }
public void AddShopListItem() { // Arrage IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); var item = new IngredientDto() { Amount = 3, IngredientName = "Test", Unit = "Test" }; // Act database.AddShopListItem("db1500c7-f616-45d3-8069-14a9f264f2fa", item); // Assert var list = database.GetShopList("db1500c7-f616-45d3-8069-14a9f264f2fa"); foreach (var i in list) { if (i.IngredientName == "Test") { database.DeleteRecipe("Test"); Assert.Pass(); } } Assert.Fail(); }
public void DeleteShopListItem() { // Arrange IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); database.AddShopListItem("db1500c7-f616-45d3-8069-14a9f264f2fa", new IngredientDto() { IngredientName = "toDelete" }); // Act database.DeleteShopListItem("db1500c7-f616-45d3-8069-14a9f264f2fa", "toDelete"); // Assert var list = database.GetShopList("db1500c7-f616-45d3-8069-14a9f264f2fa"); foreach (var i in list) { if (i.IngredientName == "toDelete") { Assert.Fail(); } } Assert.Pass(); }
public void Setup() { var mockCluster1 = new Mock <ICluster>(); mockCluster1.Setup(x => x.Id).Returns(_cluster1Guid); mockCluster1.Setup(x => x.Name).Returns("cluster1"); mockCluster1.Setup(x => x.Type).Returns("cluster"); var mockCluster2 = new Mock <ICluster>(); mockCluster2.Setup(x => x.Id).Returns(_cluster2Guid); mockCluster2.Setup(x => x.Name).Returns("cluster2"); mockCluster2.Setup(x => x.Type).Returns("cluster"); _clusters = new ClusterCollection { mockCluster1.Object, mockCluster2.Object }; _dao = new InMemoryDataAccessObject(); _dao.AddAsync(new ClusterConnectionEntity { Id = _clusterConnection1Guid, ClusterType = "cluster", Description = "fake cluster connection", Name = "FakeClusterConnection", }); _controller = new ClusterConnectionsController(_logger, _clusters, _dao); }
public void DeleteRecipeTest() { // Arrange IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); database.AddRecipe(new RecipeDto() { Name = "Test", Amount = 0, PreparationDescription = "Preparation test", PreparationTime = TimeSpan.FromMinutes(30), SkillLevel = "Skill level test" }); // Act database.DeleteRecipe("Test"); // Assert List <RecipeSimplifiedDto> list = database.GetRecipeList(); foreach (RecipeSimplifiedDto r in list) { if (r.Name == "Test") { Assert.Fail(); } } }
// GET: api/ShopList/TestUser public List <IngredientDto> Get(string userId) { IDataAccessObject dao = daoFactory.GetDao(); var result = dao.GetShopList(userId); return(result); }
public IQueryable <GetModel> GetByPlate( string plate, [FromServices] IDataAccessObject <ReadModel.Vehicle> vehicleDataAccessObject, [FromServices] IMapper mapper) { return(vehicleDataAccessObject.Where(p => p.Plate.Contains(plate)).ProjectTo <GetModel>(mapper.ConfigurationProvider)); }
public IEnumerable <GetModel> Get( [FromServices] IConfiguration configuration, [FromServices] IDataAccessObject <History> dataAccessObject, [FromServices] IMapper mapper) { return(ResolvePhotoUri(configuration, dataAccessObject.ProjectTo <GetModel>(mapper.ConfigurationProvider))); }
public async Task <IEnumerable <GetModel> > Get([FromServices] IDataAccessObject <ReadModel.Suggestion> suggestionsDataAccessObject) { return(await suggestionsDataAccessObject.Select(d => new GetModel { Id = d.MovieId, Affinity = d.Affinity, }).ToArrayAsync()); }
public Dashboard(IDataAccessObject dao) { _dao = dao ?? throw new ArgumentNullException(nameof(dao)); InitializeComponent(); userDisplayList.DataSource = _users; userDisplayList.DisplayMember = nameof(UserDTO.FullName); DisplayUsersFromDb(IDataAccessObjectConstants.NoFilter); }
public JobSubmitExecutor(ILogger <JobSubmitExecutor> logger, ClusterApiService clusterService, IDataAccessObject dao) { _logger = logger; _clusterService = clusterService; _dao = dao; }
public void SetHasVoted() { Contract.Requires(DAOFactory.Ready); IDataAccessObject dao = DAOFactory.CurrentUserDAO; dao.SetHasVoted(this); HasVoted = true; }
public IEnumerable <GetModel> Get( [FromServices] IConfiguration configuration, [FromServices] IDataAccessObject <History> dataAccessObject, [FromServices] IMapper mapper, string vehicleId) { return(ResolvePhotoUri(configuration, dataAccessObject.Where(d => d.VehicleId == vehicleId) .ProjectTo <GetModel>(mapper.ConfigurationProvider))); }
public RoomLoadIndexDAL() { _dao = (new GetDatabase()).GetDataAccessObject(); _lang = JCBase.UI.LangType.CurrentLanguage; if (_lang == "pt-BR") //因为葡萄牙语 还没有增加对应LoadCity 及 LoadIndex 所以直接使用默认英语的值 on 20180418 by xyj { _lang = "en-US"; } }
/// <summary> /// Copies the object to an existing entity of type <typeparamref name="TDestType" /> by mapping their properties one-to-one /// </summary> /// <typeparam name="TDestType">The type of destination entity</typeparam> /// <param name="entity">The entity that will be copied</param> /// <param name="destination">The entity that will be modified</param> public static void CopyTo <TDestType>(this IDataAccessObject entity, TDestType destination) where TDestType : class { if (entity == null) { return; } MapperService.CopyTo(entity, destination); }
public RecipeDto GetRecipe(int id) { IDataAccessObject dao = daoFactory.GetDao(); return(new RecipeDto() { adaptee = dao.GetRecipe(id) }); }
public DataTable LoadActiveLanguage() { string sql = "select * from JCHVRF_Language where IsActive=1"; _dao = (new GetDatabase()).GetDataAccessObject(); DataTable dtsql = _dao.GetDataTable(sql); return(dtsql); }
public MovieController(WebApiMapper webApiMapper, IBus bus, IRepository <Movie> movieRepository, IDataAccessObject <MovieRead> modelDataAccessObject) { _bus = bus; _movieRepository = movieRepository; _modelDataAccessObject = modelDataAccessObject; _webApiMapper = webApiMapper.Mapper.ConfigurationProvider; }
/// <summary> /// Initializes a new instance of the <c>ProjectsController</c> class. /// </summary> /// <param name="dao">The data access object used for accessing the projects information.</param> /// <param name="logger">The logger used for logging.</param> /// <param name="jobsApiService">The job API service.</param> /// <param name="configuration">The configuration.</param> public ProjectsController(IDataAccessObject dao, ILogger <ProjectsController> logger, JobsApiService jobsApiService, IConfiguration configuration) { (_jobsApiService, _dao, _logger, _configuration) = (jobsApiService, dao, logger, configuration); maxReservedRevisions = configuration[MaxReservedRevisionsConfigKey] == null ? DefaultMaxReservedRevisions : Convert.ToInt32(configuration[MaxReservedRevisionsConfigKey]); }
public SuggestionController(WebApiMapper webApiMapper, IBus bus, IRepository <DomainModel.Suggestion> suggestionRepository, IDataAccessObject <ReadModel.Suggestion> suggestionDataAccessObject) { _bus = bus; _suggestionRepository = suggestionRepository; _suggestionDataAccessObject = suggestionDataAccessObject; _webApiMapper = webApiMapper.Mapper.ConfigurationProvider; }
/// <summary> /// Initializes a new instance of the <see cref="CustomersController"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="eventBus">The event bus.</param> /// <param name="dao">The DAO.</param> /// <param name="logger">The logger.</param> public CustomersController(IConfiguration configuration, IEventBus eventBus, IDataAccessObject dao, ILogger <CustomersController> logger) { this.configuration = configuration; this.connectionString = configuration["postgresql:connectionString"]; this.eventBus = eventBus; this.dao = dao; this.logger = logger; }
public bool FindFile(string fileName, IDataAccessObject dataAccess) { if (dataAccess == null) { throw new ArgumentNullException(nameof(dataAccess)); } var files = dataAccess.GetFiles(); return(files.Any(x => x == fileName)); }
public AccountService() { bankDataAccessObject = new BankDataAccessObject(); _accounts = bankDataAccessObject.GetEntities(); if (_accounts == null) { _accounts = new List <Account>(); } disposed = false; }
public SuggestionHandler( ILogger <SuggestionHandler> logger, IBus bus, IRepository <Suggestion> suggestionRepository, IDataAccessObject <ReadModel.Suggestion> suggestionsDataAccessObject ) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _bus = bus ?? throw new ArgumentNullException(nameof(bus)); _suggestionRepository = suggestionRepository ?? throw new ArgumentNullException(nameof(suggestionRepository)); _suggestionsDataAccessObject = suggestionsDataAccessObject ?? throw new ArgumentNullException(nameof(suggestionsDataAccessObject)); }
public MovieHandler( ILogger <MovieHandler> logger, IBus bus, IRepository <Movie> movieRepository, IDataAccessObject <MovieRead> movieDataAccessObject ) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _bus = bus ?? throw new ArgumentNullException(nameof(bus)); _movieRepository = movieRepository ?? throw new ArgumentNullException(nameof(movieRepository)); _movieDataAccessObject = movieDataAccessObject; }
/// <summary> /// What user has this login? /// </summary> /// <param name="username">Username</param> /// <param name="password">Password</param> /// <returns>A validated user obejct, or null if the login is not found.</returns> public static User GetUser(string username, string password) { Contract.Requires(DAOFactory.Ready); IDataAccessObject dao = DAOFactory.CurrentUserDAO; User u = dao.LoadUser(username); if (u == null) { return(null); } u.FetchPermissions(username, password); return(u.Validated ? u : null); }
public MovieHandlers( ILogger <MovieHandlers> logger, IBus bus, IUserAccessor userAccessor, IRepository <Movie> repository, IDataAccessObject <ReadModel.Movie> dataAccessObject) { _logger = logger; _bus = bus; _userAccessor = userAccessor; _repository = repository; _dataAccessObject = dataAccessObject; }
public VehicleHandlers( ILogger <VehicleHandlers> logger, IBus bus, IUserAccessor userAccessor, IRepository <DomainModel.Vehicle> repository, IDataAccessObject <ReadModel.Vehicle> dataAccessObject) { _logger = logger; _bus = bus; _userAccessor = userAccessor; _repository = repository; _dataAccessObject = dataAccessObject; }
public FileManager(IDataAccessObject dataAccessObject) { this.dataAccessObject = dataAccessObject; }
public HomeController(IDataAccessObject<Beer> beerDao) { _beerDao = beerDao; }