Ejemplo n.º 1
0
        public void FindAllEidsQuery_GetsSqlAndExecutesAsQuery()
        {
            const string sql  = "sql";
            const string path = @"C:\Temp\MYDATABASE.db";

            A.CallTo(() => _databaseBuilder.Build(path)).Returns(_sqLiteDatabase);
            _database.Connect(path);
            var nameValueData = new List <NameValueCollection>
            {
                new NameValueCollection()
                {
                    { "Eid", "1" }
                },
                new NameValueCollection()
                {
                    { "Eid", "2" }
                }
            };
            var data = new List <int>
            {
                1, 2
            };

            A.CallTo(() => _sqlQueryConstructor.FindAllEidsQuery()).Returns(sql);
            A.CallTo(() => _sqLiteDatabase.ExecuteReader(sql)).Returns(nameValueData);

            var response = _database.FindAllEids();

            response.ShouldAllBeEquivalentTo(data);
        }
Ejemplo n.º 2
0
        public List <int> FindAllEids()
        {
            var sql = _sqlQueryConstructor.FindAllEidsQuery();
            var nameValueCollections = _sqLiteDatabase.ExecuteReader(sql);
            var response             = new List <int>();

            foreach (var nvc in nameValueCollections)
            {
                int subjectEid;
                int.TryParse(nvc.Get("Eid"), out subjectEid);
                response.Add(subjectEid);
            }
            return(response);
        }