Пример #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 void AddNullClassThrowsNullException()
        {
            // arrange
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try
            {
                var rand    = new RngProvider();
                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 charRepo = new CharacterRepository(context);

                    // Assert
                    Assert.ThrowsAny <ArgumentNullException>(() => charRepo.AddClass(null));
                }
            }
            finally
            {
                connection.Close();
            }
        }