Datei: IntegrationTests/IntegrationTests/IntermediateClassTest.cs
Last Commit (a04c7be)
			
| 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.Linq; | 
| 25 | using System.Collections; | 
| 26 | using NUnit.Framework; | 
| 27 | using NDO; | 
| 28 | using PureBusinessClasses; | 
| 29 | using NDO.Query; | 
| 30 | using Microsoft.Extensions.DependencyInjection; | 
| 31 | using Microsoft.Extensions.Logging; | 
| 32 | |
| 33 | namespace NdoUnitTests | 
| 34 | { | 
| 35 | ····[TestFixture] | 
| 36 | ····public class IntermediateClassTest : NDOTest | 
| 37 | ····{ | 
| 38 | ········Order order; | 
| 39 | ········Product pr; | 
| 40 | ········ | 
| 41 | ········[SetUp] | 
| 42 | ········public void Setup() | 
| 43 | ········{ | 
| 44 | ········} | 
| 45 | |
| 46 | ········void CreateProductAndOrder(PersistenceManager pm) | 
| 47 | ········{ | 
| 48 | ············order = new Order(); | 
| 49 | ············order.Date = DateTime.Now; | 
| 50 | ············pm.MakePersistent( order ); | 
| 51 | |
| 52 | ············pr = new Product(); | 
| 53 | ············pr.Name = "Shirt"; | 
| 54 | ············pm.MakePersistent( pr ); | 
| 55 | ············pm.Save(); | 
| 56 | ········} | 
| 57 | |
| 58 | ········[TearDown] | 
| 59 | ········public void TearDown() | 
| 60 | ········{ | 
| 61 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 62 | ············pm.Delete(pm.GetClassExtent(typeof(Order))); | 
| 63 | ············pm.Save(); | 
| 64 | ············pm.Delete(pm.GetClassExtent(typeof(Product))); | 
| 65 | ············pm.Save(); | 
| 66 | ········} | 
| 67 | |
| 68 | ········private void CreateOrderDetail() | 
| 69 | ········{ | 
| 70 | ············OrderDetail od = order.NewOrderDetail(pr); | 
| 71 | ············od.Price =49m; | 
| 72 | ············Assert.That(od.NDOObjectId.Id is DependentKey, "Wrong type"); | 
| 73 | ············DependentKey dk = (DependentKey) od.NDOObjectId.Id; | 
| 74 | ············Assert.That(dk.IsValid, "Dependent key not valid"); | 
| 75 | ········} | 
| 76 | |
| 77 | ········[Test] | 
| 78 | ········public void TestCreateSave() | 
| 79 | ········{ | 
| 80 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 81 | ············CreateSave( pm ); | 
| 82 | ········} | 
| 83 | |
| 84 | ········public void CreateSave(PersistenceManager pm) | 
| 85 | ········{ | 
| 86 | ············CreateProductAndOrder( pm ); | 
| 87 | ············var logger = (TestLogger)Host.Services.GetRequiredService<ILoggerFactory>().CreateLogger("Tests"); | 
| 88 | ············CreateOrderDetail(); | 
| 89 | ············pm.Save(); | 
| 90 | ············pm.UnloadCache(); | 
| 91 | ············IList orders = pm.GetClassExtent(typeof(Order)); | 
| 92 | ············Assert.That(1 ==··orders.Count ); | 
| 93 | ············Order o = (Order) orders[0]; | 
| 94 | ············Assert.That(1 ==··o.OrderDetails.Count() ); | 
| 95 | ············var text = logger.Text; | 
| 96 | ············OrderDetail od = (OrderDetail) o.OrderDetails.First(); | 
| 97 | ············Assert.That(od.Product != null, "Product shouldn't be null"); | 
| 98 | ········} | 
| 99 | |
| 100 | ········[Test] | 
| 101 | ········public void WrongSetup() | 
| 102 | ········{ | 
| 103 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 104 | ············order = new Order(); | 
| 105 | ············order.Date = DateTime.Now.Date; | 
| 106 | ············pm.MakePersistent(order); | 
| 107 | ············int exnr = 0; | 
| 108 | ············try | 
| 109 | ············{ | 
| 110 | ················order.NewOrderDetail(null); | 
| 111 | ············} | 
| 112 | ············catch (NDOException ex) | 
| 113 | ············{ | 
| 114 | ················exnr = ex.ErrorNumber; | 
| 115 | ············} | 
| 116 | ············Assert.That(exnr == 41, "NDOException #41 should have been happened"); | 
| 117 | ········} | 
| 118 | |
| 119 | ········[Test] | 
| 120 | ········public void RemoveRelatedObject() | 
| 121 | ········{ | 
| 122 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 123 | ············CreateProductAndOrder( pm ); | 
| 124 | ············CreateOrderDetail(); | 
| 125 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 126 | ············Assert.That(NDOObjectState.Created ==··od.NDOObjectState ); | 
| 127 | ············order.RemoveOrderDetail( od ); | 
| 128 | ············Assert.That(NDOObjectState.Transient ==··od.NDOObjectState ); | 
| 129 | ········} | 
| 130 | |
| 131 | ········[Test] | 
| 132 | ········public void RemoveRelatedObjectSave() | 
| 133 | ········{ | 
| 134 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 135 | ············CreateProductAndOrder( pm ); | 
| 136 | ············CreateOrderDetail(); | 
| 137 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 138 | ············Assert.That(od.NDOObjectState == NDOObjectState.Created, "Wrong state #1"); | 
| 139 | ············pm.Save(); | 
| 140 | ············Assert.That(od.NDOObjectState == NDOObjectState.Persistent, "Wrong state #2"); | 
| 141 | ············order.RemoveOrderDetail(od); | 
| 142 | ············Assert.That(od.NDOObjectState == NDOObjectState.Deleted, "Wrong state #3"); | 
| 143 | ········} | 
| 144 | |
| 145 | ········[Test] | 
| 146 | ········public void RemoveRelatedObjectSaveReload() | 
| 147 | ········{ | 
| 148 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 149 | ············CreateProductAndOrder( pm ); | 
| 150 | ············CreateOrderDetail(); | 
| 151 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 152 | ············Assert.That( od.NDOObjectState == NDOObjectState.Created, "Wrong state #1" ); | 
| 153 | ············pm.Save(); | 
| 154 | ············Assert.That( od.NDOObjectState == NDOObjectState.Persistent, "Wrong state #2" ); | 
| 155 | ············order.RemoveOrderDetail( od ); | 
| 156 | ············Assert.That( od.NDOObjectState == NDOObjectState.Deleted, "Wrong state #3" ); | 
| 157 | ············pm.Save(); | 
| 158 | ············pm.UnloadCache(); | 
| 159 | ············order = pm.Objects<Order>().Single(); | 
| 160 | ············Assert.That(0 ==··order.OrderDetails.Count() ); | 
| 161 | ············Assert.That(0 ==··pm.Objects<OrderDetail>().Count ); | 
| 162 | |
| 163 | ········} | 
| 164 | |
| 165 | ········[Test] | 
| 166 | ········public void InsertWithTransientOrder() | 
| 167 | ········{ | 
| 168 | ············Order o2 = new Order(); | 
| 169 | ············o2.Date = DateTime.Now; | 
| 170 | ············OrderDetail od = o2.NewOrderDetail(this.pr); | 
| 171 | ············// Nothing should happen, since o2 is transient and is | 
| 172 | ············// not under the control of the pm. | 
| 173 | ········} | 
| 174 | |
| 175 | |
| 176 | ········[Test] | 
| 177 | ········public void InsertWithTransientProduct() | 
| 178 | ········{ | 
| 179 | ············Product p2 = new Product(); | 
| 180 | ············p2.Name = "Trouser"; | 
| 181 | ············int exnr = 0; | 
| 182 | ············try | 
| 183 | ············{ | 
| 184 | ················OrderDetail od = order.NewOrderDetail(p2); | 
| 185 | ············} | 
| 186 | ············catch (NDOException ex) | 
| 187 | ············{ | 
| 188 | ················exnr = ex.ErrorNumber; | 
| 189 | ············} | 
| 190 | ············Assert.That(exnr == 59, "Exception 59 should have been occured"); | 
| 191 | ········} | 
| 192 | |
| 193 | |
| 194 | ········[Test] | 
| 195 | ········public void Insert() | 
| 196 | ········{ | 
| 197 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 198 | ············CreateSave(pm); | 
| 199 | ············Product p2 = new Product(); | 
| 200 | ············p2.Name = "Trouser"; | 
| 201 | ············pm.MakePersistent(p2); | 
| 202 | ············OrderDetail od = order.NewOrderDetail(p2); | 
| 203 | ············Assert.That(NDOObjectState.Created ==··od.NDOObjectState, "Wrong state"); | 
| 204 | ············od.Price = 55; | 
| 205 | ············pm.Save(); | 
| 206 | ············pm.UnloadCache(); | 
| 207 | ············IQuery q = new NDOQuery<Order>(pm); | 
| 208 | ············order = (Order) q.ExecuteSingle(true); | 
| 209 | ············Assert.That(2 ==··order.OrderDetails.Count(), "Wrong count"); | 
| 210 | ········} | 
| 211 | |
| 212 | |
| 213 | ········[Test] | 
| 214 | ········public void Reload() | 
| 215 | ········{ | 
| 216 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 217 | ············CreateSave(pm); | 
| 218 | ············OrderDetail od = (OrderDetail) order.OrderDetails.First(); | 
| 219 | ············pm.UnloadCache(); | 
| 220 | ············od = (OrderDetail) pm.FindObject(od.NDOObjectId); | 
| 221 | ············decimal d = od.Price; | 
| 222 | ········} | 
| 223 | |
| 224 | ········[Test] | 
| 225 | ········public void Delete() | 
| 226 | ········{ | 
| 227 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 228 | ············CreateSave( pm ); | 
| 229 | ············pm.UnloadCache(); | 
| 230 | ············var q = new NDOQuery<Order>(pm); | 
| 231 | ············var order = q.ExecuteSingle(true); | 
| 232 | ············order.RemoveOrderDetail( order.OrderDetails.First() ); | 
| 233 | ············pm.Save(); | 
| 234 | ············pm.UnloadCache(); | 
| 235 | ············var count = pm.Objects<OrderDetail>().Count; | 
| 236 | ············Assert.That(0 ==··count ); | 
| 237 | |
| 238 | ············order = pm.Objects<Order>().Single(); // Throws, if count != 1 | 
| 239 | ············Assert.That(0 ==··order.OrderDetails.Count() ); | 
| 240 | ········} | 
| 241 | |
| 242 | ········[Test] | 
| 243 | ········public void DeleteParent() | 
| 244 | ········{ | 
| 245 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 246 | ············CreateSave(pm); | 
| 247 | ············pm.UnloadCache(); | 
| 248 | ············IQuery q = new NDOQuery<Order>(pm); | 
| 249 | ············order = (Order) q.ExecuteSingle(true); | 
| 250 | ············pm.Delete(order); | 
| 251 | ············pm.Save(); | 
| 252 | ············pm.UnloadCache(); | 
| 253 | ············IList l = pm.GetClassExtent(typeof(OrderDetail)); | 
| 254 | ············Assert.That(0 ==··l.Count, "Wrong count #1"); | 
| 255 | ············l = pm.GetClassExtent(typeof(Order)); | 
| 256 | ············Assert.That(0 ==··l.Count, "Wrong count #2"); | 
| 257 | ········} | 
| 258 | ····} | 
| 259 | } | 
| 260 | 
New Commit (8bd8c9d)
			
