示例#1
0
        public void TestRetrieveData()
        {
            var repo = new SqLiteRepository(factory);

            repo.SaveData(new DataEntry {
                Id = 101, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });
            repo.SaveData(new DataEntry {
                Id = 102, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });
            repo.SaveData(new DataEntry {
                Id = 103, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });
            repo.SaveData(new DataEntry {
                Id = 104, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });

            var data = repo.GetList <DataEntry>();

            Assert.AreEqual(4, data.Count);

            var first = data.First();

            Assert.AreEqual(101, first.Id);
            Assert.AreEqual(5, first.Password.Length);
            Assert.AreEqual(DateTime.Today, first.Today);
            Assert.AreEqual("elephant", data.Skip(2).First().Password);
            Assert.AreNotEqual("giraffe", data.Skip(2).First().Password);
        }
示例#2
0
        public void TestMultipleDataSets()
        {
            var repo = new SqLiteRepository(factory);

            repo.SaveData(new DataEntry {
                Id = 101, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });
            repo.SaveData(new DataEntry {
                Id = 102, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });

            var data = repo.GetList <DataEntry>();

            Assert.AreEqual(2, data.Count);
            Assert.AreEqual(101, data.First().Id);
            Assert.AreEqual("paul", data.First().Username);
            Assert.AreEqual(102, data.Skip(1).First().Id);
            Assert.AreEqual("mac", data.Skip(1).First().Username);
        }
示例#3
0
        public void TestDeleteRecord()
        {
            var repo       = new SqLiteRepository(factory);
            var deleteData = new DataEntry {
                Id = 101, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            };

            repo.SaveData(deleteData);
            repo.SaveData(new DataEntry {
                Id = 102, Password = "******", RandomNumber = new Random().Next(255), Today = DateTime.Today, Username = "******"
            });

            // delete the first entry
            repo.Delete(deleteData);

            // tests
            var data = repo.GetList <DataEntry>();

            Assert.AreEqual(1, data.Count);
            Assert.AreEqual("mac", data.First().Username);
            Assert.AreEqual(DateTime.Today, data.First().Today);
        }