public BaseServiceTest()
        {
            // Настройка тестовых строк подключения.
            var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");

            AppConfiguration    = builder.Build();
            MsSqlConfigString   = AppConfiguration["ConnectionStrings:TestMsSqlConnection"];
            PostgreConfigString = AppConfiguration["ConnectionStrings:TestNpgSqlConnection"];

            // Настройка тестовых контекстов.
            var optionsMsSqlBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsMsSqlBuilder.UseSqlServer(MsSqlConfigString);
            ApplicationDbContext = new ApplicationDbContext(optionsMsSqlBuilder.Options);

            var optionsBuilder = new DbContextOptionsBuilder <PostgreDbContext>();

            optionsBuilder.UseNpgsql(PostgreConfigString);
            PostgreContext = new PostgreDbContext(optionsBuilder.Options);

            // Настройка экземпляров сервисов для тестов.
            UserService       = new UserService(null, PostgreContext, null, null);
            ExecutorService   = new ExecutorService(null, PostgreContext, UserService);
            PaginationService = new PaginationService(PostgreContext, UserService);
        }
Beispiel #2
0
 public UserService(ApplicationDbContext db, PostgreDbContext postgre, IdentityDbContext iden, SignInManager <UserEntity> signInManager)
 {
     _db            = db;
     _postgre       = postgre;
     _signInManager = signInManager;
     _iden          = iden;
 }
        /// <summary>
        /// Метод добавляет тестовые специализации.
        /// </summary>
        /// <param name="pdbc">Контекст.</param>
        /// <param name="name">Логин исполнителя.</param>
        private int AddSpec(PostgreDbContext pdbc, string name)
        {
            ExecutorSpecialization[] aSpecies = new ExecutorSpecialization[] {
                new ExecutorSpecialization()
                {
                    SpecName = "Специализация1"
                },
                new ExecutorSpecialization()
                {
                    SpecName = "Специализация2"
                }
            };
            UserEntity oExecutor = pdbc.Users
                                   .Where(e => e.UserName
                                          .Equals(name))
                                   .FirstOrDefault();

            if (oExecutor.Specializations == null)
            {
                oExecutor.Specializations = aSpecies;
            }

            pdbc.SaveChanges();

            UserEntity getExecutor = pdbc.Users
                                     .Where(e => e.UserName
                                            .Equals(name))
                                     .FirstOrDefault();

            return(getExecutor.Specializations.Count());
        }
        /// <summary>
        /// Метод добавляет тестовые специализации исполнителя.
        /// </summary>
        /// <param name="pdbc">Контекст.</param>
        private void AddSpecializations(PostgreDbContext pdbc)
        {
            string executorName = AddExecutor(pdbc);
            int    count        = AddSpec(pdbc, executorName);

            Assert.AreEqual(2, count);
        }
        public void GetQuestionsTest()
        {
            DbContextOptions <PostgreDbContext> postgreOptions = new DbContextOptionsBuilder <PostgreDbContext>().UseInMemoryDatabase(databaseName: "GetQuestionsTest").Options;
            PostgreDbContext postgreContext = new PostgreDbContext(postgreOptions);

            QuestionEntity[] aQuestions = new[]
            {
                new QuestionEntity()
                {
                    QuestionId     = 1,
                    QuestionText   = "Что такое «Ставка» в терминах сервиса?",
                    NumberQuestion = 1
                },

                new QuestionEntity()
                {
                    QuestionId     = 2,
                    QuestionText   = "Что такое «Гарантийный период» в терминах сервиса?",
                    NumberQuestion = 2
                }
            };

            postgreContext.Questions.AddRange(aQuestions);
            postgreContext.SaveChanges();

            int questionsCount = postgreContext.Questions.Count();

            Assert.AreEqual(2, questionsCount);
        }
 public UserController(ApplicationDbContext db, PostgreDbContext postgre, UserManager <UserEntity> userManager, IUserService userService)
 {
     _userManager = userManager;
     _userService = userService;
     _postgre     = postgre;
     _db          = db;
 }
 public ExecutorService(ApplicationDbContext db, PostgreDbContext postgre, IdentityDbContext iden, IUser user)
 {
     _db      = db;
     _postgre = postgre;
     _iden    = iden;
     _user    = user;
 }
 public UserService(ApplicationDbContext db, PostgreDbContext postgre, SignInManager <UserEntity> signInManager, UserManager <UserEntity> userManager)
 {
     _db            = db;
     _postgre       = postgre;
     _signInManager = signInManager;
     _userManager   = userManager;
 }
 public MoldWashingController(PostgreDbContext context, IMemoryCache cache, IHubContext <MoldsHub> hubContext)
 {
     _hubContext       = hubContext;
     _cache            = cache;
     moldWashingStatus = new MoldWashingStatus();
     _connection       = context.Database.GetDbConnection();
 }
 public PaginationController(ApplicationDbContext db, PostgreDbContext postgre, IdentityDbContext iden, UserManager <UserEntity> userManager, SignInManager <UserEntity> signInManager) : base(Module)
 {
     _db            = db;
     _postgre       = postgre;
     _userManager   = userManager;
     _signInManager = signInManager;
     _iden          = iden;
 }
        public void AddSpecializationsTest()
        {
            var dbOptions      = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "GetTasksTest").Options;
            var postgreOptions = new DbContextOptionsBuilder <PostgreDbContext>().UseInMemoryDatabase(databaseName: "GetTasksTest").Options;
            var postgreContext = new PostgreDbContext(postgreOptions);

            AddSpecializations(postgreContext);
        }
 public UnitOfWork(SqlDbContext sqlDbContext, PostgreDbContext postGreDbContext)
 {
     _sqlDbContext         = sqlDbContext;
     _postGreDbContext     = postGreDbContext;
     Customers             = new CustomerRepository(_sqlDbContext);
     MenuMasters           = new MenuMasterRepository(_sqlDbContext, _postGreDbContext);
     Accounts              = new AccountRepository(_sqlDbContext);
     InputDefectRepository = new InputDefectRepository(_sqlDbContext, _postGreDbContext);
 }
