4
using System.Collections;
12
public class PhotoStoreTests
15
const string path = "./PhotoStoreTest.db";
24
Gtk.Application.Init ();
32
foreach (string image in images) {
33
File.Copy ("../images/" + image, "./" + image, true);
39
public void TearDown ()
42
foreach (string image in images)
44
File.Delete ("./" + image);
48
// static void Dump (Photo photo)
50
// // Console.WriteLine ("\t[{0}] {1}", photo.Id, photo.Path);
51
// Console.WriteLine ("\t{0}", photo.Time.ToLocalTime ());
53
// if (photo.Description != String.Empty)
54
// Console.WriteLine ("\t{0}", photo.Description);
56
// Console.WriteLine ("\t(no description)");
58
// Console.WriteLine ("\tTags:");
60
// if (photo.Tags.Count == 0) {
61
// Console.WriteLine ("\t\t(no tags)");
63
// foreach (Tag t in photo.Tags)
64
// Console.WriteLine ("\t\t{0}", t.Name);
67
// Console.WriteLine ("\tVersions:");
69
// foreach (uint id in photo.VersionIds)
70
// Console.WriteLine ("\t\t[{0}] {1}", id, photo.GetVersionName (id));
73
// static void Dump (ArrayList photos)
75
// foreach (Photo p in photos)
79
// static void DumpAll (Db db)
81
// Console.WriteLine ("\n*** All pictures");
82
// Dump (db.Photos.Query (null));
85
// static void DumpForTags (Db db, ArrayList tags)
87
// Console.Write ("\n*** Pictures for tags: ");
88
// foreach (Tag t in tags)
89
// Console.Write ("{0} ", t.Name);
90
// Console.WriteLine ();
92
// Dump (db.Photos.Query (tags));
96
public void PopulatendRetrieve ()
98
/*Tag portraits_tag = */db.Tags.CreateTag (null, "Portraits", false);
99
Tag landscapes_tag = db.Tags.CreateTag (null, "Landscapes", false);
100
Tag favorites_tag = db.Tags.CreateTag (null, "Street", false);
102
//uint portraits_tag_id = portraits_tag.Id;
103
//uint landscapes_tag_id = landscapes_tag.Id;
104
//uint favorites_tag_id = favorites_tag.Id;
106
Pixbuf unused_thumbnail;
108
Photo ny_landscape = db.Photos.Create (UriUtils.PathToFileUri ("../images/pano.jpg"), 0, out unused_thumbnail);
109
ny_landscape.Description = "Snowy landscape";
110
ny_landscape.AddTag (landscapes_tag);
111
ny_landscape.AddTag (favorites_tag);
112
db.Photos.Commit (ny_landscape);
114
// Photo me_in_sf = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/me_in_sf.jpg",
115
// out unused_thumbnail);
116
// me_in_sf.AddTag (landscapes_tag);
117
// me_in_sf.AddTag (portraits_tag);
118
// me_in_sf.AddTag (favorites_tag);
119
// db.Photos.Commit (me_in_sf);
121
// me_in_sf.RemoveTag (favorites_tag);
122
// me_in_sf.Description = "Myself and the SF skyline";
123
// me_in_sf.CreateVersion ("cropped", Photo.OriginalVersionId);
124
// me_in_sf.CreateVersion ("UM-ed", Photo.OriginalVersionId);
125
// db.Photos.Commit (me_in_sf);
127
// Photo macro_shot = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/macro_shot.jpg",
128
// out unused_thumbnail);
131
db.Init (path, false);
135
// portraits_tag = db.Tags.Get (portraits_tag_id) as Tag;
136
// landscapes_tag = db.Tags.Get (landscapes_tag_id) as Tag;
137
// favorites_tag = db.Tags.Get (favorites_tag_id) as Tag;
139
// ArrayList query_tags = new ArrayList ();
140
// query_tags.Add (portraits_tag);
141
// query_tags.Add (landscapes_tag);
142
// DumpForTags (db, query_tags);
144
// query_tags.Clear ();
145
// query_tags.Add (favorites_tag);
146
// DumpForTags (db, query_tags);