Exemple #1
0
        public async Task TeacherGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (TeacherGroup teacherGroupToDelete in listTeacherGroup)
                {
                    await TestEntityDelete(teacherGroupToDelete);
                }

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Exemple #2
0
        public void TestSavingAndLoading()
        {
            DictionaryStorage storage = new DictionaryStorage();

            storage.AddModel <User>();
            storage.AddModel <Project>();
            storage.AddModel <Task>();

            User user = new User(storage)
            {
                name = "Test User"
            };

            Project project = new Project(storage)
            {
                name = "Test Project"
            };

            Task task = new Task(project, user, storage);

            task.Save();

            Task loaded = Task.GetById(storage, task.Id);

            Assert.IsTrue(task.IsSaved());
            Assert.IsTrue(loaded.IsSaved());
            Assert.IsTrue(user.IsSaved());
            Assert.IsTrue(project.IsSaved());
            Assert.AreEqual(loaded.Project.name, "Test Project");
            Assert.AreEqual(loaded.Performer.name, "Test User");
        }
Exemple #3
0
        public async Task UserTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            userStorage       = new UserStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);


            try
            {
                await Setup();
                await TestSelects();
                await TestBioUpdate();
                await TestUpdate();

                foreach (User userToDelete in listUser)
                {
                    TestEntityDelete(userToDelete);
                }

                await TearDown();

                transaction.Commit();
            }


            catch
            {
                transaction.Rollback();
                throw new System.Exception();
            }
        }
Exemple #4
0
        public void StudentGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                foreach (StudentGroup studentGroupToDelete in listStudentGroup)
                {
                    TestEntityDelete(studentGroupToDelete);
                }
                ClearTest();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Exemple #5
