public void NonEditablePropertyUpdateToNullIgnore() { using (var scope = TestScope.Create()) { var simpleID = Guid.NewGuid(); scope.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', 'x')" }); var repository = scope.Resolve <Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = null }; //Client may ignore existence of the DenyUserEdit properties (the value will be null on save). repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("x", repository.TestDenyUserEdit.Simple.Query().Where(item => item.ID == simpleID).Select(item => item.NonEditable).Single(), "Old value should remain unchanged after client sends null."); var simple2 = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = null }; // Explicit server update to null value should work. repository.TestDenyUserEdit.Simple.Save(null, new[] { simple2 }, null, false); Assert.IsNull(repository.TestDenyUserEdit.Simple.Query().Where(item => item.ID == simpleID).Select(item => item.NonEditable).Single(), "Explicit server update to null value should work."); } }
public void NonEditablePropertyUpdate() { using (var scope = TestScope.Create()) { var simpleID = Guid.NewGuid(); scope.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', 'x')" }); var repository = scope.Resolve <Common.DomRepository>(); Assert.AreEqual("a x null", DumpSimple(repository)); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "b", NonEditable = "x" }; repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("b x null", DumpSimple(repository)); simple.NonEditable = "y"; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true), "Simple", "NonEditable", "not allowed"); } }
public void NonEditablePropertyInsert() { using (var container = new RhetosTestContainer()) { container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = container.Resolve<Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { Editable = "a", NonEditable = "x" }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true), "Simple", "NonEditable", "not allowed"); } }
public void NonEditablePropertyInsert() { using (var scope = TestScope.Create()) { scope.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = scope.Resolve <Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { Editable = "a", NonEditable = "x" }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true), "Simple", "NonEditable", "not allowed"); } }
public void EditableProperty() { using (var container = new RhetosTestContainer()) { container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = container.Resolve<Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { Editable = "a" }; repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true); Assert.AreEqual("a null null", DumpSimple(repository)); simple.Editable = "b"; repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("b null null", DumpSimple(repository)); } }
public void EditableProperty() { using (var executionContext = new CommonTestExecutionContext()) { executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = new Common.DomRepository(executionContext); var simple = new TestDenyUserEdit.Simple { Editable = "a" }; repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true); Assert.AreEqual("a null null", DumpSimple(repository)); simple.Editable = "b"; repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("b null null", DumpSimple(repository)); } }
public void NonEditablePropertyUpdateFromNull() { using (var container = new RhetosTestContainer()) { var simpleID = Guid.NewGuid(); container.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', NULL)" }); var repository = container.Resolve <Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = "x" }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true), "Simple", "NonEditable", "not allowed"); } }
public void EditableProperty() { using (var scope = TestScope.Create()) { scope.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = scope.Resolve <Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { Editable = "a" }; repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true); Assert.AreEqual("a null null", DumpSimple(repository)); simple.Editable = "b"; repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("b null null", DumpSimple(repository)); } }
public void NonEditableRefereceInsertGuid() { using (var container = new RhetosTestContainer()) { container.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = container.Resolve <Common.DomRepository>(); var parent = new TestDenyUserEdit.Parent { Name = "p" }; repository.TestDenyUserEdit.Parent.Save(new[] { parent }, null, null, true); var simple = new TestDenyUserEdit.Simple { Editable = "a", NonEditableReferenceID = parent.ID }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true), "Simple", "NonEditableReference", "not allowed"); } }
public void NonEditablePropertyUpdateToNullIgnore() { using (var container = new RhetosTestContainer()) { var simpleID = Guid.NewGuid(); container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', 'x')" }); var repository = container.Resolve<Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = null }; //Client may ignore existence of the DenyUserEdit properties (the value will be null on save). repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true); Assert.AreEqual("x", repository.TestDenyUserEdit.Simple.Query().Where(item => item.ID == simpleID).Select(item => item.NonEditable).Single(), "Old value should remain unchanged after client sends null."); var simple2 = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = null }; // Explicit server update to null value should work. repository.TestDenyUserEdit.Simple.Save(null, new[] { simple2 }, null, false); Assert.IsNull(repository.TestDenyUserEdit.Simple.Query().Where(item => item.ID == simpleID).Select(item => item.NonEditable).Single(), "Explicit server update to null value should work."); } }
public void NonEditablePropertyUpdateFromNull() { using (var container = new RhetosTestContainer()) { var simpleID = Guid.NewGuid(); container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', NULL)" }); var repository = container.Resolve<Common.DomRepository>(); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = "x" }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true), "Simple", "NonEditable", "not allowed"); } }
public void NonEditableRefereceInsertGuid() { using (var executionContext = new CommonTestExecutionContext()) { executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent" }); var repository = new Common.DomRepository(executionContext); var parent = new TestDenyUserEdit.Parent { Name = "p" }; repository.TestDenyUserEdit.Parent.Save(new[] { parent }, null, null, true); var simple = new TestDenyUserEdit.Simple { Editable = "a", NonEditableReferenceID = parent.ID }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(new[] { simple }, null, null, true), "Simple", "NonEditableReference", "not allowed"); } }
public void NonEditablePropertyUpdateToNull() { using (var executionContext = new CommonTestExecutionContext()) { var simpleID = Guid.NewGuid(); executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestDenyUserEdit.Simple", "DELETE FROM TestDenyUserEdit.Parent", "INSERT INTO TestDenyUserEdit.Simple (ID, Editable, NonEditable) VALUES (" + SqlUtility.QuoteGuid(simpleID) + ", 'a', 'x')" }); var repository = new Common.DomRepository(executionContext); var simple = new TestDenyUserEdit.Simple { ID = simpleID, Editable = "a", NonEditable = null }; TestUtility.ShouldFail(() => repository.TestDenyUserEdit.Simple.Save(null, new[] { simple }, null, true), "Simple", "NonEditable", "not allowed"); } }