Beispiel #13
0
        public DataFactory(SQLServerDbContext sqlDbContext, PostgreDbContext postgreDbContext, SqliteDbContext sqliteDbContext)
        {
            Guard.WhenArgument(sqlDbContext, "sqlDbContext").IsNull().Throw();
            this.sqlDbContext = sqlDbContext;

            Guard.WhenArgument(postgreDbContext, "postgreDbContext").IsNull().Throw();
            this.postgreDbContext = postgreDbContext;

            Guard.WhenArgument(sqliteDbContext, "sqliteDbContext").IsNull().Throw();
            this.sqliteDbContext = sqliteDbContext;
        }
Beispiel #14
0
        public void GetProfileInfoTest()
        {
            var dbOptions      = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "GetProfileInfoTest").Options;
            var postgreOptions = new DbContextOptionsBuilder <PostgreDbContext>().UseInMemoryDatabase(databaseName: "GetProfileInfoTest").Options;
            var dbContext      = new ApplicationDbContext(dbOptions);
            var postgreContext = new PostgreDbContext(postgreOptions);

            AddProfileInfo(postgreContext);

            var query  = new GetDataQuery(dbContext, postgreContext);
            var result = query.GetProfileInfo();

            Assert.IsTrue(result != null);
        }
Beispiel #15
0
 protected override void Seed(PostgreDbContext context)
 {
     context.VisitTypes.AddOrUpdate(
         v => v.Name,
         new VisitType {
         Name = "HomeVisit"
     },
         new VisitType {
         Name = "OfficeVisit"
     },
         new VisitType {
         Name = "HospitalVisit"
     });
 }
Beispiel #16
0
        public void GetLastTasksTest()
        {
            var dbOptions      = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "GetLastTasksTest").Options;
            var postgreOptions = new DbContextOptionsBuilder <PostgreDbContext>().UseInMemoryDatabase(databaseName: "GetLastTasksTest").Options;
            var dbContext      = new ApplicationDbContext(dbOptions);
            var postgreContext = new PostgreDbContext(postgreOptions);

            AddTask(postgreContext);

            var query  = new GetDataQuery(dbContext, postgreContext);
            var result = query.GetLastTasks();

            Assert.AreEqual(5, result.Count);
        }
Beispiel #17
0
        /// <summary>
        /// Добавляет тестовую информацию профиля юзера.
        /// </summary>
        /// <param name="context"></param>
        void AddProfileInfo(PostgreDbContext context)
        {
            UserEntity oUser = new UserEntity
            {
                //UserLogin = "******",
                //UserPassword = "******",
                //UserEmail = "*****@*****.**",
                //UserType = "Заказчик",
                //UserPhone = "8(985)-435-65-78",
                //Age = 23
            };

            context.Users.Add(oUser);
            context.SaveChanges();
        }
        /// <summary>
        /// Метод добавляет тестового исполнителя.
        /// </summary>
        /// <param name="pdbc">Контекст.</param>
        private string AddExecutor(PostgreDbContext pdbc)
        {
            UserEntity oExecutor = new UserEntity
            {
                UserName     = "******",
                UserPassword = "******",
                Email        = "*****@*****.**",
                UserRole     = "E",
                PhoneNumber  = "8(985)-435-65-78",
                Age          = 23
            };

            pdbc.Users.Add(oExecutor);
            pdbc.SaveChanges();

            return(oExecutor.UserName);
        }
