예제 #1
0
      public void Can_Save_Existing_Image()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().First();

            repository.Save(image);
         }
      }
예제 #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);
         }
      }
예제 #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());
         }
      }
예제 #4
0
      public void Making_First_Offensive_Image_Not_Offensive_Gives_Non_Offensive_Images_A_Count_Of_2()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().FirstOrDefault(i => i.IsOffensive);

            image.IsOffensive = false;

            repository.Save(image);

            Assert.AreEqual(2, repository.GetAllImages().IsNotOffensive().Count());
         }
      }
예제 #5
0
      public void All_Public_Images_Returns_2()
      {
         IImageRepository repository = new SqlImageRepository();

         Assert.AreEqual(2, repository.GetAllImages().IsPublic().Count());
      }
예제 #6
0
      public void All_Non_Offensive_Returns_1()
      {
         IImageRepository repository = new SqlImageRepository();

         Assert.AreEqual(1, repository.GetAllImages().IsNotOffensive().Count());
      }
예제 #7
0
      public void Returns_Image_With_Correct_Original_Preview_Key()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().WithId(new Guid("ede4567f-32be-4aba-97ea-a0c6be3fcbfd")).SingleOrDefault();

            Assert.AreEqual("Preview_f0b999ba-36b1-4cc2-beb1-455367b5897a.gif", image.ImageSet.Preview);
         }
      }
예제 #8
0
      public void Change_Public_Image_To_Private_Saves_And_Returns_Correctly()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().WithId(new Guid("57c95cb2-dea3-486b-a951-d650e346ab59")).SingleOrDefault();

            Assert.IsNotNull(image);
            Assert.IsTrue(image.IsPublic);

            image.IsPublic = false;

            repository.Save(image);

            TadmapImage latestImage = repository.GetAllImages().WithId(new Guid("57c95cb2-dea3-486b-a951-d650e346ab59")).SingleOrDefault();

            Assert.IsFalse(latestImage.IsPublic);
         }
      }
예제 #9
0
      public void Returns_Image_With_ImageSet()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().WithId(new Guid("ede4567f-32be-4aba-97ea-a0c6be3fcbfd")).SingleOrDefault();

            Assert.IsNotNull(image.ImageSet);
         }
      }
예제 #10
0
      public void Can_Get_All_Images_Returns_3()
      {
         IImageRepository repository = new SqlImageRepository();

         Assert.AreEqual(3, repository.GetAllImages().Count());
      }
예제 #11
0
      public void Returns_Image_With_Correct_Owner_Name()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().WithId(new Guid("ede4567f-32be-4aba-97ea-a0c6be3fcbfd")).SingleOrDefault();

            Assert.AreEqual("http://taduser.myopenid.com/", image.OwnerName);
         }
      }
예제 #12
0
      public void Change_Private_Image_To_Public_Saves_And_Returns_Correctly()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().WithId(new Guid("ede4567f-32be-4aba-97ea-a0c6be3fcbfd")).SingleOrDefault();

            Assert.IsNotNull(image);
            Assert.IsFalse(image.IsPublic);

            image.IsPublic = true;

            repository.Save(image);

            TadmapImage latestImage = repository.GetAllImages().WithId(new Guid("ede4567f-32be-4aba-97ea-a0c6be3fcbfd")).SingleOrDefault();

            Assert.IsTrue(latestImage.IsPublic);
         }
      }
예제 #13
0
 public void Can_Create()
 {
    IImageRepository repository = new SqlImageRepository();
 }
예제 #14
0
      public void Change_To_Description_Is_Saved_And_Returned_Correctly()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().FirstOrDefault();

            image.Description = "First Image Title - Changed";

            string oldTitle = image.Title;

            repository.Save(image);

            Assert.AreEqual(oldTitle, repository.GetAllImages().FirstOrDefault().Title);
            Assert.AreEqual("First Image Title - Changed", repository.GetAllImages().FirstOrDefault().Description);
         }
      }
예제 #15
0
      public void Making_First_Private_Image_Public_Gives_Public_Images_A_Count_Of_3()
      {
         using (TransactionScope transaction = new TransactionScope())
         {
            IImageRepository repository = new SqlImageRepository();

            TadmapImage image = repository.GetAllImages().FirstOrDefault(i => !i.IsPublic);

            image.IsPublic = true;

            repository.Save(image);

            Assert.AreEqual(3, repository.GetAllImages().IsPublic().Count());
         }
      }