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 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();
        }
Exemplo n.º 3
0
        public void GetShopList()
        {
            IDataAccessObjectFactory factory  = DatabaseFactory.GetInstance();
            IDataAccessObject        database = factory.GetDao();

            var result = database.GetShopList("Test");
        }
Exemplo n.º 4
0
 public DAOPermissionProxy(User u, IDataAccessObject dao)
 {
     Contract.Requires(u != null);
     Contract.Requires(dao != null);
     _user = u;
     _dao  = dao;
 }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 8
0
        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();
                }
            }
        }
 public DAOPermissionProxy(User u, IDataAccessObject dao)
 {
     Contract.Requires(u != null);
     Contract.Requires(dao != null);
     _user = u;
     _dao = dao;
 }
Exemplo n.º 10
0
        // GET: api/ShopList/TestUser
        public List <IngredientDto> Get(string userId)
        {
            IDataAccessObject dao = daoFactory.GetDao();
            var result            = dao.GetShopList(userId);

            return(result);
        }
Exemplo n.º 11
0
 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));
 }
Exemplo n.º 12
0
 public IEnumerable <GetModel> Get(
     [FromServices] IConfiguration configuration,
     [FromServices] IDataAccessObject <History> dataAccessObject,
     [FromServices] IMapper mapper)
 {
     return(ResolvePhotoUri(configuration, dataAccessObject.ProjectTo <GetModel>(mapper.ConfigurationProvider)));
 }
Exemplo n.º 13
0
 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());
 }
Exemplo n.º 14
0
 public Dashboard(IDataAccessObject dao)
 {
     _dao = dao ?? throw new ArgumentNullException(nameof(dao));
     InitializeComponent();
     userDisplayList.DataSource    = _users;
     userDisplayList.DisplayMember = nameof(UserDTO.FullName);
     DisplayUsersFromDb(IDataAccessObjectConstants.NoFilter);
 }
Exemplo n.º 15
0
 public JobSubmitExecutor(ILogger <JobSubmitExecutor> logger,
                          ClusterApiService clusterService,
                          IDataAccessObject dao)
 {
     _logger         = logger;
     _clusterService = clusterService;
     _dao            = dao;
 }
Exemplo n.º 16
0
        public void SetHasVoted()
        {
            Contract.Requires(DAOFactory.Ready);
            IDataAccessObject dao = DAOFactory.CurrentUserDAO;

            dao.SetHasVoted(this);
            HasVoted = true;
        }
Exemplo n.º 17
0
 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)));
 }
Exemplo n.º 18
0
 public RoomLoadIndexDAL()
 {
     _dao  = (new GetDatabase()).GetDataAccessObject();
     _lang = JCBase.UI.LangType.CurrentLanguage;
     if (_lang == "pt-BR")  //因为葡萄牙语 还没有增加对应LoadCity 及 LoadIndex 所以直接使用默认英语的值 on 20180418 by xyj
     {
         _lang = "en-US";
     }
 }
Exemplo n.º 19
0
        /// <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);
        }
Exemplo n.º 20
0
        public RecipeDto GetRecipe(int id)
        {
            IDataAccessObject dao = daoFactory.GetDao();

            return(new RecipeDto()
            {
                adaptee = dao.GetRecipe(id)
            });
        }
Exemplo n.º 21
0
        public DataTable LoadActiveLanguage()
        {
            string sql = "select * from JCHVRF_Language where IsActive=1";

            _dao = (new GetDatabase()).GetDataAccessObject();

            DataTable dtsql = _dao.GetDataTable(sql);

            return(dtsql);
        }
Exemplo n.º 22
0
 public MovieController(WebApiMapper webApiMapper,
                        IBus bus,
                        IRepository <Movie> movieRepository,
                        IDataAccessObject <MovieRead> modelDataAccessObject)
 {
     _bus                   = bus;
     _movieRepository       = movieRepository;
     _modelDataAccessObject = modelDataAccessObject;
     _webApiMapper          = webApiMapper.Mapper.ConfigurationProvider;
 }
Exemplo n.º 23
0
 /// <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]);
 }
Exemplo n.º 24
0
 public SuggestionController(WebApiMapper webApiMapper,
                             IBus bus,
                             IRepository <DomainModel.Suggestion> suggestionRepository,
                             IDataAccessObject <ReadModel.Suggestion> suggestionDataAccessObject)
 {
     _bus = bus;
     _suggestionRepository       = suggestionRepository;
     _suggestionDataAccessObject = suggestionDataAccessObject;
     _webApiMapper = webApiMapper.Mapper.ConfigurationProvider;
 }
Exemplo n.º 25
0
 /// <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;
 }
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 28
0
 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));
 }
Exemplo n.º 29
0
 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;
 }
Exemplo n.º 30
0
        /// <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);
        }
Exemplo n.º 31
0
 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;
 }
Exemplo n.º 33
0
 public FileManager(IDataAccessObject dataAccessObject)
 {
     this.dataAccessObject = dataAccessObject;
 }
Exemplo n.º 34
0
 public HomeController(IDataAccessObject<Beer> beerDao)
 {
     _beerDao = beerDao;
 }