0
        public async Task JournalTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            lessonStorage     = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();
                await TestUpdate();

                foreach (Journal journalToDelete in listJournal)
                {
                    await TestEntityDelete(journalToDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
Exemple #6
0
 public override void Clear(ref DictionaryStorage storage)
 {
     lock (this) {
         _dict.Clear();
         _objDict?.Clear();
     }
 }
 public override void Clear(ref DictionaryStorage storage)
 {
     _storage.Clear(ref storage);
     foreach (var item in GetExtraItems())
     {
         TryRemoveExtraValue(item.Key);
     }
 }
 public override void AddNoLock(ref DictionaryStorage storage, object key, object value)
 {
     if (key is string && TrySetExtraValue((string)key, value))
     {
         return;
     }
     _storage.AddNoLock(ref storage, key, value);
 }
        public override void AddNoLock(ref DictionaryStorage storage, object key, object value) {
            int ikey = FindKey(key);
            if (ikey != -1) {
                _values[ikey] = value;
                return;
            }

            base.AddNoLock(ref storage, key, value);
        }
        public override void Clear(ref DictionaryStorage storage)
        {
            for (int i = 0; i < _values.Length; i++)
            {
                _values[i] = Uninitialized.Instance;
            }

            base.Clear(ref storage);
        }
Exemple #11
0
 public override void Clear(ref DictionaryStorage storage)
 {
     lock (this) {
         _dict.Clear();
         if (_objDict != null)
         {
             _objDict.Clear();
         }
     }
 }
        public override void AddNoLock(ref DictionaryStorage storage, object key, object value)
        {
            int ikey = FindKey(key);

            if (ikey != -1)
            {
                _values[ikey] = value;
                return;
            }

            base.AddNoLock(ref storage, key, value);
        }
Exemple #13
0
 public override void Add(ref DictionaryStorage storage, object key, object value)
 {
     lock (this) {
         string strKey = key as string;
         if (strKey != null)
         {
             _dict[strKey] = value;
         }
         else
         {
             EnsureObjectDictionary();
             _objDict[CustomStringDictionary.NullToObj(key)] = value;
         }
     }
 }
        public override bool Remove(ref DictionaryStorage storage, object key)
        {
            int ikey = FindKey(key);

            if (ikey != -1)
            {
                if (Interlocked.Exchange <object>(ref _values[ikey], Uninitialized.Instance) != Uninitialized.Instance)
                {
                    return(true);
                }

                return(false);
            }

            return(base.Remove(ref storage, key));
        }
Exemple #15
0
        public override bool Remove(ref DictionaryStorage storage, object key)
        {
            lock (this) {
                string strKey = key as string;
                if (strKey != null)
                {
                    return(_dict.Remove(strKey));
                }

                if (_objDict != null)
                {
                    return(_objDict.Remove(CustomStringDictionary.NullToObj(key)));
                }

                return(false);
            }
        }
Exemple #16
0
        public void User_SkillTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            dictionaryStorage = new DictionaryStorage(connection, transaction);

            userStorage = new UserStorage(connection, transaction);

            courseStorage = new CourseStorage(connection, transaction);



            try
            {
                Setup();

                TestSelects();

                TestDelete();

                //TestUpdate();



                //foreach (Journal journalToDelete in listJournal)

                //{

                //    TestEntityDelete(journalToDelete);

                //}



                ClearShit();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Exemple #17
0
        public async Task CityTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            dictionaryStorage = new DictionaryStorage(connection, transaction);

            try
            {
                CitySetup();
                CityTestSelects();
                await CityTestUpdate();
                await CityTestDelete(listCity);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Exemple #18
0
        public async Task AttestationThemeTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            dictionaryStorage = new DictionaryStorage(connection, transaction);

            try
            {
                AttestationThemeSetup();
                AttestationThemeTestSelects();
                await AttestationThemeTestUpdate();
                await AttestationThemeTestDelete(listAttestationTheme);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new System.Exception();
            }
        }
Exemple #19
0
        public async Task User_RoleTestAsync()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            userStorage       = new UserStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);

            try
            {
                Setup();
                User_RoleTestSelects();
                await User_RoleTestDelete();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Exemple #20
0
 public override void Add(ref DictionaryStorage storage, object key, object value)
 {
     GetStorage().Add(key, value);
 }
Exemple #21
0
        public DictionaryController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            dictionaryStorage = new DictionaryStorage(dbCon);
        }
        public override void Clear(ref DictionaryStorage storage) {
            for (int i = 0; i < _values.Length; i++) {
                _values[i] = Uninitialized.Instance;
            }

            base.Clear(ref storage);
        }
Exemple #23
0
        /// <summary>
        /// Generates a number of ships that is within a range
        /// </summary>
        public void GenerateShips()
        {
            RandomizerHelper         randomDictionary = new RandomizerHelper();
            DictionaryStorage        listOfShips      = new DictionaryStorage();
            UniqueList               uniqueList       = new UniqueList();
            Dictionary <string, int> dict             = new Dictionary <string, int>();

            Ships = new Dictionary <string, string>();

            numbers = arrayOfNumbers.ToList();

            if (CurrentFaction == "Scum")
            {
                dict = listOfShips.ScumShips;
            }

            if (CurrentFaction == "Imperial")
            {
                dict = listOfShips.ImperialShips;
            }

            int    shipAudit   = 0;
            int    pointsSpent = 0;
            Random r           = new Random();

            if (pointsSpent < ShipBudget)
            {
                ShipCost    = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                pointsSpent = pointsSpent + ShipCost;
            }

            foreach (var fetchedShipName in randomDictionary.RandomValues(dict, ShipCost).Take(1))
            {
                Ship1Name = fetchedShipName;
                Ships.Add("Ship 1: " + fetchedShipName, Ship1Name);
                if (uniqueList.UniqueVar.Contains(fetchedShipName))
                {
                    dict.Remove(fetchedShipName);

                    if (!dict.Values.Contains(ShipCost))
                    {
                        numbers.Remove(ShipCost);
                    }
                }
            }

            if (pointsSpent < ShipBudget)
            {
                Ship2Cost   = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                pointsSpent = pointsSpent + Ship2Cost;
            }


            foreach (var fetchedShipName in randomDictionary.RandomValues(dict, Ship2Cost).Take(1))
            {
                Ship2Name = fetchedShipName.ToString();
                Ships.Add("Ship 2: " + fetchedShipName, Ship2Name);
                if (uniqueList.UniqueVar.Contains(fetchedShipName))
                {
                    dict.Remove(fetchedShipName);
                    if (uniqueList.UniqueVar.Contains(fetchedShipName))
                    {
                        dict.Remove(fetchedShipName);

                        if (!dict.Values.Contains(ShipCost))
                        {
                            numbers.Remove(ShipCost);
                        }
                    }
                }
            }

            if (pointsSpent < ShipBudget)
            {
                if (pointsSpent < ShipBudget - 5)
                {
                    shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    while (shipAudit + pointsSpent > ShipBudget + 5)
                    {
                        shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    }

                    Ship3Cost   = shipAudit;
                    pointsSpent = pointsSpent + Ship3Cost;
                }
            }

            if (Ship3Cost > 0)
            {
                foreach (var fetchedShipName in randomDictionary.RandomValues(dict, Ship3Cost).Take(1))
                {
                    Ship3Name = fetchedShipName.ToString();
                    Ships.Add("Ship 3: " + fetchedShipName, Ship3Name);
                    if (uniqueList.UniqueVar.Contains(fetchedShipName))
                    {
                        dict.Remove(fetchedShipName);

                        if (!dict.Values.Contains(ShipCost))
                        {
                            numbers.Remove(ShipCost);
                        }
                    }
                }
            }

            if (pointsSpent < ShipBudget)
            {
                if (pointsSpent < ShipBudget - 12)
                {
                    shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    while (shipAudit + pointsSpent > ShipBudget + 5)
                    {
                        shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    }

                    Ship4Cost   = shipAudit;
                    pointsSpent = pointsSpent + Ship4Cost;
                }
            }

            if (Ship4Cost > 0)
            {
                foreach (var fetchedShipName in randomDictionary.RandomValues(dict, Ship4Cost).Take(1))
                {
                    Ship4Name = fetchedShipName.ToString();
                    Ships.Add("Ship 4: " + fetchedShipName, Ship4Name);
                    if (uniqueList.UniqueVar.Contains(fetchedShipName))
                    {
                        dict.Remove(fetchedShipName);

                        if (!dict.Values.Contains(ShipCost))
                        {
                            numbers.Remove(ShipCost);
                        }
                    }
                }
            }

            if (pointsSpent < ShipBudget)
            {
                if (pointsSpent < ShipBudget - 12)
                {
                    shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    while (shipAudit + pointsSpent > ShipBudget + 5)
                    {
                        shipAudit = numbers.OrderBy(n => Guid.NewGuid()).ToArray().First();
                    }

                    Ship5Cost   = shipAudit;
                    pointsSpent = pointsSpent + Ship5Cost;
                }
            }

            if (Ship5Cost > 0)
            {
                foreach (var fetchedShipName in randomDictionary.RandomValues(dict, Ship5Cost).Take(1))
                {
                    Ship5Name = fetchedShipName.ToString();
                    Ships.Add("Ship 5: " + fetchedShipName, Ship4Name);
                    if (uniqueList.UniqueVar.Contains(fetchedShipName))
                    {
                        dict.Remove(fetchedShipName);

                        if (!dict.Values.Contains(ShipCost))
                        {
                            numbers.Remove(ShipCost);
                        }
                    }
                }
            }

            Console.WriteLine("");
            Console.Write(string.Format("We finished building your ships.  We will be spending {0} on Ship 1, {1} on ship 2", ShipCost.ToString(), Ship2Cost.ToString()));

            if (Ship3Cost > 0)
            {
                Console.Write(string.Format(", {0} on ship 3", Ship3Cost.ToString()));
            }

            if (Ship4Cost > 0)
            {
                Console.Write(string.Format(", {0} on ship 4", Ship4Cost.ToString()));
            }

            if (Ship5Cost > 0)
            {
                Console.Write(string.Format(", {0} on ship 5", Ship5Cost.ToString()));
            }

            Console.Write(".");
            Console.WriteLine("");

            SpentSoFar   = SpentSoFar + pointsSpent;
            SpentOnShips = pointsSpent;
        }
 public override bool Remove(ref DictionaryStorage storage, object key)
 {
     return Remove(key);
 }
Exemple #25
0
 public override bool Remove(ref DictionaryStorage storage, object key)
 {
     return(GetStorage().Remove(ref storage, key));
 }
Exemple #26
0
 public Filmography()
 {
     _filmographyStorage = new DictionaryStorage <IEnumerable <string> >();
 }
        public override bool Remove(ref DictionaryStorage storage, object key) {
            int ikey = FindKey(key);
            if (ikey != -1) {
                if (Interlocked.Exchange<object>(ref _values[ikey], Uninitialized.Instance) != Uninitialized.Instance) {
                    return true;
                }

                return false;
            }

            return base.Remove(ref storage, key);
        }
Exemple #28
0
 public override void Clear(ref DictionaryStorage storage)
 {
     GetStorage().Clear(ref storage);
 }
 public override void Add(ref DictionaryStorage storage, object key, object value)
 {
     Add(key, value);
 }