Skip to content

Commit 047c25b

Browse files
committed
Init logging before any test
1 parent 212bbcf commit 047c25b

2 files changed

Lines changed: 57 additions & 40 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using NUnit.Framework;
7+
using Xtensive.Orm.Logging;
8+
9+
namespace Xtensive.Orm.Tests.Core
10+
{
11+
[SetUpFixture]
12+
public class GlobalTestSetup
13+
{
14+
[OneTimeSetUp]
15+
public void RunBeforeAnyTests()
16+
{
17+
var configuraion = GetType().GetConfigurationForAssembly();
18+
LogManager.Default.Initialize(configuraion);
19+
}
20+
}
21+
}

Orm/Xtensive.Orm.Tests.Core/Logging/WriteToLogTests.cs

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
55
// Created: 2013.10.14
66

@@ -18,55 +18,51 @@ public class WriteToLogTests : HasConfigurationAccessTest
1818
{
1919
private const string filePath = "Log.txt";
2020

21-
[OneTimeSetUp]
22-
public void SetUp()
23-
{
24-
LogManager.Default.Initialize(Configuration);
25-
}
26-
2721
[Test]
2822
public void OrmLogTest()
2923
{
30-
if (File.Exists(filePath))
24+
if (File.Exists(filePath)) {
3125
File.Delete(filePath);
26+
}
27+
3228
OrmLog.Debug("Test message", null);
3329
OrmLog.Debug("Test message with parameter {0}", new object[] { 1 });
34-
OrmLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
30+
_ = OrmLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
3531
OrmLog.Debug("Test message", new object[] { 1 });
3632
OrmLog.Debug("Test message {0}", null);
37-
OrmLog.Debug(new Exception("Some exeption"));
33+
_ = OrmLog.Debug(new Exception("Some exeption"));
3834
OrmLog.Debug(null, new object[] { 1 });
3935

4036
OrmLog.Info("Test message", null);
4137
OrmLog.Info("Test message with parameter {0}", new object[] { 1 });
42-
OrmLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
38+
_ = OrmLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
4339
OrmLog.Info("Test message", new object[] { 1 });
4440
OrmLog.Info("Test message {0}", null);
45-
OrmLog.Info(new Exception("Some exeption"));
41+
_ = OrmLog.Info(new Exception("Some exeption"));
4642
OrmLog.Info(null, new object[] { 1 });
4743

4844
OrmLog.Warning("Test message", null);
4945
OrmLog.Warning("Test message with parameter {0}", new object[] { 1 });
50-
OrmLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
46+
_ = OrmLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
5147
OrmLog.Warning("Test message", new object[] { 1 });
5248
OrmLog.Warning("Test message {0}", null);
53-
OrmLog.Warning(new Exception("Some exeption"));
49+
_ = OrmLog.Warning(new Exception("Some exeption"));
5450
OrmLog.Warning(null, new object[] { 1 });
5551

5652
OrmLog.Error("Test message", null);
5753
OrmLog.Error("Test message with parameter {0}", new object[] { 1 });
58-
OrmLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
54+
_ = OrmLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
5955
OrmLog.Error("Test message", new object[] { 1 });
6056
OrmLog.Error("Test message {0}", null);
61-
OrmLog.Error(new Exception("Some exeption"));
57+
_ = OrmLog.Error(new Exception("Some exeption"));
6258
OrmLog.Error(null, new object[] { 1 });
6359

6460
OrmLog.FatalError("Test message", null);
6561
OrmLog.FatalError("Test message with parameter {0}", new object[] { 1 });
66-
OrmLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
62+
_ = OrmLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
6763
OrmLog.FatalError("Test message", new object[] { 1 });
6864
OrmLog.FatalError("Test message {0}", null);
69-
OrmLog.FatalError(new Exception("Some exeption"));
65+
_ = OrmLog.FatalError(new Exception("Some exeption"));
7066
OrmLog.FatalError(null, new object[] { 1 });
7167

7268
Assert.IsTrue(File.Exists(filePath));
@@ -80,42 +76,42 @@ public void BuildLogTest()
8076
File.Delete(filePath);
8177
BuildLog.Debug("Test message", null);
8278
BuildLog.Debug("Test message with parameter {0}", new object[] { 1 });
83-
BuildLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
79+
_ = BuildLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
8480
BuildLog.Debug("Test message", new object[] { 1 });
8581
BuildLog.Debug("Test message {0}", null);
86-
BuildLog.Debug(new Exception("Some exeption"));
82+
_ = BuildLog.Debug(new Exception("Some exeption"));
8783
BuildLog.Debug(null, new object[] { 1 });
8884

8985
BuildLog.Info("Test message", null);
9086
BuildLog.Info("Test message with parameter {0}", new object[] { 1 });
91-
BuildLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
87+
_ = BuildLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
9288
BuildLog.Info("Test message", new object[] { 1 });
9389
BuildLog.Info("Test message {0}", null);
94-
BuildLog.Info(new Exception("Some exeption"));
90+
_ = BuildLog.Info(new Exception("Some exeption"));
9591
BuildLog.Info(null, new object[] { 1 });
9692

9793
BuildLog.Warning("Test message", null);
9894
BuildLog.Warning("Test message with parameter {0}", new object[] { 1 });
99-
BuildLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
95+
_ = BuildLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
10096
BuildLog.Warning("Test message", new object[] { 1 });
10197
BuildLog.Warning("Test message {0}", null);
102-
BuildLog.Warning(new Exception("Some exeption"));
98+
_ = BuildLog.Warning(new Exception("Some exeption"));
10399
BuildLog.Warning(null, new object[] { 1 });
104100

105101
BuildLog.Error("Test message", null);
106102
BuildLog.Error("Test message with parameter {0}", new object[] { 1 });
107-
BuildLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
103+
_ = BuildLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
108104
BuildLog.Error("Test message", new object[] { 1 });
109105
BuildLog.Error("Test message {0}", null);
110-
BuildLog.Error(new Exception("Some exeption"));
106+
_ = BuildLog.Error(new Exception("Some exeption"));
111107
BuildLog.Error(null, new object[] { 1 });
112108

113109
BuildLog.FatalError("Test message", null);
114110
BuildLog.FatalError("Test message with parameter {0}", new object[] { 1 });
115-
BuildLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
111+
_ = BuildLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
116112
BuildLog.FatalError("Test message", new object[] { 1 });
117113
BuildLog.FatalError("Test message {0}", null);
118-
BuildLog.FatalError(new Exception("Some exeption"));
114+
_ = BuildLog.FatalError(new Exception("Some exeption"));
119115
BuildLog.FatalError(null, new object[] { 1 });
120116

121117
Assert.IsTrue(File.Exists(filePath));
@@ -178,42 +174,42 @@ public void SqlLogTest()
178174
File.Delete(filePath);
179175
SqlLog.Debug("Test message", null);
180176
SqlLog.Debug("Test message with parameter {0}", new object[] { 1 });
181-
SqlLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
177+
_ = SqlLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
182178
SqlLog.Debug("Test message", new object[] { 1 });
183179
SqlLog.Debug("Test message {0}", null);
184-
SqlLog.Debug(new Exception("Some exeption"));
180+
_ = SqlLog.Debug(new Exception("Some exeption"));
185181
SqlLog.Debug(null, new object[] { 1 });
186182

187183
SqlLog.Info("Test message", null);
188184
SqlLog.Info("Test message with parameter {0}", new object[] { 1 });
189-
SqlLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
185+
_ = SqlLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
190186
SqlLog.Info("Test message", new object[] { 1 });
191187
SqlLog.Info("Test message {0}", null);
192-
SqlLog.Info(new Exception("Some exeption"));
188+
_ = SqlLog.Info(new Exception("Some exeption"));
193189
SqlLog.Info(null, new object[] { 1 });
194190

195191
SqlLog.Warning("Test message", null);
196192
SqlLog.Warning("Test message with parameter {0}", new object[] { 1 });
197-
SqlLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
193+
_ = SqlLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
198194
SqlLog.Warning("Test message", new object[] { 1 });
199195
SqlLog.Warning("Test message {0}", null);
200-
SqlLog.Warning(new Exception("Some exeption"));
196+
_ = SqlLog.Warning(new Exception("Some exeption"));
201197
SqlLog.Warning(null, new object[] { 1 });
202198

203199
SqlLog.Error("Test message", null);
204200
SqlLog.Error("Test message with parameter {0}", new object[] { 1 });
205-
SqlLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
201+
_ = SqlLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
206202
SqlLog.Error("Test message", new object[] { 1 });
207203
SqlLog.Error("Test message {0}", null);
208-
SqlLog.Error(new Exception("Some exeption"));
204+
_ = SqlLog.Error(new Exception("Some exeption"));
209205
SqlLog.Error(null, new object[] { 1 });
210206

211207
SqlLog.FatalError("Test message", null);
212208
SqlLog.FatalError("Test message with parameter {0}", new object[] { 1 });
213-
SqlLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
209+
_ = SqlLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
214210
SqlLog.FatalError("Test message", new object[] { 1 });
215211
SqlLog.FatalError("Test message {0}", null);
216-
SqlLog.FatalError(new Exception("Some exeption"));
212+
_ = SqlLog.FatalError(new Exception("Some exeption"));
217213
SqlLog.FatalError(null, new object[] { 1 });
218214

219215
Assert.IsTrue(File.Exists(filePath));

0 commit comments

Comments
 (0)