Esempio n. 1
0
 protected bool Equals(MacroProperty other)
 {
     return(string.Equals(_alias, other._alias) && _id == other._id);
 }
        public void Can_Add_Remove_Macro_Properties()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current))
            {
                var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml");
                var prop1 = new MacroProperty("blah1", "New1", 4, "test.editor");
                var prop2 = new MacroProperty("blah2", "New2", 3, "test.editor");

                //add/remove a few to test the collection observable
                macro.Properties.Add(prop1);
                macro.Properties.Add(prop2);
                macro.Properties.Remove(prop1);
                macro.Properties.Remove("blah2");
                macro.Properties.Add(prop2);
                
                repository.AddOrUpdate(macro);
                unitOfWork.Commit();

                // Assert
                var result = repository.Get(macro.Id);
                
                Assert.AreEqual(1, result.Properties.Count());
                Assert.AreEqual("blah2", result.Properties.Single().Alias);

            }
        }