| 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.Linq; | 
| 25 | using System.Collections; | 
| 26 | using NUnit.Framework; | 
| 27 | using NDO; | 
| 28 | using PureBusinessClasses; | 
| 29 | using NDO.Query; | 
| 30 | using Microsoft.Extensions.DependencyInjection; | 
| 31 | using Microsoft.Extensions.Logging; | 
| 32 | |
| 33 | namespace NdoUnitTests | 
| 34 | { | 
| 35 | ····[TestFixture] | 
| 36 | ····public class IntermediateClassTest : NDOTest | 
| 37 | ····{ | 
| 38 | ········Order order; | 
| 39 | ········Product pr; | 
| 40 | ········ | 
| 41 | ········[SetUp] | 
| 42 | ········public void Setup() | 
| 43 | ········{ | 
| 44 | ········} | 
| 45 | |
| 46 | ········void CreateProductAndOrder(PersistenceManager pm) | 
| 47 | ········{ | 
| 48 | ············order = new Order(); | 
| 49 | ············order.Date = DateTime.Now; | 
| 50 | ············pm.MakePersistent( order ); | 
| 51 | |
| 52 | ············pr = new Product(); | 
| 53 | ············pr.Name = "Shirt"; | 
| 54 | ············pm.MakePersistent( pr ); | 
| 55 | ············pm.Save(); | 
| 56 | ········} | 
| 57 | |
| 58 | ········[TearDown] | 
| 59 | ········public void TearDown() | 
| 60 | ········{ | 
| 61 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 62 | ············pm.Delete(pm.GetClassExtent(typeof(Order))); | 
| 63 | ············pm.Save(); | 
| 64 | ············pm.Delete(pm.GetClassExtent(typeof(Product))); | 
| 65 | ············pm.Save(); | 
| 66 | ········} | 
| 67 | |
| 68 | ········private void CreateOrderDetail() | 
| 69 | ········{ | 
| 70 | ············OrderDetail od = order.NewOrderDetail(pr); | 
| 71 | ············od.Price =49m; | 
| 72 | ············Assert.That(od.NDOObjectId.Id is DependentKey, "Wrong type"); | 
| 73 | ············DependentKey dk = (DependentKey) od.NDOObjectId.Id; | 
| 74 | ············Assert.That(dk.IsValid, "Dependent key not valid"); | 
| 75 | ········} | 
| 76 | |
| 77 | ········[Test] | 
| 78 | ········public void TestCreateSave() | 
| 79 | ········{ | 
| 80 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 81 | ············CreateSave( pm ); | 
| 82 | ········} | 
| 83 | |
| 84 | ········public void CreateSave(PersistenceManager pm) | 
| 85 | ········{ | 
| 86 | ············CreateProductAndOrder( pm ); | 
| 87 | ············CreateOrderDetail(); | 
| 88 | ············pm.Save(); | 
| 89 | ············pm.UnloadCache(); | 
| 90 | ············IList orders = pm.GetClassExtent(typeof(Order)); | 
| 91 | ············Assert.That(1 ==··orders.Count ); | 
| 92 | ············Order o = (Order) orders[0]; | 
| 93 | ············Assert.That(1 ==··o.OrderDetails.Count() ); | 
| 94 | ············OrderDetail od = (OrderDetail) o.OrderDetails.First(); | 
| 95 | ············Assert.That(od.Product != null, "Product shouldn't be null"); | 
| 96 | ········} | 
| 97 | |
| 98 | ········[Test] | 
| 99 | ········public void WrongSetup() | 
| 100 | ········{ | 
| 101 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 102 | ············order = new Order(); | 
| 103 | ············order.Date = DateTime.Now.Date; | 
| 104 | ············pm.MakePersistent(order); | 
| 105 | ············int exnr = 0; | 
| 106 | ············try | 
| 107 | ············{ | 
| 108 | ················order.NewOrderDetail(null); | 
| 109 | ············} | 
| 110 | ············catch (NDOException ex) | 
| 111 | ············{ | 
| 112 | ················exnr = ex.ErrorNumber; | 
| 113 | ············} | 
| 114 | ············Assert.That(exnr == 41, "NDOException #41 should have been happened"); | 
| 115 | ········} | 
| 116 | |
| 117 | ········[Test] | 
| 118 | ········public void RemoveRelatedObject() | 
| 119 | ········{ | 
| 120 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 121 | ············CreateProductAndOrder( pm ); | 
| 122 | ············CreateOrderDetail(); | 
| 123 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 124 | ············Assert.That(NDOObjectState.Created ==··od.NDOObjectState ); | 
| 125 | ············order.RemoveOrderDetail( od ); | 
| 126 | ············Assert.That(NDOObjectState.Transient ==··od.NDOObjectState ); | 
| 127 | ········} | 
| 128 | |
| 129 | ········[Test] | 
| 130 | ········public void RemoveRelatedObjectSave() | 
| 131 | ········{ | 
| 132 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 133 | ············CreateProductAndOrder( pm ); | 
| 134 | ············CreateOrderDetail(); | 
| 135 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 136 | ············Assert.That(od.NDOObjectState == NDOObjectState.Created, "Wrong state #1"); | 
| 137 | ············pm.Save(); | 
| 138 | ············Assert.That(od.NDOObjectState == NDOObjectState.Persistent, "Wrong state #2"); | 
| 139 | ············order.RemoveOrderDetail(od); | 
| 140 | ············Assert.That(od.NDOObjectState == NDOObjectState.Deleted, "Wrong state #3"); | 
| 141 | ········} | 
| 142 | |
| 143 | ········[Test] | 
| 144 | ········public void RemoveRelatedObjectSaveReload() | 
| 145 | ········{ | 
| 146 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 147 | ············CreateProductAndOrder( pm ); | 
| 148 | ············CreateOrderDetail(); | 
| 149 | ············OrderDetail od = (OrderDetail)order.OrderDetails.First(); | 
| 150 | ············Assert.That( od.NDOObjectState == NDOObjectState.Created, "Wrong state #1" ); | 
| 151 | ············pm.Save(); | 
| 152 | ············Assert.That( od.NDOObjectState == NDOObjectState.Persistent, "Wrong state #2" ); | 
| 153 | ············order.RemoveOrderDetail( od ); | 
| 154 | ············Assert.That( od.NDOObjectState == NDOObjectState.Deleted, "Wrong state #3" ); | 
| 155 | ············pm.Save(); | 
| 156 | ············pm.UnloadCache(); | 
| 157 | ············order = pm.Objects<Order>().Single(); | 
| 158 | ············Assert.That(0 ==··order.OrderDetails.Count() ); | 
| 159 | ············Assert.That(0 ==··pm.Objects<OrderDetail>().Count ); | 
| 160 | |
| 161 | ········} | 
| 162 | |
| 163 | ········[Test] | 
| 164 | ········public void InsertWithTransientOrder() | 
| 165 | ········{ | 
| 166 | ············Order o2 = new Order(); | 
| 167 | ············o2.Date = DateTime.Now; | 
| 168 | ············OrderDetail od = o2.NewOrderDetail(this.pr); | 
| 169 | ············// Nothing should happen, since o2 is transient and is | 
| 170 | ············// not under the control of the pm. | 
| 171 | ········} | 
| 172 | |
| 173 | |
| 174 | ········[Test] | 
| 175 | ········public void InsertWithTransientProduct() | 
| 176 | ········{ | 
| 177 | ············Product p2 = new Product(); | 
| 178 | ············p2.Name = "Trouser"; | 
| 179 | ············int exnr = 0; | 
| 180 | ············try | 
| 181 | ············{ | 
| 182 | ················OrderDetail od = order.NewOrderDetail(p2); | 
| 183 | ············} | 
| 184 | ············catch (NDOException ex) | 
| 185 | ············{ | 
| 186 | ················exnr = ex.ErrorNumber; | 
| 187 | ············} | 
| 188 | ············Assert.That(exnr == 59, "Exception 59 should have been occured"); | 
| 189 | ········} | 
| 190 | |
| 191 | |
| 192 | ········[Test] | 
| 193 | ········public void Insert() | 
| 194 | ········{ | 
| 195 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 196 | ············CreateSave(pm); | 
| 197 | ············Product p2 = new Product(); | 
| 198 | ············p2.Name = "Trouser"; | 
| 199 | ············pm.MakePersistent(p2); | 
| 200 | ············OrderDetail od = order.NewOrderDetail(p2); | 
| 201 | ············Assert.That(NDOObjectState.Created ==··od.NDOObjectState, "Wrong state"); | 
| 202 | ············od.Price = 55; | 
| 203 | ············pm.Save(); | 
| 204 | ············pm.UnloadCache(); | 
| 205 | ············IQuery q = new NDOQuery<Order>(pm); | 
| 206 | ············order = (Order) q.ExecuteSingle(true); | 
| 207 | ············Assert.That(2 ==··order.OrderDetails.Count(), "Wrong count"); | 
| 208 | ········} | 
| 209 | |
| 210 | |
| 211 | ········[Test] | 
| 212 | ········public void Reload() | 
| 213 | ········{ | 
| 214 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 215 | ············CreateSave(pm); | 
| 216 | ············OrderDetail od = (OrderDetail) order.OrderDetails.First(); | 
| 217 | ············pm.UnloadCache(); | 
| 218 | ············od = (OrderDetail) pm.FindObject(od.NDOObjectId); | 
| 219 | ············decimal d = od.Price; | 
| 220 | ········} | 
| 221 | |
| 222 | ········[Test] | 
| 223 | ········public void Delete() | 
| 224 | ········{ | 
| 225 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 226 | ············CreateSave( pm ); | 
| 227 | ············pm.UnloadCache(); | 
| 228 | ············var q = new NDOQuery<Order>(pm); | 
| 229 | ············var order = q.ExecuteSingle(true); | 
| 230 | ············order.RemoveOrderDetail( order.OrderDetails.First() ); | 
| 231 | ············pm.Save(); | 
| 232 | ············pm.UnloadCache(); | 
| 233 | ············var count = pm.Objects<OrderDetail>().Count; | 
| 234 | ············Assert.That(0 ==··count ); | 
| 235 | |
| 236 | ············order = pm.Objects<Order>().Single(); // Throws, if count != 1 | 
| 237 | ············Assert.That(0 ==··order.OrderDetails.Count() ); | 
| 238 | ········} | 
| 239 | |
| 240 | ········[Test] | 
| 241 | ········public void DeleteParent() | 
| 242 | ········{ | 
| 243 | ············var pm = PmFactory.NewPersistenceManager(); | 
| 244 | ············CreateSave(pm); | 
| 245 | ············pm.UnloadCache(); | 
| 246 | ············IQuery q = new NDOQuery<Order>(pm); | 
| 247 | ············order = (Order) q.ExecuteSingle(true); | 
| 248 | ············pm.Delete(order); | 
| 249 | ············pm.Save(); | 
| 250 | ············pm.UnloadCache(); | 
| 251 | ············IList l = pm.GetClassExtent(typeof(OrderDetail)); | 
| 252 | ············Assert.That(0 ==··l.Count, "Wrong count #1"); | 
| 253 | ············l = pm.GetClassExtent(typeof(Order)); | 
| 254 | ············Assert.That(0 ==··l.Count, "Wrong count #2"); | 
| 255 | ········} | 
| 256 | ····} | 
| 257 | } | 
| 258 |