Datei: IntegrationTests/IntegrationTests/DeleteForeignRelationTests.cs
Last Commit (9d1552b)
1 | // |
2 | // Copyright (c) 2002-2016 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | |
23 | using System; |
24 | using System.Collections; |
25 | using NUnit.Framework; |
26 | using NDO; |
27 | using DeleteForeignRelation; |
28 | |
29 | namespace NdoUnitTests |
30 | { |
31 | ····[TestFixture] |
32 | public class DeleteForeignRelationTests |
33 | ····{ |
34 | ········[SetUp] |
35 | ········public void Setup() |
36 | ········{ |
37 | ········} |
38 | |
39 | ········[TearDown] |
40 | ········public void TearDown() |
41 | ········{ |
42 | ············var pm = PmFactory.NewPersistenceManager(); |
43 | ············IList l = pm.GetClassExtent(typeof(DfrAddress)); |
44 | ············pm.Delete(l); |
45 | ············l = pm.GetClassExtent(typeof(DfrContact)); |
46 | ············pm.Delete(l); |
47 | ············l = pm.GetClassExtent(typeof(DfrAddressDescriptor)); |
48 | ············pm.Delete(l); |
49 | ············pm.Dispose(); |
50 | ········} |
51 | |
52 | |
53 | ········[Test] |
54 | ········public void TestDfr() |
55 | ········{ |
56 | ············var pm = PmFactory.NewPersistenceManager(); |
57 | |
58 | ············DfrContact contact = new DfrContact(); |
59 | ············contact.Name = "Hans Möller"; |
60 | ············pm.MakePersistent(contact as IPersistenceCapable); |
61 | |
62 | ············DfrAddress address = new DfrAddress(); |
63 | ············pm.MakePersistent(address as IPersistenceCapable); |
64 | ············address.Ort = "Wahnweil";········ |
65 | ············address.OriginContact = contact; |
66 | ······ |
67 | ············DfrAddressDescriptor descriptor = address.NewAddressDescriptor(contact); |
68 | ············descriptor.IsAdopted = true; |
69 | |
70 | ············Assert.That(1 ==··contact.Addresses.Count, "Count falsch"); |
71 | ············Assert.That((contact.Addresses[0] as DfrAddressDescriptor) == descriptor, "Descriptor falsch"); |
72 | ············pm.Save(); |
73 | |
74 | ············pm.MakeHollow(contact as IPersistenceCapable); |
75 | |
76 | ············address.RemoveAddressDescriptor(descriptor); |
77 | ············Assert.That(NDOObjectState.Deleted ==··descriptor.NDOObjectState, "Status falsch"); |
78 | ········} |
79 | ····} |
80 | } |
81 |
New Commit (60cb179)
1 | // |
2 | // Copyright (c) 2002-2016 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | |
23 | using System; |
24 | using System.Collections; |
25 | using NUnit.Framework; |
26 | using NDO; |
27 | using DeleteForeignRelation; |
28 | |
29 | namespace NdoUnitTests |
30 | { |
31 | ····[TestFixture] |
32 | public class DeleteForeignRelationTests : NDOTest |
33 | ····{ |
34 | ········[SetUp] |
35 | ········public void Setup() |
36 | ········{ |
37 | ········} |
38 | |
39 | ········[TearDown] |
40 | ········public void TearDown() |
41 | ········{ |
42 | ············var pm = PmFactory.NewPersistenceManager(); |
43 | ············IList l = pm.GetClassExtent(typeof(DfrAddress)); |
44 | ············pm.Delete(l); |
45 | ············l = pm.GetClassExtent(typeof(DfrContact)); |
46 | ············pm.Delete(l); |
47 | ············l = pm.GetClassExtent(typeof(DfrAddressDescriptor)); |
48 | ············pm.Delete(l); |
49 | ············pm.Dispose(); |
50 | ········} |
51 | |
52 | |
53 | ········[Test] |
54 | ········public void TestDfr() |
55 | ········{ |
56 | ············var pm = PmFactory.NewPersistenceManager(); |
57 | |
58 | ············DfrContact contact = new DfrContact(); |
59 | ············contact.Name = "Hans Möller"; |
60 | ············pm.MakePersistent(contact as IPersistenceCapable); |
61 | |
62 | ············DfrAddress address = new DfrAddress(); |
63 | ············pm.MakePersistent(address as IPersistenceCapable); |
64 | ············address.Ort = "Wahnweil";········ |
65 | ············address.OriginContact = contact; |
66 | ······ |
67 | ············DfrAddressDescriptor descriptor = address.NewAddressDescriptor(contact); |
68 | ············descriptor.IsAdopted = true; |
69 | |
70 | ············Assert.That(1 ==··contact.Addresses.Count, "Count falsch"); |
71 | ············Assert.That((contact.Addresses[0] as DfrAddressDescriptor) == descriptor, "Descriptor falsch"); |
72 | ············pm.Save(); |
73 | |
74 | ············pm.MakeHollow(contact as IPersistenceCapable); |
75 | |
76 | ············address.RemoveAddressDescriptor(descriptor); |
77 | ············Assert.That(NDOObjectState.Deleted ==··descriptor.NDOObjectState, "Status falsch"); |
78 | ········} |
79 | ····} |
80 | } |
81 |