public void RollbackTest() { IModel m = GetModel(); Uri t1Uri = new Uri("semio:test:testInstance1"); MappingTestClass t1 = m.CreateResource <MappingTestClass>(t1Uri); // Add value using the mapping interface string strValue = "Hallo Welt!"; t1.uniqueStringTest = strValue; t1.Commit(); t1.uniqueStringTest = "HelloWorld!"; t1.Rollback(); Assert.AreEqual(strValue, t1.uniqueStringTest); MappingTestClass newRef = m.GetResource <MappingTestClass>(t1Uri); newRef.stringTest.Add("Hi"); newRef.stringTest.Add("Blub"); newRef.Commit(); t1.Rollback(); Assert.AreEqual(2, t1.stringTest.Count); Assert.IsTrue(t1.stringTest.Contains("Hi")); Assert.IsTrue(t1.stringTest.Contains("Blub")); Uri t2Uri = new Uri("semio:test:testInstance2"); MappingTestClass2 p = m.CreateResource <MappingTestClass2>(t2Uri); p.uniqueStringTest = "blub"; p.Commit(); newRef = m.GetResource <MappingTestClass>(t1Uri); newRef.resourceTest.Add(p); newRef.Commit(); t1.Rollback(); Assert.IsTrue(t1.resourceTest.Count == 1); Assert.IsTrue(t1.resourceTest.Contains(p)); }
public void RollbackTest() { IModel m = GetModel(); Uri u0 = new Uri("urn:id:0"); MappingTestClass r0 = m.CreateResource <MappingTestClass>(u0); // Add value using the mapping interface string strValue = "Hallo Welt!"; r0.uniqueStringTest = strValue; r0.Commit(); r0.uniqueStringTest = "HelloWorld!"; r0.Rollback(); Assert.AreEqual(strValue, r0.uniqueStringTest); MappingTestClass r0ref = m.GetResource <MappingTestClass>(u0); r0ref.stringTest.Add("Hi"); r0ref.stringTest.Add("Blub"); r0ref.Commit(); r0.Rollback(); Assert.AreEqual(2, r0.stringTest.Count); Assert.IsTrue(r0.stringTest.Contains("Hi")); Assert.IsTrue(r0.stringTest.Contains("Blub")); Uri u1 = new Uri("urn:id:1"); MappingTestClass2 r1 = m.CreateResource <MappingTestClass2>(u1); r1.uniqueStringTest = "blub"; r1.Commit(); r0ref = m.GetResource <MappingTestClass>(u0); r0ref.resourceTest.Add(r1); r0ref.Commit(); r0.Rollback(); Assert.IsTrue(r0.resourceTest.Count == 1); Assert.IsTrue(r0.resourceTest.Contains(r1)); }