|
| 1 | +#region Copyright Attributions |
| 2 | + |
| 3 | +// Copyright (c) 2026 Michael Camara Pendon. |
| 4 | +// Licensed under the Apache License, Version 2.0. |
| 5 | +// See the LICENSE file in the project root for full license information. |
| 6 | + |
| 7 | +#endregion |
| 8 | + |
| 9 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 10 | +using RepoDb.DbSettings; |
| 11 | +using RepoDb.Interfaces; |
| 12 | +using RepoDb.UnitTests.CustomObjects; |
| 13 | + |
| 14 | +namespace RepoDb.UnitTests |
| 15 | +{ |
| 16 | + [TestClass] |
| 17 | + public class DbSettingIsSchemaSupportedTest |
| 18 | + { |
| 19 | + private sealed class NoSchemaDbSetting : BaseDbSetting |
| 20 | + { |
| 21 | + public NoSchemaDbSetting() |
| 22 | + { |
| 23 | + IsSchemaSupported = false; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + [TestMethod] |
| 28 | + public void TestBaseDbSettingIsSchemaSupportedByDefault() |
| 29 | + { |
| 30 | + // Act |
| 31 | + var setting = new CustomDbSetting(); |
| 32 | + |
| 33 | + // Assert |
| 34 | + Assert.IsTrue(setting.IsSchemaSupported); |
| 35 | + } |
| 36 | + |
| 37 | + [TestMethod] |
| 38 | + public void TestBaseDbSettingIsSchemaSupportedCanBeSetByTheDerivedSetting() |
| 39 | + { |
| 40 | + // Act |
| 41 | + var setting = new NoSchemaDbSetting(); |
| 42 | + |
| 43 | + // Assert |
| 44 | + Assert.IsFalse(setting.IsSchemaSupported); |
| 45 | + } |
| 46 | + |
| 47 | + [TestMethod] |
| 48 | + public void TestDbSettingIsSchemaSupportedIsExposedByTheInterface() |
| 49 | + { |
| 50 | + // Act |
| 51 | + IDbSetting supported = new CustomDbSetting(); |
| 52 | + IDbSetting unsupported = new NoSchemaDbSetting(); |
| 53 | + |
| 54 | + // Assert |
| 55 | + Assert.IsTrue(supported.IsSchemaSupported); |
| 56 | + Assert.IsFalse(unsupported.IsSchemaSupported); |
| 57 | + } |
| 58 | + |
| 59 | + [TestMethod] |
| 60 | + public void TestBaseDbSettingEqualityTakesIsSchemaSupportedIntoAccount() |
| 61 | + { |
| 62 | + // Act |
| 63 | + var unsupported = new NoSchemaDbSetting(); |
| 64 | + var sameAsUnsupported = new NoSchemaDbSetting(); |
| 65 | + var supported = new SchemaDbSetting(); |
| 66 | + |
| 67 | + // Assert |
| 68 | + Assert.IsTrue(unsupported.Equals(sameAsUnsupported)); |
| 69 | + Assert.AreEqual(unsupported.GetHashCode(), sameAsUnsupported.GetHashCode()); |
| 70 | + Assert.IsFalse(unsupported.Equals(supported)); |
| 71 | + Assert.AreNotEqual(unsupported.GetHashCode(), supported.GetHashCode()); |
| 72 | + } |
| 73 | + |
| 74 | + private sealed class SchemaDbSetting : BaseDbSetting |
| 75 | + { |
| 76 | + } |
| 77 | + } |
| 78 | +} |
0 commit comments