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(); }
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); } }
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()); } }
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); }
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); }
public void Save(TadmapImage image) { }
public void Has_ImageSet_Accessor() { TadmapImage image = new TadmapImage(); Assert.IsNull(image.ImageSet); }
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)); }
public void Contains_OwnerName() { TadmapImage image = new TadmapImage { OwnerName = "Owner" }; Assert.AreEqual("Owner", image.OwnerName); }
public void Contains_Save_Method() { IImageRepository repository = new TestImageRepository(); TadmapImage image = new TadmapImage(); repository.Save(image); }