Ejemplo n.º 1
0
      public void Save(TadmapImage image)
      {
         bool isNew = false;

         TadmapDb db = new TadmapDb();
         UserImage dbImage = db.UserImages.SingleOrDefault(i => i.Id == image.Id);

         if (dbImage == null)
         {
            dbImage = new UserImage();

            // can't change date added, id or owner
            dbImage.DateAdded = DateTime.Now;
            dbImage.UserId = image.UserId;
            dbImage.Id = image.Id;

            isNew = true;
         }
         else
         {
            isNew = false;
         }

         dbImage.Title = image.Title;
         dbImage.Description = image.Description;
         dbImage.Key = image.Key;
         dbImage.OffensiveCount = image.IsOffensive ? (byte)1 : (byte)0;
         dbImage.Privacy = image.IsPublic ? (byte)1 : (byte)0;

         if (isNew)
            db.UserImages.InsertOnSubmit(dbImage);

         db.SubmitChanges();
      }
Ejemplo n.º 2
0
      public void Can_Add_New_Image()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage newImage = new TadmapImage(Guid.NewGuid(), "", "", "", true, false, new Guid("d23a1f2a-0db5-4efe-b084-b5529e9a2756"), repository, null);

            repository.Save(newImage);
         }
      }
Ejemplo n.º 3
0
      public void GetAll_Count_Is_4_After_Saving_New_Image()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage newImage = new TadmapImage(Guid.NewGuid(), "", "", "", true, false, new Guid("d23a1f2a-0db5-4efe-b084-b5529e9a2756"), repository, null);
            
            repository.Save(newImage);

            Assert.AreEqual(4, repository.GetAllImages().Count());
         }
      }
Ejemplo n.º 4
0
      public void IsOffensive_Can_Be_False()
      {
         Guid id = Guid.NewGuid();

         TadmapImage image = new TadmapImage(id, "title", "description", "key", false, false, Guid.NewGuid(), new TestImageRepository(), new TestBinaryRepository());

         Assert.AreEqual(id, image.Id);
         Assert.AreEqual("title", image.Title);
         Assert.AreEqual("description", image.Description);
         Assert.AreEqual("key", image.Key);
         Assert.AreEqual(false, image.IsPublic);
         Assert.AreEqual(false, image.IsOffensive);
      }
Ejemplo n.º 5
0
      public void Should_Contain_Id_Title_Description_StorageKey_IsPublic()
      {
         Guid id = Guid.NewGuid();

         TadmapImage image = new TadmapImage(id, "title", "description", "key", true, true, Guid.NewGuid(), new TestImageRepository(), new TestBinaryRepository());

         Assert.AreEqual(id, image.Id);
         Assert.AreEqual("title", image.Title);
         Assert.AreEqual("description", image.Description);
         Assert.AreEqual("key", image.Key);
         Assert.AreEqual(true, image.IsPublic);
         Assert.AreEqual(true, image.IsOffensive);
      }
Ejemplo n.º 6
0
 public void Save(TadmapImage image)
 {
    
 }
Ejemplo n.º 7
0
      public void Has_ImageSet_Accessor()
      {
         TadmapImage image = new TadmapImage();

         Assert.IsNull(image.ImageSet);
      }
Ejemplo n.º 8
0
      public void Collector_Should_Not_Be_Able_To_Mark_Image_As_Offensive()
      {
         TadmapImage image = new TadmapImage(_imageId, "title", "description", "key", false, false, Guid.NewGuid(), new TestImageRepository(), new TestBinaryRepository());

         Assert.IsFalse(image.CanUserMarkAsOffensive(Principals.Collector));
      }
Ejemplo n.º 9
0
      public void Contains_OwnerName()
      {
         TadmapImage image = new TadmapImage { OwnerName = "Owner" };

         Assert.AreEqual("Owner", image.OwnerName);
      }
Ejemplo n.º 10
0
      public void Contains_Save_Method()
      {
         IImageRepository repository = new TestImageRepository();

         TadmapImage image = new TadmapImage();

         repository.Save(image);
      }