Ejemplo n.º 1
0
        public void TestInitialize()
        {
            using (var entities = new IdEntities())
            {
                entities.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                entities.Ids.RemoveRange(entities.Ids);
                entities.SaveChanges();

                for (var i = 1; i <= TestSeeds; ++i)
                {
                    entities.Ids.Add(new Id {
                        Value = i
                    });
                }

                entities.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void ClearTable()
        {
            var recordCount = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.RemoveRange(entities.Ids);
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                recordCount = entities.Ids.Count();
            }

            Assert.AreEqual(0, recordCount);
        }
Ejemplo n.º 3
0
        public void RemoveRecords()
        {
            var recordsToRemove = TestSeeds - new Random().Next(1, TestSeeds - 1);
            var recordCount     = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.RemoveRange(entities.Ids.Take(recordsToRemove));
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                recordCount = entities.Ids.Count();
            }

            Assert.AreEqual(TestSeeds - recordsToRemove, recordCount);
        }
Ejemplo n.º 4
0
        public void UpdateRecord()
        {
            var  testUpdateValue = new Random().Next(500_000, 1_000_000);
            long actualValue     = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.First().Value = testUpdateValue;
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                actualValue = entities.Ids.First().Value;
            }

            Assert.AreEqual(testUpdateValue, actualValue);
        }
Ejemplo n.º 5
0
        public void AddRecords()
        {
            var       recordCount     = -1;
            const int recordsToInsert = TestSeeds + 400;

            using (var entities = new IdEntities())
            {
                for (var i = TestSeeds + 1; i <= recordsToInsert; ++i)
                {
                    entities.Ids.Add(new Id {
                        Value = i
                    });
                }

                entities.SaveChanges();

                recordCount = entities.Ids.Count();
            }

            Assert.AreEqual(recordsToInsert, recordCount);
        }