Beispiel #19
0
        /// <summary>
        /// Метод добавляет тестовые задания.
        /// </summary>
        void AddTask(PostgreDbContext context)
        {
            //TaskDto oTask1 = new TaskDto() {
            //    OwnerId = 1,
            //    TaskTitle = "test11",
            //    TaskDetail = "test111",
            //    TypeCode = "EJ6B3ABgoUuP6wT/rgOgqw==",
            //    CategoryCode = "U4MuMGKPiE251VPwtbtMgg==",
            //    SpecCode = "OVUW7v4Tu0WABpcJ3aN0rg=="
            //};

            //TaskDto oTask2 = new TaskDto() {
            //    OwnerId = 2,
            //    TaskTitle = "test11111",
            //    TaskDetail = "test11111",
            //    TypeCode = "EJ6B3ABxoUuP6wT/rgOgqw==",
            //    CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
            //    SpecCode = "OVUW1m4Tu0WABpcJ3aN0rg=="
            //};

            //context.Tasks.AddRange(oTask1, oTask2);
            context.SaveChanges();
        }
Beispiel #20
0
 public GenericRepository(PostgreDbContext context)
 {
     _context = context;
     _dbSet   = context.Set <T>();
 }
 public TaskService(ApplicationDbContext db, PostgreDbContext postgre, IdentityDbContext iden)
 {
     _db      = db;
     _postgre = postgre;
     _iden    = iden;
 }
Beispiel #22
0
 public MenuMasterRepository(SqlDbContext sqlDbContext, PostgreDbContext postGreDbContext) : base(sqlDbContext)
 {
     _sqlDbContext     = sqlDbContext;
     _postGreDbContext = postGreDbContext;
 }
Beispiel #23
0
        /// <summary>
        /// Метод добавляет 7 тестовых заданий, но должен вернуть последние 5.
        /// </summary>
        /// <param name="context"></param>
        void AddTask(PostgreDbContext context)
        {
            TaskEntity oTask1 = new TaskEntity()
            {
                OwnerId      = "1",
                TaskTitle    = "test11",
                TaskDetail   = "test111",
                TypeCode     = "EJ6B3ABgoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiE251VPwtbtMgg==",
                SpecCode     = "OVUW7v4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask2 = new TaskEntity()
            {
                OwnerId      = "2",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask3 = new TaskEntity()
            {
                OwnerId      = "3",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask4 = new TaskEntity()
            {
                OwnerId      = "4",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask5 = new TaskEntity()
            {
                OwnerId      = "5",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask6 = new TaskEntity()
            {
                OwnerId      = "6",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            TaskEntity oTask7 = new TaskEntity()
            {
                OwnerId      = "7",
                TaskTitle    = "test11111",
                TaskDetail   = "test11111",
                TypeCode     = "EJ6B3ABxoUuP6wT/rgOgqw==",
                CategoryCode = "U4MuMGKPiEh51VPwtbtMgg==",
                SpecCode     = "OVUW1m4Tu0WABpcJ3aN0rg=="
            };

            context.Tasks.AddRange(oTask1, oTask2, oTask3, oTask4, oTask5, oTask6, oTask7);
            context.SaveChanges();
        }
 public ChatService(ApplicationDbContext db, PostgreDbContext postgre, IUserService userService)
 {
     _db          = db;
     _postgre     = postgre;
     _userService = userService;
 }
Beispiel #25
0
 public KnowlegeService(PostgreDbContext postgre)
 {
     _postgre = postgre;
 }
Beispiel #26
0
 public InputDefectRepository(SqlDbContext sqlDbContext, PostgreDbContext postGreDbContext)
 {
     _sqlDbContext     = sqlDbContext;
     _postGreDbContext = postGreDbContext;
 }
Beispiel #27
0
 public UnitOfWork()
 {
     db = new PostgreDbContext();
 }
Beispiel #28
0
 public BookRepository(PostgreDbContext context) : base(context)
 {
 }
Beispiel #29
0
 public Repository(PostgreDbContext context)
 {
     this.context = context;
     entities     = context.Set <T>();
 }
 public CustomValidatorExtension(PostgreDbContext postgre)
 {
     _postgre = postgre;
 }