コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public void GetShopList()
        {
            IDataAccessObjectFactory factory  = DatabaseFactory.GetInstance();
            IDataAccessObject        database = factory.GetDao();

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

            return(result);
        }
コード例 #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));
 }
コード例 #12
0
 public IEnumerable <GetModel> Get(
     [FromServices] IConfiguration configuration,
     [FromServices] IDataAccessObject <History> dataAccessObject,
     [FromServices] IMapper mapper)
 {
     return(ResolvePhotoUri(configuration, dataAccessObject.ProjectTo <GetModel>(mapper.ConfigurationProvider)));
 }
コード例 #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());
 }
コード例 #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);
 }
コード例 #15
0
ファイル: JobSubmitExecutor.cs プロジェクト: daxnet/abacuza
 public JobSubmitExecutor(ILogger <JobSubmitExecutor> logger,
                          ClusterApiService clusterService,
                          IDataAccessObject dao)
 {
     _logger         = logger;
     _clusterService = clusterService;
     _dao            = dao;
 }
コード例 #16
0
        public void SetHasVoted()
        {
            Contract.Requires(DAOFactory.Ready);
            IDataAccessObject dao = DAOFactory.CurrentUserDAO;

            dao.SetHasVoted(this);
            HasVoted = true;
        }
コード例 #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)));
 }
コード例 #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";
     }
 }
コード例 #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);
        }
コード例 #20
0
ファイル: Service.cs プロジェクト: bartoszburas/cookbookapp
        public RecipeDto GetRecipe(int id)
        {
            IDataAccessObject dao = daoFactory.GetDao();

            return(new RecipeDto()
            {
                adaptee = dao.GetRecipe(id)
            });
        }
コード例 #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);
        }
コード例 #22
0
ファイル: MovieController.cs プロジェクト: paonath/Samples
 public MovieController(WebApiMapper webApiMapper,
                        IBus bus,
                        IRepository <Movie> movieRepository,
                        IDataAccessObject <MovieRead> modelDataAccessObject)
 {
     _bus                   = bus;
     _movieRepository       = movieRepository;
     _modelDataAccessObject = modelDataAccessObject;
     _webApiMapper          = webApiMapper.Mapper.ConfigurationProvider;
 }
コード例 #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]);
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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));
        }
コード例 #27
0
        public AccountService()
        {
            bankDataAccessObject = new BankDataAccessObject();
            _accounts            = bankDataAccessObject.GetEntities();

            if (_accounts == null)
            {
                _accounts = new List <Account>();
            }

            disposed = false;
        }
コード例 #28
0
ファイル: SuggestionHandler.cs プロジェクト: paonath/Samples
 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));
 }
コード例 #29
0
ファイル: MovieHandler.cs プロジェクト: paonath/Samples
 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;
 }
コード例 #30
0
ファイル: User.cs プロジェクト: hyllekilde/PX3-BDSA-E2011
        /// <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);
        }
コード例 #31
0
ファイル: MovieHandlers.cs プロジェクト: paonath/Samples
 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;
 }
コード例 #32
0
 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;
 }
コード例 #33
0
ファイル: FileManager.cs プロジェクト: master-vk/Tasks-ITVDN
 public FileManager(IDataAccessObject dataAccessObject)
 {
     this.dataAccessObject = dataAccessObject;
 }
コード例 #34
0
 public HomeController(IDataAccessObject<Beer> beerDao)
 {
     _beerDao = beerDao;
 }