예제 #1
0
        public void FindEidsWithGivenObjectType_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()
                {
                    { "Subject", "1" }
                },
                new NameValueCollection()
                {
                    { "Subject", "2" }
                }
            };
            var data = new List <int>
            {
                1, 2
            };

            A.CallTo(() => _sqlQueryConstructor.FindEidsWithGivenObjectTypeQuery(A <string> .Ignored)).Returns(sql);
            A.CallTo(() => _sqLiteDatabase.ExecuteReader(sql)).Returns(nameValueData);

            var response = _database.FindEidsWithGivenObjectType("");

            response.ShouldAllBeEquivalentTo(data);
        }
예제 #2
0
        public List <int> FindEidsWithGivenObjectType(string objectType)
        {
            var sql = _sqlQueryConstructor.FindEidsWithGivenObjectTypeQuery(objectType);
            var nameValueCollections = _sqLiteDatabase.ExecuteReader(sql);
            var response             = new List <int>();

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