Пример #1
0
        public void SeedCharacterSupportClasses()
        {
            Library.Users user = new Library.Users
            {
                Username   = "******",
                Password   = "******",
                Permission = 0,
                Email      = "*****@*****.**"
            };
            _userRepo.CreateUser(user);
            _userRepo.Save();

            Library.CampaignCreate camp = new Library.CampaignCreate
            {
                Name = "TestCamp",
            };
            _campRepo.CreateCampaign(camp);
            _campRepo.Save();

            Library.Class testClass = new Library.Class
            {
                Name = "TestClass"
            };
            _repo.AddClass(testClass);
            _repo.Save();

            Library.Race race = new Library.Race
            {
                Name = "TestRace"
            };
            _repo.AddRace(race);
            _repo.Save();
        }
Пример #2
0
 public static Users Map(Library.Users r) => new Users
 {
     UsersId    = r.UserID,
     Username   = r.Username,
     Password   = r.Password,
     Permission = r.Permission,
     Email      = r.Email
 };
Пример #3
0
        public void DeleteUserFromDbIsSuccessful()
        {
            // arrange
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try
            {
                var options = new DbContextOptionsBuilder <ANightsTaleContext>()
                              .UseSqlite(connection)
                              .Options;

                // Create the schema in the database
                using (var context = new ANightsTaleContext(options))
                {
                    context.Database.EnsureCreated();
                }

                // Act

                // Run the test against one instance of the context
                using (var context = new ANightsTaleContext(options))
                {
                    var repo = new UserRepository(context);

                    Library.Users user = new Library.Users
                    {
                        Username   = "******",
                        Password   = "******",
                        Permission = 0,
                        Email      = "*****@*****.**"
                    };

                    repo.CreateUser(user);
                    repo.Save();

                    repo.DeleteUser(1);
                    repo.Save();

                    // Assert
                    Assert.Empty(context.Users);
                }
            }
            finally
            {
                connection.Close();
            }
        }
Пример #4
0
 public void CreateUser(Library.Users user)
 {
     _db.Add(Mapper.Map(user));
 }