Datei: IntegrationTests/IntegrationTests/DateTest.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.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
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 (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.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