Пример #1
0
        public TopoMojo.Models.User AddUser(string name, bool makeActor, bool isAdmin = false)
        {
            if (!_actors.ContainsKey(name))
            {
                TopoMojo.Models.User target = new TopoMojo.Models.User
                {
                    Name     = name,
                    Role     = UserRole.Administrator,
                    GlobalId = Guid.NewGuid().ToString()
                };

                target = _proman.Add(target).Result;

                _actors.Add(name, target);
                _mgrStore.Add(target, new Dictionary <string, object>());
            }

            TopoMojo.Models.User person = _actors[name];
            if (makeActor)
            {
                Actor = person;
            }

            return(person);
        }
Пример #2
0
        protected void Initialize()
        {
            _options = new CoreOptions();
            _mill    = new LoggerFactory();

            Mapper = new AutoMapper.MapperConfiguration(cfg => {
                cfg.AddTopoMojoMaps();
            }).CreateMapper();

            Cache       = new StubDistributedCache();
            MemoryCache = new StubMemoryCache();

            _dbOptions = new DbContextOptionsBuilder <TopoMojoDbContext>()
                         .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                         .Options;

            using (TopoMojoDbContext ctx = new TopoMojoDbContext(_dbOptions))
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
                _user = new TopoMojo.Models.User {
                    Id = 1, Name = "tester"
                };
                _ur = new IdentityResolver(_user);
            }
        }