Example #1
0
        public void property_can_only_have_one_preferred_picture()
        {
            // arrange
            var pic1 = new PropertyPicture { PictureUrl="pic1.png"};
            var pic2 = new PropertyPicture { PictureUrl="pic2.png"};
            var pic3 = new PropertyPicture { PictureUrl="pic3.png"};
             _property.Pictures.Add(pic1);
            _property.Pictures.Add(pic2);
            _property.Pictures.Add(pic3);
            _property.SetPreferredPicture(pic1);

            Assert.AreEqual(1, _property.Pictures.Count(p=>p.PreferredPicture == true));

            //act
            _property.SetPreferredPicture(pic2);

            // assert
            Assert.AreEqual(1, _property.Pictures.Count(p=>p.PreferredPicture == true));
        }
Example #2
0
        public virtual void SetPreferredPicture(PropertyPicture picture)
        {
            foreach (var p in Pictures)
            {
                p.SetPreferredPicture(false);
            }

            Pictures.Single(p => p == picture).SetPreferredPicture(true);
        }