Datei: IntegrationTests/IntegrationTests/DateTest.cs
Last Commit (182cfd7)
| 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.Diagnostics; |
| 25 | using System.Collections; |
| 26 | using NUnit.Framework; |
| 27 | using NDO; |
| 28 | using DateTest; |
| 29 | using NDO.Query; |
| 30 | |
| 31 | namespace NdoUnitTests |
| 32 | { |
| 33 | ····[TestFixture] |
| 34 | ····public class DateTest : NDOTest |
| 35 | ····{ |
| 36 | ········ |
| 37 | ········[SetUp] |
| 38 | ········public void Setup() |
| 39 | ········{ |
| 40 | ········} |
| 41 | |
| 42 | ········[TearDown] |
| 43 | ········public void TearDown() |
| 44 | ········{ |
| 45 | ············var pm = PmFactory.NewPersistenceManager(); |
| 46 | ············NDOQuery<DateTestClass> q = new NDOQuery<DateTestClass>(pm, null); |
| 47 | ············IList l = q.Execute(); |
| 48 | ············pm.Delete(l); |
| 49 | ············pm.Save(); |
| 50 | ············pm.Close(); |
| 51 | ········} |
| 52 | |
| 53 | ········[Test] |
| 54 | ········public void TestCreated() |
| 55 | ········{ |
| 56 | ············var pm = PmFactory.NewPersistenceManager(); |
| 57 | |
| 58 | ············// dt = new DateTime(2004, 10, 12, 13, 30, 31, 123); |
| 59 | ············DateTestClass dtc = new DateTestClass(); |
| 60 | ············InnerDate id = new InnerDate(); |
| 61 | ············id.SetInnerDate(); |
| 62 | ············pm.MakePersistent(id); |
| 63 | ············pm.MakePersistent(dtc); |
| 64 | ············pm.Save(); |
| 65 | ············dtc.InnerDate = id; |
| 66 | ············dtc.Name = "Test";············ |
| 67 | ············pm.Save(); |
| 68 | ············pm.UnloadCache(); |
| 69 | |
| 70 | ············NDOQuery<DateTestClass> q = new NDOQuery<DateTestClass>(pm, null); |
| 71 | ············dtc = (DateTestClass) q.ExecuteSingle(true); |
| 72 | ············Assert.That(2002 ==··dtc.InnerDate.Dt.Year, "DateTime konnte nicht richtig gelesen werden"); |
| 73 | ········} |
| 74 | |
| 75 | ········[Test] |
| 76 | ········public void TestPersistent() |
| 77 | ········{ |
| 78 | ············var pm = PmFactory.NewPersistenceManager(); |
| 79 | |
| 80 | ············InnerDate id = new InnerDate(); |
| 81 | ············pm.MakePersistent(id); |
| 82 | ············pm.Save(); |
| 83 | ············pm.UnloadCache(); |
| 84 | ············id.SetInnerDate(); |
| 85 | ············ObjectHelper.MarkDirty(id); |
| 86 | ············Assert.That(NDOObjectState.PersistentDirty ==··id.NDOObjectState, "Status falsch"); |
| 87 | ············pm.Save(); |
| 88 | ········} |
| 89 | |
| 90 | ········[Test] |
| 91 | ········public void ProviderTest() |
| 92 | ········{ |
| 93 | ············var pm = PmFactory.NewPersistenceManager(); |
| 94 | |
| 95 | ············Trace.WriteLine("Provider: " + pm.NDOMapping.GetProvider(typeof(Reisekosten.Personal.Mitarbeiter)).GetType().Assembly.FullName); |
| 96 | ············Trace.WriteLine("Available Providers:"); |
| 97 | ············foreach (string s in NDOProviderFactory.Instance.ProviderNames) |
| 98 | ················Trace.WriteLine("··" + s); |
| 99 | ········} |
| 100 | |
| 101 | ····} |
| 102 | } |
| 103 |
New 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.Diagnostics; |
| 25 | using System.Collections; |
| 26 | using NUnit.Framework; |
| 27 | using NDO; |
| 28 | using DateTest; |
| 29 | using NDO.Query; |
| 30 | using NDO.ProviderFactory; |
| 31 | |
| 32 | namespace NdoUnitTests |
| 33 | { |
| 34 | ····[TestFixture] |
| 35 | ····public class DateTest : NDOTest |
| 36 | ····{ |
| 37 | ········ |
| 38 | ········[SetUp] |
| 39 | ········public void Setup() |
| 40 | ········{ |
| 41 | ········} |
| 42 | |
| 43 | ········[TearDown] |
| 44 | ········public void TearDown() |
| 45 | ········{ |
| 46 | ············var pm = PmFactory.NewPersistenceManager(); |
| 47 | ············NDOQuery<DateTestClass> q = new NDOQuery<DateTestClass>(pm, null); |
| 48 | ············IList l = q.Execute(); |
| 49 | ············pm.Delete(l); |
| 50 | ············pm.Save(); |
| 51 | ············pm.Close(); |
| 52 | ········} |
| 53 | |
| 54 | ········[Test] |
| 55 | ········public void TestCreated() |
| 56 | ········{ |
| 57 | ············var pm = PmFactory.NewPersistenceManager(); |
| 58 | |
| 59 | ············// dt = new DateTime(2004, 10, 12, 13, 30, 31, 123); |
| 60 | ············DateTestClass dtc = new DateTestClass(); |
| 61 | ············InnerDate id = new InnerDate(); |
| 62 | ············id.SetInnerDate(); |
| 63 | ············pm.MakePersistent(id); |
| 64 | ············pm.MakePersistent(dtc); |
| 65 | ············pm.Save(); |
| 66 | ············dtc.InnerDate = id; |
| 67 | ············dtc.Name = "Test";············ |
| 68 | ············pm.Save(); |
| 69 | ············pm.UnloadCache(); |
| 70 | |
| 71 | ············NDOQuery<DateTestClass> q = new NDOQuery<DateTestClass>(pm, null); |
| 72 | ············dtc = (DateTestClass) q.ExecuteSingle(true); |
| 73 | ············Assert.That(2002 ==··dtc.InnerDate.Dt.Year, "DateTime konnte nicht richtig gelesen werden"); |
| 74 | ········} |
| 75 | |
| 76 | ········[Test] |
| 77 | ········public void TestPersistent() |
| 78 | ········{ |
| 79 | ············var pm = PmFactory.NewPersistenceManager(); |
| 80 | |
| 81 | ············InnerDate id = new InnerDate(); |
| 82 | ············pm.MakePersistent(id); |
| 83 | ············pm.Save(); |
| 84 | ············pm.UnloadCache(); |
| 85 | ············id.SetInnerDate(); |
| 86 | ············ObjectHelper.MarkDirty(id); |
| 87 | ············Assert.That(NDOObjectState.PersistentDirty ==··id.NDOObjectState, "Status falsch"); |
| 88 | ············pm.Save(); |
| 89 | ········} |
| 90 | |
| 91 | ········[Test] |
| 92 | ········public void ProviderTest() |
| 93 | ········{ |
| 94 | ············var pm = PmFactory.NewPersistenceManager(); |
| 95 | |
| 96 | ············Trace.WriteLine("Provider: " + pm.NDOMapping.GetProvider(typeof(Reisekosten.Personal.Mitarbeiter)).GetType().Assembly.FullName); |
| 97 | ············Trace.WriteLine("Available Providers:"); |
| 98 | ············foreach (string s in NDOProviderFactory.Instance.ProviderNames) |
| 99 | ················Trace.WriteLine("··" + s); |
| 100 | ········} |
| 101 | |
| 102 | ····} |
| 103 | } |
| 104 |