Exemplo n.º 1
0
        public void TestIdentity()
        {
            var data = new OctopushCollection <DummyPerson, int>(x => x.PersonId);

            for (int index = 0; index < 2000; index++)
            {
                data.Add(DummyPersonFactory.Instance.Make());
            }

            //Check if are 2000 unique ids
            Assert.AreEqual(data.Count, data.Select(x => x.PersonId).Distinct().Count());
        }
Exemplo n.º 2
0
        public void TestRemove()
        {
            var data = new OctopushCollection <DummyPerson, int>(x => x.PersonId);

            for (int index = 0; index < 2000; index++)
            {
                data.Add(DummyPersonFactory.Instance.Make());
            }

            var count = data.Count();

            for (int index = 0; index < 10; index++)
            {
                var item = data.FirstOrDefault();
                data.Remove(item);
            }

            //Check if are 2000 unique ids
            Assert.AreEqual(count - 10, data.Select(x => x.PersonId).Distinct().Count());
        }
Exemplo n.º 3
0
        public void TestUniqueKey()
        {
            var data = new OctopushCollection <DummyPerson, int>(x => x.PersonId);

            data.AddUniqueField(x => x.BirthDate);
            data.AddUniqueField(x => x.Name);

            for (int index = 0; index < 2000; index++)
            {
                data.Add(DummyPersonFactory.Instance.Make());
            }

            //Try to make a duplicated fields
            var item = data.FirstOrDefault();

            data.Add(DummyPersonFactory.Instance.Clone(item));
            data.Add(DummyPersonFactory.Instance.Clone(item));
            data.Add(DummyPersonFactory.Instance.Clone(item));
            data.Add(DummyPersonFactory.Instance.Clone(item));
            data.Add(DummyPersonFactory.Instance.Clone(item));

            //Check if are 2000 unique ids
            Assert.AreEqual(data.Count, data.Select(x => new { x.Name, x.BirthDate }).Distinct().Count());
        }