Пример #1
0
        public void Add_Localizable_Entity_Preserve_Original_And_Loads_Localized()
        {
            using (var db = new TestDataContext())
            {
                db.ReCreate();
                var entity = new LocalizedEntity {
                    NotLocalizedText = "NotLocalizedText", LocalizedText = "LocalizedText"
                };

                db.LocalizedEntities.Add(entity);
                db.SaveChanges();
            }

            using (var db = new TestDataContext())
            {
                var entity = db.LocalizedEntities.First();
                entity.LanguageCode  = "cs";
                entity.LocalizedText = "new localized text";
                db.SaveChanges();
            }

            using (var db = new TestDataContext())
            {
                var entity = db.LocalizeEntity(db.LocalizedEntities.First(), "cs");

                Assert.AreEqual(1, entity.Id);
                Assert.AreEqual("NotLocalizedText", entity.NotLocalizedText);
                Assert.AreEqual("new localized text", entity.LocalizedText);
            }
        }