diff --git a/lib/net/SharpTestsEx.NUnit.dll b/lib/net/SharpTestsEx.NUnit.dll deleted file mode 100644 index 45fb62b3a7e..00000000000 Binary files a/lib/net/SharpTestsEx.NUnit.dll and /dev/null differ diff --git a/lib/net/SharpTestsEx.NUnit.xml b/lib/net/SharpTestsEx.NUnit.xml deleted file mode 100644 index 919b71ab287..00000000000 --- a/lib/net/SharpTestsEx.NUnit.xml +++ /dev/null @@ -1,772 +0,0 @@ - - - - SharpTestsEx.NUnit - - - - - Assertion for . - - - - - Verifies that the given throws a specific . - - The specific expected . - The given to execute. - The . - The does not throws the expected . - - - - Verifies that the given throws a specific . - - The specific expected . - The given to execute. - A message to display if the assertion fails. This message can be seen in the unit test results. - The . - The does not throws the expected . - - - - Verifies that the given throws an . - - The given to execute. - The . - The does not throws an . - - - - Verifies that the given throws an . - - The given to execute. - A message to display if the assertion fails. This message can be seen in the unit test results. - The . - The does not throws the expected . - - - - Verifies that the given does not throw any . - - The given to execute. - - - - Verifies that the given does not throw any . - - The given to execute. - A message to display if the assertion fails. This message can be seen in the unit test results. - - - - The intention of is to create a more readable - string representation for the failure message. - - - - - Verifies that the specified object is null. The assertion fails if it is not null. - - Type of the actual value subject of the assertion. - - - - Represent a Assertion template where the real logic is delegated. - - Type of the actual value. - Type of the expected value. - - - - Initializes a new instance of the class. - - - - - Verifies that two specified generic type data are equal. The assertion fails if they are not equal. - - Type of the actual value. - Type of the expected value. - - The comparison is done ny the base . - - - - - Initializes a new instance of the class. - - The value to compare. - - - - Verifies that two specified instances are the same object instance.. - - Type of the actual value. - Type of the expected value. - - - - Initializes a new instance of the class. - - The value to compare. - - - - Extensions for constraint over object instances. - - - - - Verifies that actual is the same instance than . - - The extented. - The expected object instance. - Chainable And constraint - - - - Verifies that actual is an instance of . - - The expected. - The extented. - Chainable And constraint - - - - Verifies that actual instance is assignable from . - - The expected. - The extented. - Chainable And constraint - - - - Verifies that actual instance is assignable to . - - The expected. - The extented. - Chainable And constraint - - - - Verifies that actual instance is serializable using . - - The extented. - Chainable And constraint - - - - Verifies that actual instance is serializable using . - - The extented. - Chainable And constraint - - - - Useful class to avoid the creation of new Action. - - - This class can be used when the instance of the class under test is no available; - typically to test a constructor. - When you have an instance of the class under test the most appropite way to test an action - is the extension . - - - - Executing.This(() => new AClass(null)).Should().Throw(); - - - Executing.This(() => new AClass(null)).Should().Throw{ArgumentNullException}() - .And.ValueOf - .ParamName.Should().Be("obj"); - - - - - - Basic contract for a generic constraint. - - The type of the 'actual' value subject of the test. - - - - Verifies that the throws a specific . - - The specific subclass expected. - Chainable And constraint - - - - Verifies that the throws an . - - Chainable And constraint - - - - Verifies that the does not throw any . - - - - - etensions methods. - - - - - Find the first position where two sequence differ - - The type of the elements of the input sequences. - An to compare to second - An to compare to the first sequence. - The position of the first difference; otherwise -1 where the two sequences has the same sequence. - - - - Useful extensions to test s. - - - - - Returns a sequence of all Inner Exceptions. - - The root - A of all Inner Exceptions - - - - Returns a sequence of including the root and all Inner Exceptions. - - The root - A of including the root and all Inner Exceptions. - - - - Constraints for . - - - - - Verifies that the throws a specific . - - The specific subclass expected. - Chainable And constraint - - - - Verifies that the throws an. - - Chainable And constraint - - - - Verifies that the does not throw any . - - - - - The instance thrown. - - - - - var ex = (new Action(() => new AClass(null))).Should().Throw().Exception; - - - - - - - Chainable constraint for - - The specific subclass expected. - - - - The thrown. - - - Allow an readable chained way to begin a new assertion based on one of the properties - of the expected - - - (new Action(() => new AClass(null))) - .Should().Throw{ArgumentNullException}() - .And.ValueOf.ParamName - .Should().Be.EqualTo("obj"); - - - - - - - The instance thrown. - - - Allow an readable chained way to begin a new assertion based on the itself. - - - (new Action(() => new AClass(null))) - .Should().Throw() - .And.Exception.Should().Be.InstanceOf{ArgumentException}(); - - - - - - - Assertion information. - - The type of the value subject of the assertion. - - - - Subject of the assertion. - - - - - The assertion is negated ? - - - - - The title of the assertion ("message" in MsTests terminology) - - - - - Constraint over boolean values. - - - - - Constraints for boolean "Should Be" - - - - - Verifies that actual is true. - - - - - Verifies that actual is false. - - - - - Negate next constraint. - - - - - Constraint over object instances. - - - - - Constraints for object instance of a specific gine . - - The of the instance. - - - - The actual value - - - - - The actual value - - - - - Constraints for object instance "Should Be" - - - - - Verifies that actual is equal to . - - The expected instance - Chainable And constraint - - - - Verifies that the is null. - - Chainable And constraint - - - - Verifies that the actual is an instance of a specific type. - - The expected . - - A for the instance converted to - the specified type to start a chained assertion. - - - - - Constraint over instances. - - The concrete type of actual value. - - - - Constraints for instance ("Should Be") - - - - - - Verifies that actual is equal to . - - The expected instance - Chainable And constraint - - - - Verifies that actual is greater than . - - The expected instance - Chainable And constraint - - - - Verifies that actual is less than . - - The expected instance - Chainable And constraint - - - - Verifies that actual is greater than or equal to . - - The expected instance - Chainable And constraint - - - - Verifies that actual is less than or equal to . - - The expected instance - Chainable And constraint - - - - Verifies that actual is included in the range -. - - The less aceptable value. - The higher aceptable value. - Chainable And constraint - - - - Verifies that the instance is null. - - Chainable And constraint - - - - Verifies that the is empty. - - Chainable And constraint - - - - Verifies that the is null. - - Chainable And constraint - - - - Verifies that the is empty. - - Chainable And constraint - - - - Verifies that the instance is null. - - Chainable And constraint - - - - Collection information to build the failure message - - Type of the actual value. - Type of the expected value. - - - - The actual value under test. - - - - - The expected value of the test. - - - - - The name of the assertion - - - "be EqualTo" - - - - - The user custom message. - - - - - Extensions for any System.Object. - - - - - Allow access to a private field of a class instance. - - The of the field. - The class instance. - The field name. - The value of the field. - - - - A strongly-typed resource class, for looking up localized strings, etc. - - - - - Returns the cached ResourceManager instance used by this class. - - - - - Overrides the current thread's CurrentUICulture property for all - resource lookups using this strongly typed resource class. - - - - - Looks up a localized string similar to Should. - - - - - Looks up a localized string similar to Be. - - - - - Looks up a localized string similar to <Empty>. - - - - - Looks up a localized string similar to Can't access to a field of a null value.. - - - - - Looks up a localized string similar to The class {0} does not contain a field named {1}.. - - - - - Looks up a localized string similar to The class {0} does contain a field named {1} but its type is {2} and not {3}.. - - - - - Looks up a localized string similar to Can't check serialization for (null) value.. - - - - - Looks up a localized string similar to Expected: {0}. - - - - - Looks up a localized string similar to Differences :. - - - - - Looks up a localized string similar to Values differ at position {0}.. - - - - - Looks up a localized string similar to Not expected exception message:. - - - - - Looks up a localized string similar to Strings differ at position {0}.. - - - - - Looks up a localized string similar to Found : {0}. - - - - - Looks up a localized string similar to Not. - - - - - Looks up a localized string similar to (null). - - - - - Looks up a localized string similar to Be Assignable From. - - - - - Looks up a localized string similar to Be Assignable To. - - - - - Looks up a localized string similar to Be Binary Serializable. - - - - - Looks up a localized string similar to Be Empty. - - - - - Looks up a localized string similar to Be Equal To. - - - - - Looks up a localized string similar to Be Greater Than. - - - - - Looks up a localized string similar to Be Greater than Or Equal to. - - - - - Looks up a localized string similar to Be in Range. - - - - - Looks up a localized string similar to Be Instance Of. - - - - - Looks up a localized string similar to Be Less Than. - - - - - Looks up a localized string similar to Be Less than Or Equal to. - - - - - Looks up a localized string similar to Be Null. - - - - - Looks up a localized string similar to Be Ordered. - - - - - Looks up a localized string similar to Be Ordered ascending. - - - - - Looks up a localized string similar to Be Ordered By ({0}). - - - - - Looks up a localized string similar to Be Same instance As. - - - - - Looks up a localized string similar to Be SubClass Of. - - - - - Looks up a localized string similar to Be Subset Of. - - - - - Looks up a localized string similar to Be Xml Serializable. - - - - - Looks up a localized string similar to Contain. - - - - - Looks up a localized string similar to Not throw. - - - - - Looks up a localized string similar to Have Attribute. - - - - - Looks up a localized string similar to Have Same Sequence As. - - - - - Looks up a localized string similar to Have Same Values As. - - - - - Looks up a localized string similar to Have Unique Values. - - - - - Looks up a localized string similar to Have Value. - - - - - Looks up a localized string similar to Throw. - - - - - Looks up a localized string similar to Throws an exception. - - - - diff --git a/lib/net/SharpTestsEx_License.txt b/lib/net/SharpTestsEx_License.txt deleted file mode 100644 index da3dc935e5c..00000000000 --- a/lib/net/SharpTestsEx_License.txt +++ /dev/null @@ -1,31 +0,0 @@ -Microsoft Public License (Ms-PL) - -This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. - -1. Definitions - -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. - -A "contribution" is the original software, or any additions or changes to the software. - -A "contributor" is any person that distributes its contribution under this license. - -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights - -(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. - -(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. - -3. Conditions and Limitations - -(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. - -(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. - -(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. - -(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. - -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. \ No newline at end of file diff --git a/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.build b/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.build index 78668b557c5..393e45848cb 100644 --- a/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.build +++ b/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.build @@ -25,7 +25,6 @@ - diff --git a/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs b/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs index 4d35bbbdb56..35d7295c299 100644 --- a/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs +++ b/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs @@ -15,7 +15,7 @@ public void NotConfiguredProxyFactoryFactory() { var bcp = new BytecodeProviderImpl(); IProxyFactoryFactory p = bcp.ProxyFactoryFactory; - p.Should().Be.InstanceOf(); + Assert.That(p, Is.InstanceOf()); } [Test] diff --git a/src/NHibernate.Test/CfgTest/AccessorsSerializableTest.cs b/src/NHibernate.Test/CfgTest/AccessorsSerializableTest.cs index 5202bccc2b5..e09db5cfbbe 100644 --- a/src/NHibernate.Test/CfgTest/AccessorsSerializableTest.cs +++ b/src/NHibernate.Test/CfgTest/AccessorsSerializableTest.cs @@ -13,7 +13,7 @@ public class AccessorsSerializableTest [Test, TestCaseSource("accessors")] public void AllAccessorsAreMarkedAsSerializable(System.Type concreteAccessor) { - concreteAccessor.Should().Have.Attribute(); + Assert.That(concreteAccessor, Has.Attribute()); } private static System.Type[] setters = typeof(ISetter).Assembly.GetTypes().Where(t => t.Namespace == typeof(ISetter).Namespace && t.GetInterfaces().Contains(typeof(ISetter))).ToArray(); @@ -21,7 +21,7 @@ public void AllAccessorsAreMarkedAsSerializable(System.Type concreteAccessor) [Test, TestCaseSource("setters")] public void AllSettersAreMarkedAsSerializable(System.Type concreteAccessor) { - concreteAccessor.Should().Have.Attribute(); + Assert.That(concreteAccessor, Has.Attribute()); } private static System.Type[] getters = typeof(IGetter).Assembly.GetTypes().Where(t => t.Namespace == typeof(IGetter).Namespace && t.GetInterfaces().Contains(typeof(IGetter))).ToArray(); @@ -29,7 +29,7 @@ public void AllSettersAreMarkedAsSerializable(System.Type concreteAccessor) [Test, TestCaseSource("getters")] public void AllGettersAreMarkedAsSerializable(System.Type concreteAccessor) { - concreteAccessor.Should().Have.Attribute(); + Assert.That(concreteAccessor, Has.Attribute()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/CfgTest/ConfigurationAddMappingEvents.cs b/src/NHibernate.Test/CfgTest/ConfigurationAddMappingEvents.cs index 0ce9b2da27c..6eb619e5c95 100644 --- a/src/NHibernate.Test/CfgTest/ConfigurationAddMappingEvents.cs +++ b/src/NHibernate.Test/CfgTest/ConfigurationAddMappingEvents.cs @@ -45,15 +45,15 @@ public void WhenSubscribedToBeforeBindThenRaiseEventForEachMapping() var listOfCalls = new List(); var configuration = new Configuration(); configuration.DataBaseIntegration(x => x.Dialect()); - configuration.BeforeBindMapping += (sender, args) => { sender.Should().Be.SameInstanceAs(configuration); listOfCalls.Add(args); }; + configuration.BeforeBindMapping += (sender, args) => { Assert.That(sender, Is.SameAs(configuration)); listOfCalls.Add(args); }; configuration.AddXmlString(ProductLineMapping); configuration.AddXmlString(ModelMapping); - listOfCalls.Count.Should().Be(2); - listOfCalls.Select(x => x.FileName).All(x => x.Satisfy(filename => filename != null)); - listOfCalls.Select(x => x.Mapping).All(x => x.Satisfy(mappingDoc => mappingDoc != null)); - listOfCalls.Select(x => x.Dialect).All(x => x.Satisfy(dialect => dialect.GetType() == typeof(MsSql2008Dialect))); + Assert.That(listOfCalls.Count, Is.EqualTo(2)); + Assert.That(listOfCalls.Select(x => x.FileName).All(x => x != null), Is.True); + Assert.That(listOfCalls.Select(x => x.Mapping).All(x => x != null), Is.True); + Assert.That(listOfCalls.Select(x => x.Dialect).All(x => x.GetType() == typeof (MsSql2008Dialect)), Is.True); } [Test] @@ -62,15 +62,15 @@ public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping() var listOfCalls = new List(); var configuration = new Configuration(); configuration.DataBaseIntegration(x => x.Dialect()); - configuration.AfterBindMapping += (sender, args) => { sender.Should().Be.SameInstanceAs(configuration); listOfCalls.Add(args); }; + configuration.AfterBindMapping += (sender, args) => { Assert.That(sender, Is.SameAs(configuration)); listOfCalls.Add(args); }; configuration.AddXmlString(ProductLineMapping); configuration.AddXmlString(ModelMapping); - listOfCalls.Count.Should().Be(2); - listOfCalls.Select(x => x.FileName).All(x => x.Satisfy(filename => filename != null)); - listOfCalls.Select(x => x.Mapping).All(x => x.Satisfy(mappingDoc => mappingDoc != null)); - listOfCalls.Select(x => x.Dialect).All(x => x.Satisfy(dialect => dialect.GetType() == typeof(MsSql2008Dialect))); + Assert.That(listOfCalls.Count, Is.EqualTo(2)); + Assert.That(listOfCalls.Select(x => x.FileName).All(x => x != null), Is.True); + Assert.That(listOfCalls.Select(x => x.Mapping).All(x => x != null), Is.True); + Assert.That(listOfCalls.Select(x => x.Dialect).All(x => x.GetType() == typeof(MsSql2008Dialect)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs b/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs index d318fb4bda1..fbaabb6c1fe 100644 --- a/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs +++ b/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs @@ -29,7 +29,7 @@ public void InvalidConfig() public void FromAppConfigTest() { IHibernateConfiguration hc = ConfigurationManager.GetSection("hibernate-configuration") as IHibernateConfiguration; - hc.ByteCodeProviderType.Should().Be("lcg"); + Assert.That(hc.ByteCodeProviderType, Is.EqualTo("lcg")); Assert.IsTrue(hc.UseReflectionOptimizer); Assert.AreEqual("NHibernate.Test", hc.SessionFactory.Name); } diff --git a/src/NHibernate.Test/CfgTest/CustomBytecodeProviderTest.cs b/src/NHibernate.Test/CfgTest/CustomBytecodeProviderTest.cs index 44315a518c8..a3c6be54418 100644 --- a/src/NHibernate.Test/CfgTest/CustomBytecodeProviderTest.cs +++ b/src/NHibernate.Test/CfgTest/CustomBytecodeProviderTest.cs @@ -34,29 +34,29 @@ public override IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, I public void WhenNoShortCutUsedThenCanBuildBytecodeProvider() { var properties = new Dictionary { { Environment.PropertyBytecodeProvider, typeof(MyByteCodeProvider).AssemblyQualifiedName } }; - Executing.This(() => Environment.BuildBytecodeProvider(properties)).Should().NotThrow(); + Assert.That(() => Environment.BuildBytecodeProvider(properties), Throws.Nothing); } [Test] public void WhenNoShortCutUsedThenCanBuildInstanceOfConfiguredBytecodeProvider() { var properties = new Dictionary { { Environment.PropertyBytecodeProvider, typeof(MyByteCodeProvider).AssemblyQualifiedName } }; - Environment.BuildBytecodeProvider(properties).Should().Be.InstanceOf(); + Assert.That(Environment.BuildBytecodeProvider(properties), Is.InstanceOf()); } [Test] public void WhenInvalidThenThrow() { var properties = new Dictionary { { Environment.PropertyBytecodeProvider, typeof(InvalidByteCodeProvider).AssemblyQualifiedName } }; - Executing.This(() => Environment.BuildBytecodeProvider(properties)).Should().Throw(); + Assert.That(() => Environment.BuildBytecodeProvider(properties), Throws.TypeOf()); } [Test] public void WhenNoDefaultCtorThenThrow() { var properties = new Dictionary { { Environment.PropertyBytecodeProvider, typeof(InvalidNoCtorByteCodeProvider).AssemblyQualifiedName } }; - Executing.This(() => Environment.BuildBytecodeProvider(properties)).Should().Throw() - .And.Exception.InnerException.Message.Should().Contain("constructor was not found"); + Assert.That(() => Environment.BuildBytecodeProvider(properties), Throws.TypeOf() + .And.InnerException.Message.ContainsSubstring("constructor was not found")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs index d6147be3933..40a72b1c4b8 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs @@ -39,29 +39,29 @@ public void FullConfiguration() p.ProxyFactoryFactory(); }); configure.Mappings(m=> - { - m.DefaultCatalog = "MyCatalog"; - m.DefaultSchema = "MySche"; - }); + { + m.DefaultCatalog = "MyCatalog"; + m.DefaultSchema = "MySche"; + }); configure.DataBaseIntegration(db => - { - db.Dialect(); - db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; - db.Batcher(); - db.BatchSize = 15; - db.ConnectionProvider(); - db.Driver(); - db.ConnectionReleaseMode = ConnectionReleaseMode.AfterTransaction; - db.IsolationLevel = IsolationLevel.ReadCommitted; - db.ConnectionString = "The connection string"; - db.AutoCommentSql = true; - db.ExceptionConverter(); - db.PrepareCommands = true; - db.Timeout = 10; - db.MaximumDepthOfOuterJoinFetching = 11; - db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'"; - db.SchemaAction = SchemaAutoAction.Validate; - }); + { + db.Dialect(); + db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; + db.Batcher(); + db.BatchSize = 15; + db.ConnectionProvider(); + db.Driver(); + db.ConnectionReleaseMode = ConnectionReleaseMode.AfterTransaction; + db.IsolationLevel = IsolationLevel.ReadCommitted; + db.ConnectionString = "The connection string"; + db.AutoCommentSql = true; + db.ExceptionConverter(); + db.PrepareCommands = true; + db.Timeout = 10; + db.MaximumDepthOfOuterJoinFetching = 11; + db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'"; + db.SchemaAction = SchemaAutoAction.Validate; + }); Assert.That(configure.Properties[Environment.SessionFactoryName], Is.EqualTo("SomeName")); Assert.That(configure.Properties[Environment.CacheProvider], @@ -102,7 +102,7 @@ public void FullConfiguration() Assert.That(configure.Properties[Environment.MaxFetchDepth], Is.EqualTo("11")); Assert.That(configure.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'")); Assert.That(configure.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate")); - configure.Properties[Environment.LinqToHqlGeneratorsRegistry].Should().Be(typeof(DefaultLinqToHqlGeneratorsRegistry).AssemblyQualifiedName); + Assert.That(configure.Properties[Environment.LinqToHqlGeneratorsRegistry], Is.EqualTo(typeof(DefaultLinqToHqlGeneratorsRegistry).AssemblyQualifiedName)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/CfgTest/Loquacious/NamedQueryTests.cs b/src/NHibernate.Test/CfgTest/Loquacious/NamedQueryTests.cs index 0e7ff97a812..d526081de47 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/NamedQueryTests.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/NamedQueryTests.cs @@ -16,9 +16,9 @@ public void AddSimpleNamedQuery() b.Query = "from System.Object o"; }); - configure.NamedQueries.Should().Have.Count.EqualTo(1); - configure.NamedQueries.Keys.Single().Should().Be("aQuery"); - configure.NamedQueries.Values.Single().Query.Should().Be("from System.Object o"); + Assert.That(configure.NamedQueries, Has.Count.EqualTo(1)); + Assert.That(configure.NamedQueries.Keys.Single(), Is.EqualTo("aQuery")); + Assert.That(configure.NamedQueries.Values.Single().Query, Is.EqualTo("from System.Object o")); } [Test] @@ -31,7 +31,7 @@ public void WhenSetInvalidFetchSizeThenLeaveDefault() b.FetchSize = 0; }); - configure.NamedQueries.Values.Single().FetchSize.Should().Be(-1); + Assert.That(configure.NamedQueries.Values.Single().FetchSize, Is.EqualTo(-1)); } [Test] @@ -44,7 +44,7 @@ public void WhenSetValidFetchSizeThenSetValue() b.FetchSize = 15; }); - configure.NamedQueries.Values.Single().FetchSize.Should().Be(15); + Assert.That(configure.NamedQueries.Values.Single().FetchSize, Is.EqualTo(15)); } [Test] @@ -57,7 +57,7 @@ public void WhenSetInvalidTimeoutThenLeaveDefault() b.Timeout = 0; }); - configure.NamedQueries.Values.Single().Timeout.Should().Be(-1); + Assert.That(configure.NamedQueries.Values.Single().Timeout, Is.EqualTo(-1)); } [Test] @@ -70,7 +70,7 @@ public void WhenSetValidTimeoutThenSetValue() b.Timeout = 123; }); - configure.NamedQueries.Values.Single().Timeout.Should().Be(123); + Assert.That(configure.NamedQueries.Values.Single().Timeout, Is.EqualTo(123)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs b/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs index 5897f0aa645..cc0b2ab4ce3 100644 --- a/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs +++ b/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs @@ -335,7 +335,7 @@ public void TestSignatureNonGeneric() { MethodInfo thisMethod = GetType().GetMethod("NonGenericMethod"); - ExpressionProcessor.Signature(thisMethod).Should().Be("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:Void NonGenericMethod(System.String)"); + Assert.That(ExpressionProcessor.Signature(thisMethod), Is.EqualTo("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:Void NonGenericMethod(System.String)")); } [Test] @@ -343,7 +343,7 @@ public void TestSignatureGeneric() { MethodInfo thisMethod = GetType().GetMethod("GenericMethod"); - ExpressionProcessor.Signature(thisMethod).Should().Be("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:T GenericMethod[T](T)"); + Assert.That(ExpressionProcessor.Signature(thisMethod), Is.EqualTo("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:T GenericMethod[T](T)")); } [Test] @@ -352,7 +352,7 @@ public void TestSignatureQualifiedGeneric() Expression> expression = () => this.GenericMethod("test"); MethodInfo genericMethodWithQualifiedType = (expression.Body as MethodCallExpression).Method; - ExpressionProcessor.Signature(genericMethodWithQualifiedType).Should().Be("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:T GenericMethod[T](T)"); + Assert.That(ExpressionProcessor.Signature(genericMethodWithQualifiedType), Is.EqualTo("NHibernate.Test.Criteria.Lambda.ExpressionProcessorFixture:T GenericMethod[T](T)")); } } diff --git a/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs b/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs index f888671293c..14ddeff05ac 100644 --- a/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs +++ b/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs @@ -52,8 +52,8 @@ public void YearPartEqual() .Where(p => p.BirthDate.YearPart() == 2008) .List(); - persons.Count.Should().Be(1); - persons[0].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(1)); + Assert.That(persons[0].Name, Is.EqualTo("p2")); } } @@ -68,9 +68,9 @@ public void YearPartIsIn() .OrderBy(p => p.Name).Asc .List(); - persons.Count.Should().Be(2); - persons[0].Name.Should().Be("p1"); - persons[1].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(2)); + Assert.That(persons[0].Name, Is.EqualTo("p1")); + Assert.That(persons[1].Name, Is.EqualTo("p2")); } } @@ -85,8 +85,8 @@ public void YearPartSingleOrDefault() .Select(p => p.BirthDate.YearPart()) .SingleOrDefault(); - yearOfBirth.GetType().Should().Be(typeof (int)); - yearOfBirth.Should().Be(2008); + Assert.That(yearOfBirth.GetType(), Is.EqualTo(typeof (int))); + Assert.That(yearOfBirth, Is.EqualTo(2008)); } } @@ -100,8 +100,8 @@ public void SelectAvgYearPart() .SelectList(list => list.SelectAvg(p => p.BirthDate.YearPart())) .SingleOrDefault(); - avgYear.GetType().Should().Be(typeof (double)); - string.Format("{0:0}", avgYear).Should().Be("2008"); + Assert.That(avgYear.GetType(), Is.EqualTo(typeof (double))); + Assert.That(string.Format("{0:0}", avgYear), Is.EqualTo("2008")); } } @@ -116,8 +116,8 @@ public void SqrtSingleOrDefault() .Select(p => Math.Round(p.Age.Sqrt(), 2)) .SingleOrDefault(); - sqrtOfAge.Should().Be.InstanceOf(); - string.Format("{0:0.00}", sqrtOfAge).Should().Be((9.49).ToString()); + Assert.That(sqrtOfAge, Is.InstanceOf()); + Assert.That(string.Format("{0:0.00}", sqrtOfAge), Is.EqualTo((9.49).ToString())); } } @@ -129,11 +129,11 @@ public void RoundDoubleWithOneArgument() using (s.BeginTransaction()) { var roundedValue = s.QueryOver() - .Where(p => p.Name == "p1") - .Select(p => Math.Round(p.Age.Sqrt())) - .SingleOrDefault(); + .Where(p => p.Name == "p1") + .Select(p => Math.Round(p.Age.Sqrt())) + .SingleOrDefault(); - roundedValue.Should().Be.InstanceOf(); + Assert.That(roundedValue, Is.InstanceOf()); Assert.That(roundedValue, Is.EqualTo(9)); } } @@ -145,11 +145,11 @@ public void RoundDecimalWithOneArgument() using (s.BeginTransaction()) { var roundedValue = s.QueryOver() - .Where(p => p.Name == "p1") - .Select(p => Math.Round((decimal) p.Age.Sqrt())) - .SingleOrDefault(); + .Where(p => p.Name == "p1") + .Select(p => Math.Round((decimal) p.Age.Sqrt())) + .SingleOrDefault(); - roundedValue.Should().Be.InstanceOf(); + Assert.That(roundedValue, Is.InstanceOf()); Assert.That(roundedValue, Is.EqualTo(9)); } } @@ -165,7 +165,7 @@ public void RoundDoubleWithTwoArguments() .Select(p => Math.Round(p.Age.Sqrt() , 3)) .SingleOrDefault(); - roundedValue.Should().Be.InstanceOf(); + Assert.That(roundedValue, Is.InstanceOf()); Assert.That(roundedValue, Is.EqualTo(9.487).Within(0.000001)); } } @@ -177,11 +177,11 @@ public void RoundDecimalWithTwoArguments() using (s.BeginTransaction()) { var roundedValue = s.QueryOver() - .Where(p => p.Name == "p1") - .Select(p => Math.Round((decimal) p.Age.Sqrt(), 3)) - .SingleOrDefault(); + .Where(p => p.Name == "p1") + .Select(p => Math.Round((decimal) p.Age.Sqrt(), 3)) + .SingleOrDefault(); - roundedValue.Should().Be.InstanceOf(); + Assert.That(roundedValue, Is.InstanceOf()); Assert.That(roundedValue, Is.EqualTo(9.487).Within(0.000001)); } } @@ -197,8 +197,8 @@ public void FunctionsToLowerToUpper() .Select(p => p.Name.Lower(), p => p.Name.Upper()) .SingleOrDefault(); - names[0].Should().Be("pp3"); - names[1].Should().Be("PP3"); + Assert.That(names[0], Is.EqualTo("pp3")); + Assert.That(names[1], Is.EqualTo("PP3")); } } @@ -213,7 +213,7 @@ public void Concat() .Select(p => Projections.Concat(p.Name, ", ", p.Name)) .SingleOrDefault(); - name.Should().Be("p1, p1"); + Assert.That(name, Is.EqualTo("p1, p1")); } } @@ -227,8 +227,8 @@ public void MonthPartEqualsDayPart() .Where(p => p.BirthDate.MonthPart() == p.BirthDate.DayPart()) .List(); - persons.Count.Should().Be(1); - persons[0].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(1)); + Assert.That(persons[0].Name, Is.EqualTo("p2")); } } @@ -242,10 +242,10 @@ public void OrderByYearPart() .OrderBy(p => p.BirthDate.YearPart()).Desc .List(); - persons.Count.Should().Be(3); - persons[0].Name.Should().Be("p1"); - persons[1].Name.Should().Be("p2"); - persons[2].Name.Should().Be("pP3"); + Assert.That(persons.Count, Is.EqualTo(3)); + Assert.That(persons[0].Name, Is.EqualTo("p1")); + Assert.That(persons[1].Name, Is.EqualTo("p2")); + Assert.That(persons[2].Name, Is.EqualTo("pP3")); } } @@ -259,8 +259,8 @@ public void YearEqual() .Where(p => p.BirthDate.Year == 2008) .List(); - persons.Count.Should().Be(1); - persons[0].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(1)); + Assert.That(persons[0].Name, Is.EqualTo("p2")); } } @@ -275,9 +275,9 @@ public void YearIsIn() .OrderBy(p => p.Name).Asc .List(); - persons.Count.Should().Be(2); - persons[0].Name.Should().Be("p1"); - persons[1].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(2)); + Assert.That(persons[0].Name, Is.EqualTo("p1")); + Assert.That(persons[1].Name, Is.EqualTo("p2")); } } @@ -292,8 +292,8 @@ public void YearSingleOrDefault() .Select(p => p.BirthDate.Year) .SingleOrDefault(); - yearOfBirth.GetType().Should().Be(typeof(int)); - yearOfBirth.Should().Be(2008); + Assert.That(yearOfBirth.GetType(), Is.EqualTo(typeof(int))); + Assert.That(yearOfBirth, Is.EqualTo(2008)); } } @@ -307,8 +307,8 @@ public void SelectAvgYear() .SelectList(list => list.SelectAvg(p => p.BirthDate.Year)) .SingleOrDefault(); - avgYear.GetType().Should().Be(typeof(double)); - string.Format("{0:0}", avgYear).Should().Be("2008"); + Assert.That(avgYear.GetType(), Is.EqualTo(typeof(double))); + Assert.That(string.Format("{0:0}", avgYear), Is.EqualTo("2008")); } } @@ -322,10 +322,10 @@ public void OrderByYear() .OrderBy(p => p.BirthDate.Year).Desc .List(); - persons.Count.Should().Be(3); - persons[0].Name.Should().Be("p1"); - persons[1].Name.Should().Be("p2"); - persons[2].Name.Should().Be("pP3"); + Assert.That(persons.Count, Is.EqualTo(3)); + Assert.That(persons[0].Name, Is.EqualTo("p1")); + Assert.That(persons[1].Name, Is.EqualTo("p2")); + Assert.That(persons[2].Name, Is.EqualTo("pP3")); } } @@ -339,8 +339,8 @@ public void MonthEqualsDay() .Where(p => p.BirthDate.Month == p.BirthDate.Day) .List(); - persons.Count.Should().Be(1); - persons[0].Name.Should().Be("p2"); + Assert.That(persons.Count, Is.EqualTo(1)); + Assert.That(persons[0].Name, Is.EqualTo("p2")); } } } diff --git a/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs b/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs index af24a9d3072..d4586697cfb 100644 --- a/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs +++ b/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs @@ -106,22 +106,19 @@ public void OnClause() .WhereRestrictionOn(p => p.Name).IsNotNull .List(); - children.Should().Have.Count.EqualTo(1); + Assert.That(children, Has.Count.EqualTo(1)); } using (ISession s = OpenSession()) { Child childAlias = null; Person parentAlias = null; - var parentNames = - s.QueryOver(() => childAlias) - .Left.JoinAlias(c => c.Parent, () => parentAlias, p => p.Name == childAlias.Nickname) - .Select(c => parentAlias.Name) - .List(); + var parentNames = s.QueryOver(() => childAlias) + .Left.JoinAlias(c => c.Parent, () => parentAlias, p => p.Name == childAlias.Nickname) + .Select(c => parentAlias.Name) + .List(); - parentNames - .Where(n => !string.IsNullOrEmpty(n)) - .Should().Have.Count.EqualTo(1); + Assert.That(parentNames.Count(n => !string.IsNullOrEmpty(n)), Is.EqualTo(1)); } using (ISession s = OpenSession()) @@ -134,7 +131,7 @@ public void OnClause() .WhereRestrictionOn(c => c.Nickname).IsNotNull .List(); - people.Should().Have.Count.EqualTo(1); + Assert.That(people, Has.Count.EqualTo(1)); } using (ISession s = OpenSession()) @@ -147,9 +144,7 @@ public void OnClause() .Select(p => childAlias.Nickname) .List(); - childNames - .Where(n => !string.IsNullOrEmpty(n)) - .Should().Have.Count.EqualTo(1); + Assert.That(childNames.Count(n => !string.IsNullOrEmpty(n)), Is.EqualTo(1)); } } @@ -331,15 +326,15 @@ public void FunctionsOrder() using (ISession s = OpenSession()) using (s.BeginTransaction()) { - var persons = - s.QueryOver() - .OrderBy(p => p.BirthDate.Year).Desc - .List(); - - persons.Count.Should().Be(3); - persons[0].Name.Should().Be("p1"); - persons[1].Name.Should().Be("p2"); - persons[2].Name.Should().Be("p3"); + var persons = + s.QueryOver() + .OrderBy(p => p.BirthDate.Year).Desc + .List(); + + Assert.That(persons.Count, Is.EqualTo(3)); + Assert.That(persons[0].Name, Is.EqualTo("p1")); + Assert.That(persons[1].Name, Is.EqualTo("p2")); + Assert.That(persons[2].Name, Is.EqualTo("p3")); } } diff --git a/src/NHibernate.Test/DialectTest/DialectFixture.cs b/src/NHibernate.Test/DialectTest/DialectFixture.cs index d0c25cff3b3..cccc59f3f77 100644 --- a/src/NHibernate.Test/DialectTest/DialectFixture.cs +++ b/src/NHibernate.Test/DialectTest/DialectFixture.cs @@ -65,8 +65,8 @@ public void IsQuotedFalse() [Test] public void WhenNullOrEmptyIsQuotedFalse() { - d.IsQuoted(null).Should().Be.False(); - d.IsQuoted("").Should().Be.False(); + Assert.That(d.IsQuoted(null), Is.False); + Assert.That(d.IsQuoted(""), Is.False); } [Test] diff --git a/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs b/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs index 79c85cf7ada..fcc8d26126f 100644 --- a/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs +++ b/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs @@ -11,7 +11,7 @@ public class DbProviderFactoryDriveConnectionCommandProviderTest [Test] public void WhenCreatedWithNullDbFactoryThenThrows() { - Executing.This(() => new DbProviderFactoryDriveConnectionCommandProvider(null)).Should().Throw(); + Assert.That(() => new DbProviderFactoryDriveConnectionCommandProvider(null), Throws.TypeOf()); } [Test] @@ -21,7 +21,7 @@ public void WhenCreatedWithDbFactoryThenCanReturnConnection() var provider = new DbProviderFactoryDriveConnectionCommandProvider(factory); using(var connection =provider.CreateConnection()) { - connection.Should().Not.Be.Null(); + Assert.That(connection, Is.Not.Null); } } @@ -32,7 +32,7 @@ public void WhenCreatedWithDbFactoryThenCanReturnCommand() var provider = new DbProviderFactoryDriveConnectionCommandProvider(factory); using (var command = provider.CreateCommand()) { - command.Should().Not.Be.Null(); + Assert.That(command, Is.Not.Null); } } } diff --git a/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs b/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs index 6a476996d12..d5e6fde13d5 100644 --- a/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs +++ b/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs @@ -70,7 +70,7 @@ public void AdjustCommand_StringParametersWithinConditionalSelect_ThenParameterI _driver.AdjustCommand(cmd); var expectedCommandTxt = "select (case when col = @p0 then cast(@p1 as VARCHAR(255)) else cast(@p2 as VARCHAR(255)) end) from table"; - cmd.CommandText.Should().Be(expectedCommandTxt); + Assert.That(cmd.CommandText, Is.EqualTo(expectedCommandTxt)); } [Test] @@ -82,7 +82,7 @@ public void AdjustCommand_IntParametersWithinConditionalSelect_ThenParameterIsWr _driver.AdjustCommand(cmd); var expectedCommandTxt = "select (case when col = @p0 then cast(@p1 as INTEGER) else cast(@p2 as INTEGER) end) from table"; - cmd.CommandText.Should().Be(expectedCommandTxt); + Assert.That(cmd.CommandText, Is.EqualTo(expectedCommandTxt)); } [Test] @@ -94,7 +94,7 @@ public void AdjustCommand_ParameterWithinSelectConcat_ParameterIsCasted() _driver.AdjustCommand(cmd); var expected = "select col || cast(@p0 as VARCHAR(255)) || col from table"; - cmd.CommandText.Should().Be(expected); + Assert.That(cmd.CommandText, Is.EqualTo(expected)); } [Test] @@ -106,7 +106,7 @@ public void AdjustCommand_ParameterWithinSelectAddFunction_ParameterIsCasted() _driver.AdjustCommand(cmd); var expected = "select col + cast(@p0 as VARCHAR(255)) from table"; - cmd.CommandText.Should().Be(expected); + Assert.That(cmd.CommandText, Is.EqualTo(expected)); } [Test] @@ -118,7 +118,7 @@ public void AdjustCommand_InsertWithParamsInSelect_ParameterIsCasted() _driver.AdjustCommand(cmd); var expected = "insert into table1 (col1, col2) select col1, cast(@p0 as INTEGER) from table2"; - cmd.CommandText.Should().Be(expected); + Assert.That(cmd.CommandText, Is.EqualTo(expected)); } private void MakeDriver() @@ -142,7 +142,7 @@ private IDbConnection MakeConnection() private void VerifyCountOfEstablishedConnectionsIs(int expectedCount) { var physicalConnections = GetEstablishedConnections(); - physicalConnections.Should().Be(expectedCount); + Assert.That(physicalConnections, Is.EqualTo(expectedCount)); } private int GetEstablishedConnections() diff --git a/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs b/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs index a0de6ce6ca0..a6179357457 100644 --- a/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs +++ b/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs @@ -60,13 +60,13 @@ public override string NamedPrefix [Test] public void WhenCreatedWithGoodDbProviderThenNotThrows() { - Executing.This(()=> new MyDriverWithWrongClassesAndGoodDbProviderFactory()).Should().NotThrow(); + Assert.That(() => new MyDriverWithWrongClassesAndGoodDbProviderFactory(), Throws.Nothing); } [Test] public void WhenCreatedWithNullAssemblyAndGoodDbProviderThenNotThrows() { - Executing.This(() => new MyDriverWithWrongClassesAndGoodDbProviderFactory(null)).Should().NotThrow(); + Assert.That(() => new MyDriverWithWrongClassesAndGoodDbProviderFactory(null), Throws.Nothing); } [Test] @@ -75,7 +75,7 @@ public void WhenCreatedWithDbFactoryThenCanReturnConnection() var provider = new MyDriverWithWrongClassesAndGoodDbProviderFactory(); using (var connection = provider.CreateConnection()) { - connection.Should().Not.Be.Null(); + Assert.That(connection, Is.Not.Null); } } @@ -85,14 +85,14 @@ public void WhenCreatedWithDbFactoryThenCanReturnCommand() var provider = new MyDriverWithWrongClassesAndGoodDbProviderFactory(); using (var command = provider.CreateCommand()) { - command.Should().Not.Be.Null(); + Assert.That(command, Is.Not.Null); } } [Test] public void WhenCreatedWithNoDbProviderThenNotThrows() { - Executing.This(() => new MyDriverWithNoDbProviderFactory()).Should().NotThrow(); + Assert.That(() => new MyDriverWithNoDbProviderFactory(), Throws.Nothing); } [Test] @@ -101,7 +101,7 @@ public void WhenCreatedWithNoDbFactoryThenCanReturnConnection() var provider = new MyDriverWithNoDbProviderFactory(); using (var connection = provider.CreateConnection()) { - connection.Should().Not.Be.Null(); + Assert.That(connection, Is.Not.Null); } } @@ -111,7 +111,7 @@ public void WhenCreatedNoWithDbFactoryThenCanReturnCommand() var provider = new MyDriverWithNoDbProviderFactory(); using (var command = provider.CreateCommand()) { - command.Should().Not.Be.Null(); + Assert.That(command, Is.Not.Null); } } } diff --git a/src/NHibernate.Test/DriverTest/Sql2008DateTime2Test.cs b/src/NHibernate.Test/DriverTest/Sql2008DateTime2Test.cs index ebfd17cd3c9..2d25f9ae8c2 100644 --- a/src/NHibernate.Test/DriverTest/Sql2008DateTime2Test.cs +++ b/src/NHibernate.Test/DriverTest/Sql2008DateTime2Test.cs @@ -46,8 +46,8 @@ public void Crud() using (ITransaction t = s.BeginTransaction()) { savedId = s.Save(new EntityForMs2008 - { - DateTimeProp = expectedMoment, + { + DateTimeProp = expectedMoment, TimeSpanProp = expectedLapse, }); t.Commit(); @@ -57,8 +57,8 @@ public void Crud() using (ITransaction t = s.BeginTransaction()) { var m = s.Get(savedId); - m.DateTimeProp.Should().Be(expectedMoment); - m.TimeSpanProp.Should().Be(expectedLapse); + Assert.That(m.DateTimeProp, Is.EqualTo(expectedMoment)); + Assert.That(m.TimeSpanProp, Is.EqualTo(expectedLapse)); t.Commit(); } diff --git a/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs b/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs index d8cf02434b6..aa2440e1629 100644 --- a/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs +++ b/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs @@ -12,8 +12,8 @@ public void CanProxyBasicGenericMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); - c.BasicGenericMethod().Should().Be(5); - c.BasicGenericMethod().Should().Be("blha"); + Assert.That(c.BasicGenericMethod(), Is.EqualTo(5)); + Assert.That(c.BasicGenericMethod(), Is.EqualTo("blha")); } [Test] @@ -21,7 +21,7 @@ public void CanProxyMethodWithGenericBaseClassConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); - c.MethodWithGenericBaseClassConstraint, int>().Should().Be(typeof(MyGenericClass)); + Assert.That(c.MethodWithGenericBaseClassConstraint, int>(), Is.EqualTo(typeof(MyGenericClass))); } [Test] @@ -29,7 +29,7 @@ public void CanProxySelfCastingMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); - c.As().Should().Not.Be.Null(); + Assert.That(c.As(), Is.Not.Null); } [Test] @@ -37,7 +37,7 @@ public void CanProxyMethodWithDefaultConstructorConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); - c.MethodWithConstructorConstraint().Should().Not.Be.Null(); + Assert.That(c.MethodWithConstructorConstraint(), Is.Not.Null); } [Test] @@ -45,7 +45,7 @@ public void CanProxyGenericMethodWithInterfaceConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); - c.MethodWithInterfaceConstraint(new MyDerivedClass()).Should().Be(typeof(IMyInterface)); + Assert.That(c.MethodWithInterfaceConstraint(new MyDerivedClass()), Is.EqualTo(typeof(IMyInterface))); } [Test] @@ -53,7 +53,7 @@ public void CanProxyGenericMethodWithReferenceTypeAndInterfaceConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyDerivedClass()), null); - c.MethodWithReferenceTypeAndInterfaceConstraint().Should().Not.Be.Null(); + Assert.That(c.MethodWithReferenceTypeAndInterfaceConstraint(), Is.Not.Null); } [Test] @@ -61,7 +61,7 @@ public void CanProxySelfCastingMethodWithGenericConstaint() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.As>().Should().Not.Be.Null(); + Assert.That(c.As>(), Is.Not.Null); } [Test] @@ -69,7 +69,7 @@ public void CanProxySelfCastingMethodWithGenericConstaintBase() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsBase>().Should().Not.Be.Null(); + Assert.That(c.AsBase>(), Is.Not.Null); } [Test] @@ -77,7 +77,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceConstaint() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterface>().Should().Not.Be.Null(); + Assert.That(c.AsInterface>(), Is.Not.Null); } [Test] @@ -85,7 +85,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterfaceBase>().Should().Not.Be.Null(); + Assert.That(c.AsInterfaceBase>(), Is.Not.Null); } [Test] @@ -93,7 +93,7 @@ public void CanProxySelfCastingMethodWithGenericConstaint2() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.As2>().Should().Not.Be.Null(); + Assert.That(c.As2>(), Is.Not.Null); } [Test] @@ -101,7 +101,7 @@ public void CanProxySelfCastingMethodWithGenericConstaintBase2() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsBase2>().Should().Not.Be.Null(); + Assert.That(c.AsBase2>(), Is.Not.Null); } [Test] @@ -109,7 +109,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceConstaint2() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterface2>().Should().Not.Be.Null(); + Assert.That(c.AsInterface2>(), Is.Not.Null); } [Test] @@ -117,7 +117,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint2() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterfaceBase2>().Should().Not.Be.Null(); + Assert.That(c.AsInterfaceBase2>(), Is.Not.Null); } [Test] @@ -125,7 +125,7 @@ public void CanProxySelfCastingMethodWithGenericConstaint3() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.As3, object>().Should().Not.Be.Null(); + Assert.That(c.As3, object>(), Is.Not.Null); } [Test] @@ -133,7 +133,7 @@ public void CanProxySelfCastingMethodWithGenericConstaintBase3() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsBase3, object>().Should().Not.Be.Null(); + Assert.That(c.AsBase3, object>(), Is.Not.Null); } [Test] @@ -141,7 +141,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceConstaint3() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterface3, object>().Should().Not.Be.Null(); + Assert.That(c.AsInterface3, object>(), Is.Not.Null); } [Test] @@ -149,7 +149,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint3() { var factory = new ProxyFactory(); var c = (MyGenericClass) factory.CreateProxy(typeof (MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterfaceBase3, object>().Should().Not.Be.Null(); + Assert.That(c.AsInterfaceBase3, object>(), Is.Not.Null); } [Test] @@ -157,7 +157,7 @@ public void CanProxySelfCastingMethodWithGenericConstaint4() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.As4>().Should().Not.Be.Null(); + Assert.That(c.As4>(), Is.Not.Null); } [Test] @@ -165,7 +165,7 @@ public void CanProxySelfCastingMethodWithGenericConstaintBase4() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsBase4>().Should().Not.Be.Null(); + Assert.That(c.AsBase4>(), Is.Not.Null); } [Test] @@ -173,7 +173,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceConstaint4() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterface4>().Should().Not.Be.Null(); + Assert.That(c.AsInterface4>(), Is.Not.Null); } [Test] @@ -181,7 +181,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint4() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterfaceBase4>().Should().Not.Be.Null(); + Assert.That(c.AsInterfaceBase4>(), Is.Not.Null); } [Test] @@ -189,7 +189,7 @@ public void CanProxySelfCastingMethodWithGenericConstaint5() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.As5>().Should().Not.Be.Null(); + Assert.That(c.As5>(), Is.Not.Null); } [Test] @@ -197,7 +197,7 @@ public void CanProxySelfCastingMethodWithGenericConstaintBase5() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsBase5>().Should().Not.Be.Null(); + Assert.That(c.AsBase5>(), Is.Not.Null); } [Test] @@ -205,7 +205,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceConstaint5() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterface5>().Should().Not.Be.Null(); + Assert.That(c.AsInterface5>(), Is.Not.Null); } [Test] @@ -213,7 +213,7 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint5() { var factory = new ProxyFactory(); var c = (MyGenericClass)factory.CreateProxy(typeof(MyGenericClass), new PassThroughInterceptor(new MyGenericClass()), null); - c.AsInterfaceBase5>().Should().Not.Be.Null(); + Assert.That(c.AsInterfaceBase5>(), Is.Not.Null); } [Test] diff --git a/src/NHibernate.Test/DynamicProxyTests/InterfaceWithEqualsGethashcodeTests.cs b/src/NHibernate.Test/DynamicProxyTests/InterfaceWithEqualsGethashcodeTests.cs index d27291c37cc..cd678c4f0d4 100644 --- a/src/NHibernate.Test/DynamicProxyTests/InterfaceWithEqualsGethashcodeTests.cs +++ b/src/NHibernate.Test/DynamicProxyTests/InterfaceWithEqualsGethashcodeTests.cs @@ -38,7 +38,7 @@ public void WhenProxyAnInterfaceShouldInterceptEquals() var interceptor = new InterceptedMethodsExposer(); var proxy = proxyFactory.CreateProxy(typeof(IHasSomething), interceptor, null); proxy.Equals(null); - interceptor.InterceptedMethods.Should().Contain("Equals"); + Assert.That(interceptor.InterceptedMethods, Contains.Item("Equals")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs index 1d03caddfd0..829dc277a3a 100644 --- a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs +++ b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs @@ -18,7 +18,7 @@ public class MyClass [Test] public void LazyFieldInterceptorMarkedAsSerializable() { - typeof(DefaultDynamicLazyFieldInterceptor).Should().Have.Attribute(); + Assert.That(typeof(DefaultDynamicLazyFieldInterceptor), Has.Attribute()); } [Test] @@ -30,8 +30,7 @@ public void LazyFieldInterceptorIsBinarySerializable() var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy(new MyClass()); fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass)); - fieldInterceptionProxy.Should().Be.BinarySerializable(); + Assert.That(fieldInterceptionProxy, Is.BinarySerializable); } - } } \ No newline at end of file diff --git a/src/NHibernate.Test/DynamicProxyTests/ProxiedMembers/MetodWithRefDictionaryTest.cs b/src/NHibernate.Test/DynamicProxyTests/ProxiedMembers/MetodWithRefDictionaryTest.cs index 7e27b94429e..051130a2cce 100644 --- a/src/NHibernate.Test/DynamicProxyTests/ProxiedMembers/MetodWithRefDictionaryTest.cs +++ b/src/NHibernate.Test/DynamicProxyTests/ProxiedMembers/MetodWithRefDictionaryTest.cs @@ -23,7 +23,7 @@ public void Proxy() var dictionary = new Dictionary(); var myParam = dictionary; c.Method(ref myParam); - myParam.Should().Not.Be.SameInstanceAs(dictionary); + Assert.That(myParam, Is.Not.SameAs(dictionary)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Events/DisposableListenersTest.cs b/src/NHibernate.Test/Events/DisposableListenersTest.cs index 8d457f1e339..682b153488f 100644 --- a/src/NHibernate.Test/Events/DisposableListenersTest.cs +++ b/src/NHibernate.Test/Events/DisposableListenersTest.cs @@ -29,7 +29,7 @@ public void WhenCloseSessionFactoryThenCallDisposeOfListener() cfg.AppendListeners(ListenerType.PostUpdate, new[]{myDisposableListener}); var sf = cfg.BuildSessionFactory(); sf.Close(); - myDisposableListener.DisposeCalled.Should().Be.True(); + Assert.That(myDisposableListener.DisposeCalled, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/GenericTest/EnumGeneric/EnumGenericFixture.cs b/src/NHibernate.Test/GenericTest/EnumGeneric/EnumGenericFixture.cs index 83edb7be3c2..5473435110c 100644 --- a/src/NHibernate.Test/GenericTest/EnumGeneric/EnumGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/EnumGeneric/EnumGenericFixture.cs @@ -36,7 +36,7 @@ public void MapsToEnum() int index = -1; for (int i = 0; i < persister.PropertyNames.Length; i++) { - if (persister.PropertyNames[i].Equals("NullableValue")) + if (persister.PropertyNames[i] == "NullableValue") { index = i; break; @@ -45,7 +45,7 @@ public void MapsToEnum() if (index == -1) Assert.Fail("Property NullableValue not found."); - persister.PropertyTypes[index].Should().Be.AssignableTo(); + Assert.That(persister.PropertyTypes[index], Is.AssignableTo()); } } diff --git a/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs b/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs index a89b0159f15..d4661745654 100644 --- a/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs +++ b/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs @@ -128,13 +128,13 @@ public void WillLoadGhostAssociationOnAccess() { order = s.Get(1); var logMessage = ls.GetWholeLog(); - logMessage.Should().Not.Contain("FROM Payment"); + Assert.That(logMessage, Is.Not.StringContaining("FROM Payment")); } - order.Satisfy(o => !NHibernateUtil.IsPropertyInitialized(o, "Payment")); + Assert.That(NHibernateUtil.IsPropertyInitialized(order, "Payment"), Is.False); // trigger on-access lazy load var x = order.Payment; - order.Satisfy(o => NHibernateUtil.IsPropertyInitialized(o, "Payment")); + Assert.That(NHibernateUtil.IsPropertyInitialized(order, "Payment"), Is.True); } } @@ -148,19 +148,19 @@ public void WhenGetThenLoadOnlyNoLazyPlainProperties() { order = s.Get(1); var logMessage = ls.GetWholeLog(); - logMessage.Should().Not.Contain("ALazyProperty"); - logMessage.Should().Contain("NoLazyProperty"); + Assert.That(logMessage, Is.Not.StringContaining("ALazyProperty")); + Assert.That(logMessage, Is.StringContaining("NoLazyProperty")); } - order.Satisfy(o => NHibernateUtil.IsPropertyInitialized(o, "NoLazyProperty")); - order.Satisfy(o => !NHibernateUtil.IsPropertyInitialized(o, "ALazyProperty")); + Assert.That(NHibernateUtil.IsPropertyInitialized(order, "NoLazyProperty"), Is.True); + Assert.That(NHibernateUtil.IsPropertyInitialized(order, "ALazyProperty"), Is.False); using (var ls = new SqlLogSpy()) { var x = order.ALazyProperty; var logMessage = ls.GetWholeLog(); - logMessage.Should().Contain("ALazyProperty"); + Assert.That(logMessage, Is.StringContaining("ALazyProperty")); } - order.Satisfy(o => NHibernateUtil.IsPropertyInitialized(o, "ALazyProperty")); + Assert.That(NHibernateUtil.IsPropertyInitialized(order, "ALazyProperty"), Is.True); } } } diff --git a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs index b2a164252ea..7853a34e054 100644 --- a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs +++ b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs @@ -350,8 +350,8 @@ public void UpdateWithWhereExistsSubquery() s = OpenSession(); t = s.BeginTransaction(); string updateQryString = "update Human h " + "set h.description = 'updated' " + "where exists (" - + " select f.id " + " from h.friends f " + " where f.name.last = 'Public' " - + ")"; + + " select f.id " + " from h.friends f " + " where f.name.last = 'Public' " + + ")"; int count = s.CreateQuery(updateQryString).ExecuteUpdate(); Assert.That(count, Is.EqualTo(1)); s.Delete(doll); @@ -376,15 +376,15 @@ public void UpdateWithWhereExistsSubquery() t = s.BeginTransaction(); // one-to-many test updateQryString = "update SimpleEntityWithAssociation e set e.Name = 'updated' where " - + "exists(select a.id from e.AssociatedEntities a " + "where a.Name = 'one-to-many-association')"; + + "exists(select a.id from e.AssociatedEntities a " + "where a.Name = 'one-to-many-association')"; count = s.CreateQuery(updateQryString).ExecuteUpdate(); Assert.That(count, Is.EqualTo(1)); // many-to-many test if (Dialect.SupportsSubqueryOnMutatingTable) { updateQryString = "update SimpleEntityWithAssociation e set e.Name = 'updated' where " - + "exists(select a.id from e.ManyToManyAssociatedEntities a " - + "where a.Name = 'many-to-many-association')"; + + "exists(select a.id from e.ManyToManyAssociatedEntities a " + + "where a.Name = 'many-to-many-association')"; count = s.CreateQuery(updateQryString).ExecuteUpdate(); Assert.That(count, Is.EqualTo(1)); } @@ -653,7 +653,7 @@ public void UpdateMultiplePropertyOnAnimal() .SetDouble("w1", 3) .ExecuteUpdate(); - count.Should().Be(1); + Assert.That(count, Is.EqualTo(1)); t.Commit(); } @@ -661,8 +661,8 @@ public void UpdateMultiplePropertyOnAnimal() using (s.BeginTransaction()) { var tadpole = s.Get(data.Polliwog.Id); - tadpole.Description.Should().Be("Tadpole"); - tadpole.BodyWeight.Should().Be(3); + Assert.That(tadpole.Description, Is.EqualTo("Tadpole")); + Assert.That(tadpole.BodyWeight, Is.EqualTo(3)); } data.Cleanup(); diff --git a/src/NHibernate.Test/Hql/Ast/LimitClauseFixture.cs b/src/NHibernate.Test/Hql/Ast/LimitClauseFixture.cs index c0b20d4de24..eadeb277b62 100644 --- a/src/NHibernate.Test/Hql/Ast/LimitClauseFixture.cs +++ b/src/NHibernate.Test/Hql/Ast/LimitClauseFixture.cs @@ -97,7 +97,7 @@ public void SkipTakeWithParameter() .SetInt32("pSkip", 1) .SetInt32("pTake", 3).List().Select(h => h.BodyWeight).ToArray(); var expected = new[] {6f, 10f, 15f}; - actual.Should().Have.SameSequenceAs(expected); + Assert.That(actual, Is.EquivalentTo(expected)); txn.Commit(); s.Close(); @@ -114,7 +114,7 @@ public void SkipTakeWithParameterList() .SetInt32("pSkip", 1) .SetInt32("pTake", 4).List().Select(h => h.BodyWeight).ToArray(); var expected = new[] {10f, 15f}; - actual.Should().Have.SameSequenceAs(expected); + Assert.That(actual, Is.EquivalentTo(expected)); txn.Commit(); s.Close(); @@ -128,7 +128,7 @@ public void SkipWithParameter() float[] actual = s.CreateQuery("from Human h order by h.bodyWeight skip :jump").SetInt32("jump", 2).List().Select(h => h.BodyWeight).ToArray(); var expected = new[] {10f, 15f, 20f}; - actual.Should().Have.SameSequenceAs(expected); + Assert.That(actual, Is.EquivalentTo(expected)); txn.Commit(); s.Close(); diff --git a/src/NHibernate.Test/Hql/Ast/QuerySubstitutionTest.cs b/src/NHibernate.Test/Hql/Ast/QuerySubstitutionTest.cs index f6684737e59..4e471d012df 100644 --- a/src/NHibernate.Test/Hql/Ast/QuerySubstitutionTest.cs +++ b/src/NHibernate.Test/Hql/Ast/QuerySubstitutionTest.cs @@ -19,7 +19,7 @@ public void WhenSubstitutionsConfiguredThenUseItInTranslation() { const string query = "from SimpleClass s where s.IntValue > pizza"; var sql = GetSql(query, new Dictionary{{"pizza","1"}}); - sql.Should().Not.Contain("pizza"); + Assert.That(sql, Is.Not.StringContaining("pizza")); } [Test] @@ -32,7 +32,7 @@ public void WhenExecutedThroughSessionThenUseSubstitutions() { s.CreateQuery(query).List(); string sql = sqlLogSpy.Appender.GetEvents()[0].RenderedMessage; - sql.Should().Not.Contain("pizza"); + Assert.That(sql, Is.Not.StringContaining("pizza")); } } } @@ -42,7 +42,7 @@ public void WhenSubstitutionsWithStringConfiguredThenUseItInTranslation() { const string query = "from SimpleClass s where s.Description > calda"; var sql = GetSql(query, new Dictionary { { "calda", "'bobrock'" } }); - sql.Should().Not.Contain("pizza").And.Contain("'bobrock'"); + Assert.That(sql, Is.Not.StringContaining("pizza").And.Contains("'bobrock'")); } [Test] @@ -55,7 +55,7 @@ public void WhenExecutedThroughSessionThenUseSubstitutionsWithString() { s.CreateQuery(query).List(); string sql = sqlLogSpy.Appender.GetEvents()[0].RenderedMessage; - sql.Should().Not.Contain("pizza").And.Contain("'bobrock'"); + Assert.That(sql, Is.Not.StringContaining("pizza").And.Contains("'bobrock'")); } } } diff --git a/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs b/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs index 42ecbe38c43..5da94051892 100644 --- a/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs +++ b/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs @@ -37,11 +37,11 @@ protected override bool AppliesTo(Dialect.Dialect dialect) protected override void Configure(Configuration configuration) { configuration.DataBaseIntegration(x => - { + { x.BatchSize = batchSize; x.OrderInserts = true; x.Batcher(); - }); + }); } [Test] @@ -63,7 +63,7 @@ public void BatchOrdering() } int expectedBatchesPerEntity = (instancesPerEach / batchSize) + ((instancesPerEach % batchSize) == 0 ? 0 : 1); - StatsBatcher.BatchSizes.Count.Should().Be(expectedBatchesPerEntity * typesOfEntities); + Assert.That(StatsBatcher.BatchSizes.Count, Is.EqualTo(expectedBatchesPerEntity * typesOfEntities)); using (ISession s = OpenSession()) { diff --git a/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs b/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs index 1b55126b7c6..3afe34147c7 100644 --- a/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs +++ b/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs @@ -61,15 +61,15 @@ public void PropertyLoadedNotInitialized() { var book = s.Load(1); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "Id")); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "Name")); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText")); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Id"), Is.False); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Name"), Is.False); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.False); NHibernateUtil.Initialize(book); - Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Id")); - Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Name")); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText")); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Id"), Is.True); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Name"), Is.True); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.False); } } @@ -86,9 +86,9 @@ public void PropertyLoadedNotInitializedWhenUsingGet() { var book = s.Get(1); - Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Id")); - Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Name")); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText")); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Id"), Is.True); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "Name"), Is.True); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.False); } } @@ -99,8 +99,8 @@ public void CanGetValueForLazyProperty() { var book = s.Get(1); - Assert.AreEqual("a lot of text ...", book.ALotOfText); - Assert.True(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText")); + Assert.That(book.ALotOfText, Is.EqualTo("a lot of text ...")); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.True); } } @@ -111,8 +111,8 @@ public void CanGetValueForNonLazyProperty() { var book = s.Get(1); - Assert.AreEqual("some name", book.Name); - Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText")); + Assert.That(book.Name, Is.EqualTo("some name")); + Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.False); } } diff --git a/src/NHibernate.Test/Linq/BooleanMethodExtensionExample.cs b/src/NHibernate.Test/Linq/BooleanMethodExtensionExample.cs index 6f9bbaad2f9..3ebe4901a1e 100644 --- a/src/NHibernate.Test/Linq/BooleanMethodExtensionExample.cs +++ b/src/NHibernate.Test/Linq/BooleanMethodExtensionExample.cs @@ -32,8 +32,8 @@ public FreetextGenerator() } public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, - ReadOnlyCollection arguments, HqlTreeBuilder treeBuilder, - IHqlExpressionVisitor visitor) + ReadOnlyCollection arguments, HqlTreeBuilder treeBuilder, + IHqlExpressionVisitor visitor) { IEnumerable args = arguments.Select(a => visitor.Visit(a)) .Cast(); @@ -50,7 +50,7 @@ public class MyLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry public MyLinqToHqlGeneratorsRegistry() { RegisterGenerator(ReflectionHelper.GetMethodDefinition(() => BooleanLinqExtensions.FreeText(null, null)), - new FreetextGenerator()); + new FreetextGenerator()); } } @@ -63,8 +63,8 @@ protected override void Configure(Configuration configuration) public void CanUseMyCustomExtension() { List contacts = (from c in db.Customers where c.ContactName.FreeText("Thomas") select c).ToList(); - contacts.Count.Should().Be.GreaterThan(0); - contacts.Select(customer => customer.ContactName).All(c => c.Satisfy(customer => customer.Contains("Thomas"))); + Assert.That(contacts.Count, Is.GreaterThan(0)); + Assert.That(contacts.Select(c => c.ContactName).All(c => c.Contains("Thomas")), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Linq/ByMethod/CastTests.cs b/src/NHibernate.Test/Linq/ByMethod/CastTests.cs index 1572d30739c..1f34dfd06fe 100644 --- a/src/NHibernate.Test/Linq/ByMethod/CastTests.cs +++ b/src/NHibernate.Test/Linq/ByMethod/CastTests.cs @@ -11,19 +11,19 @@ public class CastTests : LinqTestCase [Test] public void CastCount() { - session.Query() - .Cast() - .Count().Should().Be(1); + Assert.That(session.Query() + .Cast() + .Count(), Is.EqualTo(1)); } [Test] public void CastWithWhere() { var pregnatMammal = (from a - in session.Query().Cast() - where a.Pregnant - select a).FirstOrDefault(); - pregnatMammal.Should().Not.Be.Null(); + in session.Query().Cast() + where a.Pregnant + select a).FirstOrDefault(); + Assert.That(pregnatMammal, Is.Not.Null); } [Test] @@ -31,7 +31,7 @@ public void CastDowncast() { var query = session.Query().Cast(); // the list contains at least one Cat then should Throws - query.Executing(q=> q.ToList()).Throws(); + Assert.That(() => query.ToList(), Throws.Exception); } [Test] @@ -39,7 +39,7 @@ public void OrderByAfterCast() { // NH-2657 var query = session.Query().Cast().OrderBy(a=> a.BodyWeight); - query.Executing(q => q.ToList()).NotThrows(); + Assert.That(() => query.ToList(), Throws.Nothing); } [Test, Ignore("Not fixed yet. The method OfType does not work as expected.")] @@ -47,7 +47,7 @@ public void CastDowncastUsingOfType() { var query = session.Query().OfType().Cast(); // the list contains at least one Cat then should Throws - query.Executing(q => q.ToList()).Throws(); + Assert.That(() => query.ToList(), Throws.Exception); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Linq/ByMethod/DistinctTests.cs b/src/NHibernate.Test/Linq/ByMethod/DistinctTests.cs index 6761d9bd2ea..d30aaa945f2 100644 --- a/src/NHibernate.Test/Linq/ByMethod/DistinctTests.cs +++ b/src/NHibernate.Test/Linq/ByMethod/DistinctTests.cs @@ -30,7 +30,7 @@ public void DistinctOnAnonymousTypeProjection() .Distinct() .ToArray(); - result.Length.Should().Be.EqualTo(388); + Assert.That(result.Length, Is.EqualTo(388)); } [Test] @@ -46,7 +46,7 @@ public void DistinctOnComplexAnonymousTypeProjection() .Distinct() .ToArray(); - result.Length.Should().Be.EqualTo(774); + Assert.That(result.Length, Is.EqualTo(774)); } [Test] @@ -61,7 +61,7 @@ public void DistinctOnTypeProjection() .Distinct() .ToArray(); - result.Length.Should().Be.EqualTo(388); + Assert.That(result.Length, Is.EqualTo(388)); } [Test] @@ -77,7 +77,7 @@ public void DistinctOnTypeProjectionTwoProperty() .Distinct() .ToArray(); - result.Length.Should().Be.EqualTo(774); + Assert.That(result.Length, Is.EqualTo(774)); } [Test] @@ -95,7 +95,7 @@ public void DistinctOnTypeProjectionWithHqlMethodIsOk() .Distinct() .ToArray(); - result.Length.Should().Be.EqualTo(824); + Assert.That(result.Length, Is.EqualTo(824)); } [Test] diff --git a/src/NHibernate.Test/Linq/CustomExtensionsExample.cs b/src/NHibernate.Test/Linq/CustomExtensionsExample.cs index 355ee0683fb..ef683a72107 100644 --- a/src/NHibernate.Test/Linq/CustomExtensionsExample.cs +++ b/src/NHibernate.Test/Linq/CustomExtensionsExample.cs @@ -5,6 +5,7 @@ using System.Text.RegularExpressions; using NHibernate.Cfg; using NHibernate.Cfg.Loquacious; +using NHibernate.DomainModel.Northwind.Entities; using NHibernate.Hql.Ast; using NHibernate.Linq; using NHibernate.Linq.Functions; @@ -31,7 +32,7 @@ public class MyLinqToHqlGeneratorsRegistry: DefaultLinqToHqlGeneratorsRegistry public MyLinqToHqlGeneratorsRegistry():base() { RegisterGenerator(ReflectionHelper.GetMethodDefinition(() => MyLinqExtensions.IsLike(null, null)), - new IsLikeGenerator()); + new IsLikeGenerator()); } } @@ -46,7 +47,7 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { return treeBuilder.Like(visitor.Visit(arguments[0]).AsExpression(), - visitor.Visit(arguments[1]).AsExpression()); + visitor.Visit(arguments[1]).AsExpression()); } } @@ -61,8 +62,8 @@ protected override void Configure(NHibernate.Cfg.Configuration configuration) public void CanUseMyCustomExtension() { var contacts = (from c in db.Customers where c.ContactName.IsLike("%Thomas%") select c).ToList(); - contacts.Count.Should().Be.GreaterThan(0); - contacts.Select(customer => customer.ContactName).All(c => c.Satisfy(customer => customer.Contains("Thomas"))); + Assert.That(contacts.Count, Is.GreaterThan(0)); + Assert.That(contacts.All(c => c.ContactName.Contains("Thomas")), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Linq/EagerLoadTests.cs b/src/NHibernate.Test/Linq/EagerLoadTests.cs index 48905e0068b..d5d30ef8000 100644 --- a/src/NHibernate.Test/Linq/EagerLoadTests.cs +++ b/src/NHibernate.Test/Linq/EagerLoadTests.cs @@ -60,16 +60,15 @@ public void NestedRelationshipsCanBeEagerLoaded() public void WhenFetchSuperclassCollectionThenNotThrows() { // NH-2277 - session.Executing(s => s.Query().Fetch(x => x.Children).ToList()).NotThrows(); + Assert.That(() => session.Query().Fetch(x => x.Children).ToList(), Throws.Nothing); session.Close(); } [Test] public void FetchWithWhere() { - // NH-2381 NH-2362 - (from p - in session.Query().Fetch(a => a.Supplier) + // NH-2381 NH-2362 + (from p in session.Query().Fetch(a => a.Supplier) where p.ProductId == 1 select p).ToList(); } diff --git a/src/NHibernate.Test/Linq/LinqTestCase.cs b/src/NHibernate.Test/Linq/LinqTestCase.cs index e98075488fe..0b79e8136b3 100755 --- a/src/NHibernate.Test/Linq/LinqTestCase.cs +++ b/src/NHibernate.Test/Linq/LinqTestCase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NHibernate.DomainModel.Northwind.Entities; +using NUnit.Framework; using SharpTestsEx; namespace NHibernate.Test.Linq @@ -64,9 +65,9 @@ protected override void OnTearDown() } } - public void AssertByIds(IEnumerable entities, TId[] expectedIds, Converter entityIdGetter) + public static void AssertByIds(IEnumerable entities, TId[] expectedIds, Converter entityIdGetter) { - entities.Select(x => entityIdGetter(x)).Should().Have.SameValuesAs(expectedIds); + Assert.That(entities.Select(x => entityIdGetter(x)), Is.EquivalentTo(expectedIds)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs b/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs index 5201010fd29..a470ef8f0c1 100644 --- a/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs +++ b/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs @@ -14,8 +14,8 @@ public class LinqToHqlGeneratorsRegistryFactoryTest public void WhenNotDefinedThenReturnDefaultRegistry() { var registry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(new Dictionary()); - registry.Should().Not.Be.Null(); - registry.Should().Be.OfType(); + Assert.That(registry, Is.Not.Null); + Assert.That(registry, Is.TypeOf()); } [Test] @@ -23,8 +23,8 @@ public void WhenDefinedThenReturnCustomtRegistry() { var properties = new Dictionary { { Environment.LinqToHqlGeneratorsRegistry, typeof(MyLinqToHqlGeneratorsRegistry).AssemblyQualifiedName } }; var registry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(properties); - registry.Should().Not.Be.Null(); - registry.Should().Be.OfType(); + Assert.That(registry, Is.Not.Null); + Assert.That(registry, Is.TypeOf()); } private class MyLinqToHqlGeneratorsRegistry : ILinqToHqlGeneratorsRegistry diff --git a/src/NHibernate.Test/Linq/MathTests.cs b/src/NHibernate.Test/Linq/MathTests.cs index 69c79fd7e12..b078c7f0f5f 100644 --- a/src/NHibernate.Test/Linq/MathTests.cs +++ b/src/NHibernate.Test/Linq/MathTests.cs @@ -33,7 +33,7 @@ public void SignAllPositiveTest() var signs = (from o in db.OrderLines select Math.Sign(o.UnitPrice)).ToList(); - Assert.True(signs.All(x => x == 1)); + Assert.That(signs.All(x => x == 1), Is.True); } [Test] @@ -43,7 +43,7 @@ public void SignAllNegativeTest() var signs = (from o in db.OrderLines select Math.Sign(0m - o.UnitPrice)).ToList(); - Assert.True(signs.All(x => x == -1)); + Assert.That(signs.All(x => x == -1), Is.True); } [Test] diff --git a/src/NHibernate.Test/Linq/ProjectionsTests.cs b/src/NHibernate.Test/Linq/ProjectionsTests.cs index 2e9a5ccea3c..e069c43a7f2 100644 --- a/src/NHibernate.Test/Linq/ProjectionsTests.cs +++ b/src/NHibernate.Test/Linq/ProjectionsTests.cs @@ -205,7 +205,7 @@ public void CanUseConstantStringInProjection() var firstUser = query.First(); Assert.IsNotNull(firstUser); - firstUser.Category.Should().Be("something"); + Assert.That(firstUser.Category, Is.EqualTo("something")); } [Test] diff --git a/src/NHibernate.Test/Linq/StatelessSessionQueringTest.cs b/src/NHibernate.Test/Linq/StatelessSessionQueringTest.cs index 0ac4708b050..e7f483a9e9a 100644 --- a/src/NHibernate.Test/Linq/StatelessSessionQueringTest.cs +++ b/src/NHibernate.Test/Linq/StatelessSessionQueringTest.cs @@ -15,7 +15,7 @@ public void WhenQueryThroughStatelessSessionThenDoesNotThrows() using (var statelessSession = Sfi.OpenStatelessSession()) { var query = statelessSession.Query(); - query.Executing(q => q.ToList()).NotThrows(); + Assert.That(() => query.ToList(), Throws.Nothing); } } @@ -26,7 +26,7 @@ public void AggregateWithStartsWith() { StringBuilder query = (from c in statelessSession.Query() where c.CustomerId.StartsWith("A") select c.CustomerId) .Aggregate(new StringBuilder(), (sb, id) => sb.Append(id).Append(",")); - query.ToString().Should().Be("ALFKI,ANATR,ANTON,AROUT,"); + Assert.That(query.ToString(), Is.EqualTo("ALFKI,ANATR,ANTON,AROUT,")); } } } diff --git a/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs b/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs index da3562b0515..d9020209add 100644 --- a/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs +++ b/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs @@ -285,25 +285,25 @@ public void CallingMethods() logger.Fatal(null); logger.Fatal(null, null); - logMock.debug.Should().Be(1); - logMock.debugException.Should().Be(1); - logMock.debugFormat.Should().Be(1); - logMock.info.Should().Be(1); - logMock.infoException.Should().Be(1); - logMock.infoFormat.Should().Be(1); - logMock.warn.Should().Be(1); - logMock.warnException.Should().Be(1); - logMock.warnFormat.Should().Be(1); - logMock.error.Should().Be(1); - logMock.errorException.Should().Be(1); - logMock.errorFormat.Should().Be(1); - logMock.fatal.Should().Be(1); - logMock.fatalException.Should().Be(1); - logMock.isDebugEnabled.Should().Be.GreaterThan(1); - logMock.isInfoEnabled.Should().Be.GreaterThan(1); - logMock.isWarnEnabled.Should().Be.GreaterThan(1); - logMock.isErrorEnabled.Should().Be.GreaterThan(1); - logMock.isFatalEnabled.Should().Be.GreaterThan(1); + Assert.That(logMock.debug, Is.EqualTo(1)); + Assert.That(logMock.debugException, Is.EqualTo(1)); + Assert.That(logMock.debugFormat, Is.EqualTo(1)); + Assert.That(logMock.info, Is.EqualTo(1)); + Assert.That(logMock.infoException, Is.EqualTo(1)); + Assert.That(logMock.infoFormat, Is.EqualTo(1)); + Assert.That(logMock.warn, Is.EqualTo(1)); + Assert.That(logMock.warnException, Is.EqualTo(1)); + Assert.That(logMock.warnFormat, Is.EqualTo(1)); + Assert.That(logMock.error, Is.EqualTo(1)); + Assert.That(logMock.errorException, Is.EqualTo(1)); + Assert.That(logMock.errorFormat, Is.EqualTo(1)); + Assert.That(logMock.fatal, Is.EqualTo(1)); + Assert.That(logMock.fatalException, Is.EqualTo(1)); + Assert.That(logMock.isDebugEnabled, Is.GreaterThan(1)); + Assert.That(logMock.isInfoEnabled, Is.GreaterThan(1)); + Assert.That(logMock.isWarnEnabled, Is.GreaterThan(1)); + Assert.That(logMock.isErrorEnabled, Is.GreaterThan(1)); + Assert.That(logMock.isFatalEnabled, Is.GreaterThan(1)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Logging/LoggerProviderTest.cs b/src/NHibernate.Test/Logging/LoggerProviderTest.cs index 299ebbfa5d3..e7a68e82d68 100644 --- a/src/NHibernate.Test/Logging/LoggerProviderTest.cs +++ b/src/NHibernate.Test/Logging/LoggerProviderTest.cs @@ -8,14 +8,14 @@ public class LoggerProviderTest [Test] public void LoggerProviderCanCreateLoggers() { - LoggerProvider.LoggerFor("pizza").Should().Not.Be.Null(); - LoggerProvider.LoggerFor(typeof (LoggerProviderTest)).Should().Not.Be.Null(); + Assert.That(LoggerProvider.LoggerFor("pizza"), Is.Not.Null); + Assert.That(LoggerProvider.LoggerFor(typeof (LoggerProviderTest)), Is.Not.Null); } [Test] public void WhenNotConfiguredAndLog4NetExistsThenUseLog4NetFactory() { - LoggerProvider.LoggerFor("pizza").Should().Be.InstanceOf(); + Assert.That(LoggerProvider.LoggerFor("pizza"), Is.InstanceOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsAccessorTests.cs b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsAccessorTests.cs index 1a697db52f1..5d947e614a0 100644 --- a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsAccessorTests.cs +++ b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsAccessorTests.cs @@ -45,7 +45,7 @@ public void WhenMapComoponetWithNestBidirectionalComponentThenMapParentAccessor( var hbmClass = mapping.RootClasses[0]; var hbmMyCompo = hbmClass.Properties.OfType().Single(); - hbmMyCompo.Access.Should().Contain("camelcase"); + Assert.That(hbmMyCompo.Access, Is.StringContaining("camelcase")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsParentAccessorTests.cs b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsParentAccessorTests.cs index 4be73872b5f..b688f9840ee 100644 --- a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsParentAccessorTests.cs +++ b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/ComponetsParentAccessorTests.cs @@ -69,7 +69,7 @@ public void WhenMapComoponetWithNestBidirectionalComponentThenMapParentAccessor( var hbmMyCompo = hbmClass.Properties.OfType().Single(); var hbmMyNestedCompo = hbmMyCompo.Properties.OfType().Single(); - hbmMyNestedCompo.Parent.access.Should().Contain("camelcase"); + Assert.That(hbmMyNestedCompo.Parent.access, Is.StringContaining("camelcase")); } [Test] @@ -83,7 +83,7 @@ public void WhenCollectionOfComoponetsWithNestBidirectionalComponentThenMapParen var hbmMyCompo = (HbmCompositeElement)hbmBag.ElementRelationship; var hbmMyNestedCompo = hbmMyCompo.Properties.OfType().Single(); - hbmMyNestedCompo.Parent.access.Should().Contain("camelcase"); + Assert.That(hbmMyNestedCompo.Parent.access, Is.StringContaining("camelcase")); } [Test, Ignore("No fixed yet. When the parent is an entity it should be managed explicitly as explicitly is managed the relation (Parent instead many-to-one)")] @@ -93,7 +93,7 @@ public void WhenMapComoponetWithParentThenMapParentAccessor() var hbmClass = mapping.RootClasses[0]; var hbmMyCompo = hbmClass.Properties.OfType().Single(); - hbmMyCompo.Parent.access.Should().Contain("camelcase"); + Assert.That(hbmMyCompo.Parent.access, Is.StringContaining("camelcase")); } [Test, Ignore("No fixed yet. When the parent is an entity it should be managed explicitly as explicitly is managed the relation (Parent instead many-to-one)")] @@ -105,7 +105,7 @@ public void WhenCollectionOfComoponetsWithParentThenMapParentAccessor() var hbmBag = hbmClass.Properties.OfType().Single(); var hbmMyCompo = (HbmCompositeElement)hbmBag.ElementRelationship; - hbmMyCompo.Parent.access.Should().Contain("camelcase"); + Assert.That(hbmMyCompo.Parent.access, Is.StringContaining("camelcase")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/PropertyToFieldAccessorTest.cs b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/PropertyToFieldAccessorTest.cs index 57f708bc2eb..7114d452cc0 100644 --- a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/PropertyToFieldAccessorTest.cs +++ b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/PropertyToFieldAccessorTest.cs @@ -56,7 +56,7 @@ public void WhenFieldAccessToField() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "aField"); - hbmProperty.Access.Should().Be("field"); + Assert.That(hbmProperty.Access, Is.EqualTo("field")); } [Test] @@ -67,7 +67,7 @@ public void WhenAutoPropertyNoAccessor() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "AProp"); - hbmProperty.Access.Should().Be.NullOrEmpty(); + Assert.That(hbmProperty.Access, Is.Null.Or.Empty); } [Test] @@ -78,7 +78,7 @@ public void WhenPropertyWithSameBackFieldNoMatch() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "SameTypeOfBackField"); - hbmProperty.Access.Should().Be.NullOrEmpty(); + Assert.That(hbmProperty.Access, Is.Null.Or.Empty); } [Test] @@ -89,7 +89,7 @@ public void WhenReadOnlyPropertyWithSameBackFieldNoMatch() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "ReadOnlyWithSameBackField"); - hbmProperty.Access.Should().Not.Contain("field"); + Assert.That(hbmProperty.Access, Is.Not.StringContaining("field")); } [Test] @@ -102,7 +102,7 @@ public void WhenPropertyWithoutFieldNoMatch() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "PropertyWithoutField"); - hbmProperty.Access.Should().Not.Contain("field"); + Assert.That(hbmProperty.Access, Is.Not.StringContaining("field")); } [Test] @@ -113,7 +113,7 @@ public void WhenPropertyWithDifferentBackFieldMatch() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "WithDifferentBackField"); - hbmProperty.Access.Should().Contain("field"); + Assert.That(hbmProperty.Access, Is.StringContaining("field")); } [Test] @@ -124,7 +124,7 @@ public void WhenSetOnlyPropertyNoMatch() var hbmClass = hbmMapping.RootClasses[0]; var hbmProperty = hbmClass.Properties.Single(x => x.Name == "SetOnlyProperty"); - hbmProperty.Access.Should().Not.Contain("field"); + Assert.That(hbmProperty.Access, Is.Not.StringContaining("field")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/SafePoidTests.cs b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/SafePoidTests.cs index 3d02323ec0a..6051e1dcf3d 100644 --- a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/SafePoidTests.cs +++ b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/SafePoidTests.cs @@ -30,10 +30,10 @@ public void WhenClassWithoutPoidNorGeeneratorThenApplyGuid() var hbmClass = hbmMapping.RootClasses[0]; var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.generator.Should().Not.Be.Null(); - hbmId.generator.@class.Should().Be("guid"); - hbmId.type1.Should().Be("Guid"); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.generator, Is.Not.Null); + Assert.That(hbmId.generator.@class, Is.EqualTo("guid")); + Assert.That(hbmId.type1, Is.EqualTo("Guid")); } [Test] @@ -45,10 +45,10 @@ public void WhenClassWithoutPoidWithGeneratorThenApplyDefinedGenerator() var hbmClass = hbmMapping.RootClasses[0]; var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.generator.Should().Not.Be.Null(); - hbmId.generator.@class.Should().Be("native"); - hbmId.type1.Should().Be(Generators.Native.DefaultReturnType.GetNhTypeName()); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.generator, Is.Not.Null); + Assert.That(hbmId.generator.@class, Is.EqualTo("native")); + Assert.That(hbmId.type1, Is.EqualTo(Generators.Native.DefaultReturnType.GetNhTypeName())); } [Test] @@ -59,7 +59,7 @@ public void WhenPoidNoSetterThenApplyNosetter() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Id.access.Should().Be("nosetter.camelcase-underscore"); + Assert.That(hbmClass.Id.access, Is.EqualTo("nosetter.camelcase-underscore")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/VersionOnBaseClassIntegrationTest.cs b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/VersionOnBaseClassIntegrationTest.cs index 9f4834f1231..774398a1715 100644 --- a/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/VersionOnBaseClassIntegrationTest.cs +++ b/src/NHibernate.Test/MappingByCode/ConventionModelMapperTests/VersionOnBaseClassIntegrationTest.cs @@ -33,8 +33,8 @@ public void WhenPropertyVersionFromBaseEntityThenFindItAsVersion() var hbmClass = hbmMapping.RootClasses[0]; var hbmVersion = hbmClass.Version; - hbmVersion.Should().Not.Be.Null(); - hbmVersion.name.Should().Be("Version"); + Assert.That(hbmVersion, Is.Not.Null); + Assert.That(hbmVersion.name, Is.EqualTo("Version")); } [Test] @@ -54,10 +54,9 @@ public void WhenVersionFromBaseEntityThenShouldntMapVersionAsProperty() var hbmClass = hbmMapping.RootClasses[0]; var hbmVersion = hbmClass.Version; - hbmVersion.Should().Not.Be.Null(); - hbmVersion.name.Should().Be("Version"); - - hbmClass.Properties.Should("because one is the POID and the other is the version").Be.Empty(); + Assert.That(hbmVersion, Is.Not.Null); + Assert.That(hbmVersion.name, Is.EqualTo("Version")); + Assert.That(hbmClass.Properties, Is.Empty, "because one is the POID and the other is the version"); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/CustomizerHolderMergeTest.cs b/src/NHibernate.Test/MappingByCode/CustomizerHolderMergeTest.cs index 142563d2853..0e12f6f3a8e 100644 --- a/src/NHibernate.Test/MappingByCode/CustomizerHolderMergeTest.cs +++ b/src/NHibernate.Test/MappingByCode/CustomizerHolderMergeTest.cs @@ -18,7 +18,7 @@ private class MyClass public void WhenMergeWithNullThenNotThrow() { var emptyHolder = new CustomizersHolder(); - emptyHolder.Executing(x=> x.Merge(null)).NotThrows(); + Assert.That(() => emptyHolder.Merge(null), Throws.Nothing); } [Test] @@ -32,7 +32,7 @@ public void MergeShouldMergeAnyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IAnyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -46,7 +46,7 @@ public void MergeShouldMergeBagPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IBagPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -60,7 +60,7 @@ public void MergeShouldMergeIdBagPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IIdBagPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -74,7 +74,7 @@ public void MergeShouldMergeCollectionPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IBagPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -88,7 +88,7 @@ public void MergeShouldMergeElementMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IElementMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -102,7 +102,7 @@ public void MergeShouldMergeManyToManyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IManyToManyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -116,7 +116,7 @@ public void MergeShouldMergeManyToAnyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IManyToAnyMapper) null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -130,7 +130,7 @@ public void MergeShouldMergeOneToManyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IOneToManyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -144,7 +144,7 @@ public void MergeShouldMergeComponentAttributesMapperOnProperty() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IComponentAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -158,7 +158,7 @@ public void MergeShouldMergeListPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IListPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -172,7 +172,7 @@ public void MergeShouldMergeManyToOneMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IManyToOneMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -186,7 +186,7 @@ public void MergeShouldMergeMapPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IMapPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -200,7 +200,7 @@ public void MergeShouldMergeMapKeyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IMapKeyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -214,7 +214,7 @@ public void MergeShouldMergeMapKeyManyToManyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IMapKeyManyToManyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -228,7 +228,7 @@ public void MergeShouldMergeOneToOneMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IOneToOneMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -242,7 +242,7 @@ public void MergeShouldMergePropertyMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IPropertyMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -256,7 +256,7 @@ public void MergeShouldMergeSetPropertiesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (ISetPropertiesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -270,7 +270,7 @@ public void MergeShouldMergeJoinedSubclassAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (IJoinedSubclassAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -284,7 +284,7 @@ public void MergeShouldMergeClassMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (IClassMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -298,7 +298,7 @@ public void MergeShouldMergeSubclassMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (ISubclassMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -312,7 +312,7 @@ public void MergeShouldMergeJoinAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (IJoinAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -326,7 +326,7 @@ public void MergeShouldMergeUnionSubclassAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (IUnionSubclassAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -340,7 +340,7 @@ public void MergeShouldMergeComponentAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(typeof(MyClass), (IComponentAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -354,7 +354,7 @@ public void MergeShouldMergeDynamicComponentAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IDynamicComponentAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -368,7 +368,7 @@ public void MergeShouldMergeComponentAsIdAttributesMapper() emptyHolder.Merge(holder); emptyHolder.InvokeCustomizers(propertyPath, (IComponentAsIdAttributesMapper)null); - called.Should().Be.True(); + Assert.That(called, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/AllPropertiesRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/AllPropertiesRegistrationTests.cs index 3fedd3bf9b8..2dd98a36c2e 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/AllPropertiesRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/AllPropertiesRegistrationTests.cs @@ -123,35 +123,35 @@ public void WhenMapPropertiesInTheBaseJumpedClassThenMapInInherited() inspector.IsRootEntity((type, declared) => type == typeof(Inherited)); var mapper = new ModelMapper(inspector); mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Property(x => x.Simple, map => map.Access(Accessor.Field)); - mc.Property(x => x.ComplexType, map => map.Access(Accessor.Field)); - mc.Bag(x => x.Bag, y => y.Access(Accessor.Field)); - mc.IdBag(x => x.IdBag, y => y.Access(Accessor.Field)); - mc.List(x => x.List, y => y.Access(Accessor.Field)); - mc.Set(x => x.Set, y => y.Access(Accessor.Field)); - mc.Map(x => x.Map, y => y.Access(Accessor.Field)); + { + mc.Id(x => x.Id); + mc.Property(x => x.Simple, map => map.Access(Accessor.Field)); + mc.Property(x => x.ComplexType, map => map.Access(Accessor.Field)); + mc.Bag(x => x.Bag, y => y.Access(Accessor.Field)); + mc.IdBag(x => x.IdBag, y => y.Access(Accessor.Field)); + mc.List(x => x.List, y => y.Access(Accessor.Field)); + mc.Set(x => x.Set, y => y.Access(Accessor.Field)); + mc.Map(x => x.Map, y => y.Access(Accessor.Field)); mc.OneToOne(x => x.OneToOne, y => y.Access(Accessor.Field)); mc.ManyToOne(x => x.ManyToOne, y => y.Access(Accessor.Field)); mc.Any(x => x.Any, typeof(int), y => y.Access(Accessor.Field)); mc.Component(x => x.DynamicCompo, new { A = 2 }, y => y.Access(Accessor.Field)); mc.Component(x => x.Compo, y => - { - y.Access(Accessor.Field); - y.Property(c => c.Something); - }); - }); + { + y.Access(Accessor.Field); + y.Property(c => c.Something); + }); + }); mapper.Class(mc =>{}); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); var hbmClass = mappings.RootClasses[0]; - mappings.JoinedSubclasses.Should().Be.Empty(); - hbmClass.Properties.Select(p => p.Name).Should().Have.SameValuesAs("Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", "DynamicCompo"); - hbmClass.Properties.Select(p => p.Access).All(x => x.Satisfy(access => access.Contains("field."))); + Assert.That(mappings.JoinedSubclasses, Is.Empty); + Assert.That(hbmClass.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", "DynamicCompo"})); + Assert.That(hbmClass.Properties.Select(p => p.Access).All(x => x.StartsWith("field.")), Is.True); } - [Test] + [Test] public void WhenMapPropertiesInTheBaseJumpedClassUsingMemberNameThenMapInInherited() { // ignoring MyClass and using Inherited, as root-class, I will try to map all properties using the base class. @@ -161,117 +161,109 @@ public void WhenMapPropertiesInTheBaseJumpedClassUsingMemberNameThenMapInInherit inspector.IsRootEntity((type, declared) => type == typeof(Inherited)); var mapper = new ModelMapper(inspector); mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Property("Simple", map => map.Access(Accessor.Field)); - mc.Property("ComplexType", map => map.Access(Accessor.Field)); - mc.Bag("Bag", y => y.Access(Accessor.Field)); - mc.IdBag("IdBag", y => y.Access(Accessor.Field)); - mc.List("List", y => y.Access(Accessor.Field)); - mc.Set("Set", y => y.Access(Accessor.Field)); - mc.Map("Map", y => y.Access(Accessor.Field)); - mc.OneToOne("OneToOne", y => y.Access(Accessor.Field)); - mc.ManyToOne("ManyToOne", y => y.Access(Accessor.Field)); - mc.Any("Any", typeof (int), y => y.Access(Accessor.Field)); - mc.Component("DynamicCompo", new {A = 2}, y => y.Access(Accessor.Field)); - mc.Component("Compo", y => - { - y.Access(Accessor.Field); - y.Property(c => c.Something); - }); - }); + { + mc.Id(x => x.Id); + mc.Property("Simple", map => map.Access(Accessor.Field)); + mc.Property("ComplexType", map => map.Access(Accessor.Field)); + mc.Bag("Bag", y => y.Access(Accessor.Field)); + mc.IdBag("IdBag", y => y.Access(Accessor.Field)); + mc.List("List", y => y.Access(Accessor.Field)); + mc.Set("Set", y => y.Access(Accessor.Field)); + mc.Map("Map", y => y.Access(Accessor.Field)); + mc.OneToOne("OneToOne", y => y.Access(Accessor.Field)); + mc.ManyToOne("ManyToOne", y => y.Access(Accessor.Field)); + mc.Any("Any", typeof (int), y => y.Access(Accessor.Field)); + mc.Component("DynamicCompo", new {A = 2}, y => y.Access(Accessor.Field)); + mc.Component("Compo", y => + { + y.Access(Accessor.Field); + y.Property(c => c.Something); + }); + }); mapper.Class(mc => { }); HbmMapping mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); HbmClass hbmClass = mappings.RootClasses[0]; - mappings.JoinedSubclasses.Should().Be.Empty(); - hbmClass.Properties.Select(p => p.Name).Should().Have.SameValuesAs("Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", - "DynamicCompo"); - hbmClass.Properties.Select(p => p.Access).All(x => x.Satisfy(access => access.Contains("field."))); + Assert.That(mappings.JoinedSubclasses, Is.Empty); + Assert.That(hbmClass.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", "DynamicCompo"})); + Assert.That(hbmClass.Properties.Select(p => p.Access).All(a => a.StartsWith("field.")), Is.True); } [Test] public void WhenMapBagWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Bag("Bag", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Bag("Bag", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapIdBagWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.IdBag("IdBag", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.IdBag("IdBag", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapSetWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Set("Set", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Set("Set", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapListWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Set("Set", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Set("Set", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapDictionaryWithWrongKeyTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Map("Map", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Map("Map", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapDictionaryWithWrongValueTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Map("Map", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Map("Map", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapComponentWithWrongElementTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Component("Compo", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Component("Compo", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } @@ -279,36 +271,33 @@ public void WhenMapComponentWithWrongElementTypeThenThrows() public void WhenMapOneToOneWithWrongTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.OneToOne("OneToOne", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.OneToOne("OneToOne", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapManyToOneWithWrongTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.ManyToOne("ManyToOne", y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.ManyToOne("ManyToOne", y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } [Test] public void WhenMapAnyWithWrongTypeThenThrows() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Any("Any", typeof(int),y => y.Access(Accessor.Field)); - })).Should().Throw(); + Assert.That(() => mapper.Class(mc => + { + mc.Id(x => x.Id); + mc.Any("Any", typeof(int),y => y.Access(Accessor.Field)); + }), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BagOfNestedComponentsWithParentTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BagOfNestedComponentsWithParentTest.cs index cd530dd8a19..bb2aaf3cd86 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BagOfNestedComponentsWithParentTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BagOfNestedComponentsWithParentTest.cs @@ -102,32 +102,32 @@ private void VerifyMapping(HbmMapping mapping, bool hasParent, params string[] p HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Person")); var relation = rc.Properties.First(p => p.Name == "Addresses"); var collection = (HbmBag)relation; - collection.ElementRelationship.Should().Be.OfType(); + Assert.That(collection.ElementRelationship, Is.TypeOf()); var elementRelation = (HbmCompositeElement)collection.ElementRelationship; - elementRelation.Class.Should().Contain("Address"); + Assert.That(elementRelation.Class, Is.StringContaining("Address")); // This test was modified because when the "owner" is an entity it can be mapped as many-to-one or as parent and without an explicit // definition of the property representing the bidiretional-relation we can't know is the mapping element (many-to-one or parent) - elementRelation.Properties.Should().Have.Count.EqualTo(properties.Length); - elementRelation.Properties.Select(p => p.Name).Should().Have.SameValuesAs(properties); + Assert.That(elementRelation.Properties.Count(), Is.EqualTo(properties.Length)); + Assert.That(elementRelation.Properties.Select(p => p.Name), Is.EquivalentTo(properties)); if (hasParent) { - elementRelation.Parent.Should().Not.Be.Null(); - elementRelation.Parent.name.Should().Be.EqualTo("Owner"); + Assert.That(elementRelation.Parent, Is.Not.Null); + Assert.That(elementRelation.Parent.name, Is.EqualTo("Owner")); } else { - elementRelation.Parent.Should().Be.Null(); + Assert.That(elementRelation.Parent, Is.Null); } // Nested var propertyNestedRelation = elementRelation.Properties.FirstOrDefault(p => p.Name == "Number"); - propertyNestedRelation.Should().Not.Be.Null().And.Be.OfType(); + Assert.That(propertyNestedRelation, Is.Not.Null.And.TypeOf()); var nestedRelation = (HbmNestedCompositeElement) propertyNestedRelation; - nestedRelation.Class.Should().Contain("Number"); - nestedRelation.Properties.Should().Have.Count.EqualTo(1); - nestedRelation.Parent.Should().Not.Be.Null(); - nestedRelation.Parent.name.Should().Be.EqualTo("OwnerAddress"); + Assert.That(nestedRelation.Class, Is.StringContaining("Number")); + Assert.That(nestedRelation.Properties.Count(), Is.EqualTo(1)); + Assert.That(nestedRelation.Parent, Is.Not.Null); + Assert.That(nestedRelation.Parent.name, Is.EqualTo("OwnerAddress")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BasicMappingOfSimpleClass.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BasicMappingOfSimpleClass.cs index 942df9e3864..aca7d9c7ffd 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BasicMappingOfSimpleClass.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/BasicMappingOfSimpleClass.cs @@ -57,17 +57,17 @@ public void WhenMapClassWithoutIdThenApplyTypeOfGeneratorDef() { var mapper = new ModelMapper(); mapper.Class(ca => ca.Id(null, map => - { - map.Column("MyClassId"); - map.Generator(Generators.HighLow, gmap => gmap.Params(new { max_low = 100 })); - })); + { + map.Column("MyClassId"); + map.Generator(Generators.HighLow, gmap => gmap.Params(new { max_low = 100 })); + })); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.column1.Should().Be("MyClassId"); - hbmId.type1.Should().Be(NHibernateUtil.Int32.Name); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.column1, Is.EqualTo("MyClassId")); + Assert.That(hbmId.type1, Is.EqualTo(NHibernateUtil.Int32.Name)); } [Test] @@ -80,11 +80,11 @@ public void WhenMapClassWithoutIdAndWithoutGeneratorThenTypeShouldHaveValue() })); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.column1.Should().Be("MyClassId"); - hbmId.type1.Should().Not.Be.Null(); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.column1, Is.EqualTo("MyClassId")); + Assert.That(hbmId.type1, Is.Not.Null); } [Test] @@ -136,18 +136,18 @@ public void WhenDuplicateClassDoesNotDuplicateMapping() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.name.Should().Be("Id"); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.name, Is.EqualTo("Id")); var hbmGenerator = hbmId.generator; - hbmGenerator.Should().Not.Be.Null(); - hbmGenerator.@class.Should().Be("hilo"); - hbmGenerator.param[0].name.Should().Be("max_low"); - hbmGenerator.param[0].GetText().Should().Be("100"); + Assert.That(hbmGenerator, Is.Not.Null); + Assert.That(hbmGenerator.@class, Is.EqualTo("hilo")); + Assert.That(hbmGenerator.param[0].name, Is.EqualTo("max_low")); + Assert.That(hbmGenerator.param[0].GetText(), Is.EqualTo("100")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("Something"); - hbmProperty.length.Should().Be("150"); + Assert.That(hbmProperty.name, Is.EqualTo("Something")); + Assert.That(hbmProperty.length, Is.EqualTo("150")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ClassWithComponentsTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ClassWithComponentsTest.cs index 7fe9afa04c5..db110d09794 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ClassWithComponentsTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ClassWithComponentsTest.cs @@ -54,8 +54,8 @@ public void ComponentMappingJustOnceDemo() var hbmClass = hbmMapping.RootClasses[0]; var hbmComponents = hbmClass.Properties.OfType(); - hbmComponents.Should().Have.Count.EqualTo(2); - hbmComponents.Select(x => x.Name).Should().Have.SameValuesAs("Name","Address"); + Assert.That(hbmComponents.Count(), Is.EqualTo(2)); + Assert.That(hbmComponents.Select(x => x.Name), Is.EquivalentTo(new [] {"Name", "Address"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ColumnsNamingConvetions.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ColumnsNamingConvetions.cs index 929f0ddd4e7..af1aa1a035d 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ColumnsNamingConvetions.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ColumnsNamingConvetions.cs @@ -32,11 +32,11 @@ public void MapClassWithConventions() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.column1.Should().Be("MYCLASSID"); + Assert.That(hbmId.column1, Is.EqualTo("MYCLASSID")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.column.Should().Be("SOMETHING"); + Assert.That(hbmProperty.column, Is.EqualTo("SOMETHING")); } [Test] @@ -57,11 +57,11 @@ public void MapClassWithHardConventions() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.column1.Should().Be("MYCLASSID"); + Assert.That(hbmId.column1, Is.EqualTo("MYCLASSID")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.column.Should().Be("SOMETHING"); + Assert.That(hbmProperty.column, Is.EqualTo("SOMETHING")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComponentAsIdTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComponentAsIdTests.cs index d976324c61f..c60ef8fc55c 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComponentAsIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComponentAsIdTests.cs @@ -51,9 +51,9 @@ public void WhenPropertyUsedAsComposedIdThenRegister() var mapper = new ModelMapper(inspector); mapper.Class(map => map.ComponentAsId(x => x.Id)); - inspector.IsPersistentId(For.Property(x => x.Id)).Should().Be.True(); - inspector.IsPersistentProperty(For.Property(x => x.Id)).Should().Be.True(); - inspector.IsComponent(typeof(IMyCompo)).Should().Be.True(); + Assert.That(inspector.IsPersistentId(For.Property(x => x.Id)), Is.True); + Assert.That(inspector.IsPersistentProperty(For.Property(x => x.Id)), Is.True); + Assert.That(inspector.IsComponent(typeof(IMyCompo)), Is.True); } [Test] @@ -61,18 +61,18 @@ public void WhenMapComponentAsIdThenMapItAndItsProperties() { var mapper = new ModelMapper(); mapper.Class(map => map.ComponentAsId(x => x.Id, idmap => - { - idmap.Property(y => y.Code); - idmap.Property(y => y.Name); - })); + { + idmap.Property(y => y.Code); + idmap.Property(y => y.Name); + })); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; var keyProperties = hbmCompositId.Items.OfType(); - keyProperties.Should().Have.Count.EqualTo(2); - keyProperties.Select(x => x.Name).Should().Have.SameValuesAs("Code", "Name"); - hbmCompositId.name.Should().Be(For.Property(x => x.Id).Name); + Assert.That(keyProperties.Count(), Is.EqualTo(2)); + Assert.That(keyProperties.Select(x => x.Name), Is.EquivalentTo(new [] {"Code", "Name"})); + Assert.That(hbmCompositId.name, Is.EqualTo(For.Property(x => x.Id).Name)); } [Test] @@ -88,8 +88,8 @@ public void WhenMapComponentAsIdAttributesThenMapAttributes() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; - hbmCompositId.access.Should().Contain("field"); - hbmCompositId.@class.Should().Contain("MyComponent"); + Assert.That(hbmCompositId.access, Is.StringContaining("field")); + Assert.That(hbmCompositId.@class, Is.StringContaining("MyComponent")); } [Test] @@ -97,19 +97,19 @@ public void WhenMapComponentUsedAsComponentAsIdThenMapItAndItsProperties() { var mapper = new ModelMapper(); mapper.Component(x => - { + { x.Property(y => y.Code, pm => pm.Length(10)); x.Property(y => y.Name); - }); + }); mapper.Class(map => map.ComponentAsId(x => x.Id)); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; var keyProperties = hbmCompositId.Items.OfType(); - keyProperties.Should().Have.Count.EqualTo(2); - keyProperties.Select(x => x.Name).Should().Have.SameValuesAs("Code", "Name"); - keyProperties.Where(x => x.Name == "Code").Single().length.Should().Be("10"); + Assert.That(keyProperties.Count(), Is.EqualTo(2)); + Assert.That(keyProperties.Select(x => x.Name), Is.EquivalentTo(new [] {"Code", "Name"})); + Assert.That(keyProperties.Single(x => x.Name == "Code").length, Is.EqualTo("10")); } [Test] @@ -131,7 +131,7 @@ public void WhenMapCustomizedComponentUsedAsComponentAsIdWithCustomizationThenUs var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; var keyProperties = hbmCompositId.Items.OfType(); - keyProperties.Select(x => x.length).Should().Have.SameValuesAs("15", "25"); + Assert.That(keyProperties.Select(x => x.length), Is.EquivalentTo(new [] {"15", "25"})); } [Test] @@ -148,8 +148,8 @@ public void WhenMapAttributesOfCustomizedComponentUsedAsComponentAsIdWithCustomi var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; - hbmCompositId.access.Should().Contain("field"); - hbmCompositId.@class.Should().Contain("MyComponent"); + Assert.That(hbmCompositId.access, Is.StringContaining("field")); + Assert.That(hbmCompositId.@class, Is.StringContaining("MyComponent")); } [Test] @@ -166,8 +166,8 @@ public void WhenMapAttributesOfCustomizedComponentUsedAsComponentAsIdWithCustomi var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; - hbmCompositId.access.Should().Contain("nosetter"); - hbmCompositId.@class.Should().Contain("MyComponent"); + Assert.That(hbmCompositId.access, Is.StringContaining("nosetter")); + Assert.That(hbmCompositId.@class, Is.StringContaining("MyComponent")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComposedIdTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComposedIdTests.cs index b731ea91b4c..0ade96cd566 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComposedIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ComposedIdTests.cs @@ -36,18 +36,18 @@ public void WhenPropertyUsedAsComposedIdThenRegister() var mapper = new ModelMapper(inspector); mapper.Class(map => map.ComposedId(cm=> - { + { cm.Property(x => x.Code); cm.ManyToOne(x => x.Relation); - }) - ); + }) + ); - inspector.IsMemberOfComposedId(For.Property(x => x.Code)).Should().Be.True(); - inspector.IsMemberOfComposedId(For.Property(x => x.Relation)).Should().Be.True(); - inspector.IsPersistentProperty(For.Property(x => x.Code)).Should().Be.True(); - inspector.IsPersistentProperty(For.Property(x => x.Relation)).Should().Be.True(); - inspector.IsPersistentId(For.Property(x => x.Code)).Should().Be.False(); - inspector.IsPersistentId(For.Property(x => x.Relation)).Should().Be.False(); + Assert.That(inspector.IsMemberOfComposedId(For.Property(x => x.Code)), Is.True); + Assert.That(inspector.IsMemberOfComposedId(For.Property(x => x.Relation)), Is.True); + Assert.That(inspector.IsPersistentProperty(For.Property(x => x.Code)), Is.True); + Assert.That(inspector.IsPersistentProperty(For.Property(x => x.Relation)), Is.True); + Assert.That(inspector.IsPersistentId(For.Property(x => x.Code)), Is.False); + Assert.That(inspector.IsPersistentId(For.Property(x => x.Relation)), Is.False); } [Test] @@ -64,8 +64,8 @@ public void WhenPropertyUsedAsComposedIdThenNotUsedAsSimpleProperties() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositId = hbmClass.CompositeId; - hbmCompositId.Items.Should().Have.Count.EqualTo(2); - hbmClass.Properties.Should().Be.Empty(); + Assert.That(hbmCompositId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmClass.Properties, Is.Empty); } [Test] @@ -73,21 +73,21 @@ public void WhenPropertyUsedAsComposedIdAndPropertiesThenNotUsedAsSimpleProperti { var mapper = new ModelMapper(); mapper.Class(map => - { - map.ComposedId(cm => - { - cm.Property(x => x.Code); - cm.ManyToOne(x => x.Relation); - }); - map.Property(x => x.Code); - map.ManyToOne(x => x.Relation); - } + { + map.ComposedId(cm => + { + cm.Property(x => x.Code); + cm.ManyToOne(x => x.Relation); + }); + map.Property(x => x.Code); + map.ManyToOne(x => x.Relation); + } ); HbmMapping hbmMapping = mapper.CompileMappingFor(new[] {typeof (MyClass)}); HbmClass hbmClass = hbmMapping.RootClasses[0]; HbmCompositeId hbmCompositId = hbmClass.CompositeId; - hbmCompositId.Items.Should().Have.Count.EqualTo(2); - hbmClass.Properties.Should().Be.Empty(); + Assert.That(hbmCompositId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmClass.Properties, Is.Empty); } [Test] @@ -102,10 +102,10 @@ public void WhenPropertyUsedAsComposedIdAndPropertiesAndNaturalIdThenMapOnlyAsCo cm.ManyToOne(x => x.Relation); }); map.NaturalId(nm => - { + { nm.Property(x => x.Code); nm.ManyToOne(x => x.Relation); - }); + }); map.Property(x => x.Code); map.ManyToOne(x => x.Relation); } @@ -113,9 +113,9 @@ public void WhenPropertyUsedAsComposedIdAndPropertiesAndNaturalIdThenMapOnlyAsCo HbmMapping hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); HbmClass hbmClass = hbmMapping.RootClasses[0]; HbmCompositeId hbmCompositId = hbmClass.CompositeId; - hbmCompositId.Items.Should().Have.Count.EqualTo(2); - hbmClass.naturalid.Should().Be.Null(); - hbmClass.Properties.Should().Be.Empty(); + Assert.That(hbmCompositId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmClass.naturalid, Is.Null); + Assert.That(hbmClass.Properties, Is.Empty); } [Test] @@ -133,8 +133,7 @@ public void WhenSuperclassPropertyUsedAsComposedIdThenRegister() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyOtherSubclass) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmCompositeId = hbmClass.CompositeId; - hbmCompositeId.Items.Should().Have.Count.EqualTo(2); + Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); } - } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ClassMappingRegistrationTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ClassMappingRegistrationTest.cs index 39e2c8a30bf..444017ac25d 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ClassMappingRegistrationTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ClassMappingRegistrationTest.cs @@ -70,7 +70,7 @@ public void WhenRegisterClassMappingThroughCollectionOfTypeThenMapTheClass() public void WhenRegisterClassMappingThroughCollectionOfTypeThenFilterValidMappings() { var mapper = new ModelMapper(); - mapper.Executing(x => x.AddMappings(new[] { typeof(object), typeof(MyClassMap), typeof(MyClass), typeof(MyClassBaseMap<>) })).NotThrows(); + Assert.That(() => mapper.AddMappings(new[] { typeof(object), typeof(MyClassMap), typeof(MyClass), typeof(MyClassBaseMap<>) }), Throws.Nothing); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); ModelIsWellFormed(hbmMapping); @@ -89,18 +89,18 @@ public void WhenRegisterClassMappingThroughTypeThenGetMapping() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.name.Should().Be("Id"); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.name, Is.EqualTo("Id")); var hbmGenerator = hbmId.generator; - hbmGenerator.Should().Not.Be.Null(); - hbmGenerator.@class.Should().Be("hilo"); - hbmGenerator.param[0].name.Should().Be("max_low"); - hbmGenerator.param[0].GetText().Should().Be("100"); + Assert.That(hbmGenerator, Is.Not.Null); + Assert.That(hbmGenerator.@class, Is.EqualTo("hilo")); + Assert.That(hbmGenerator.param[0].name, Is.EqualTo("max_low")); + Assert.That(hbmGenerator.param[0].GetText(), Is.EqualTo("100")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("Something"); - hbmProperty.length.Should().Be("150"); + Assert.That(hbmProperty.name, Is.EqualTo("Something")); + Assert.That(hbmProperty.length, Is.EqualTo("150")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ComponentMappingRegistrationTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ComponentMappingRegistrationTest.cs index dfc9200e460..d09168c51bc 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ComponentMappingRegistrationTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ComponentMappingRegistrationTest.cs @@ -69,15 +69,15 @@ public void WhenRegisterClassMappingThroughTypeThenMapTheClass() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.RootClasses.Single(); - hbmClass.Properties.Should().Have.Count.EqualTo(1); + Assert.That(hbmClass.Properties.Count(), Is.EqualTo(1)); var hbmComponent = hbmClass.Properties.OfType().Single(); - hbmComponent.name.Should().Be("Name"); - hbmComponent.Properties.Should().Have.Count.EqualTo(2); + Assert.That(hbmComponent.name, Is.EqualTo("Name")); + Assert.That(hbmComponent.Properties.Count(), Is.EqualTo(2)); var hbmp1 = hbmComponent.Properties.OfType().Single(x => x.name == "First"); var hbmp2 = hbmComponent.Properties.OfType().Single(x => x.name == "Last"); - hbmp1.length.Should().Be("20"); - hbmp2.length.Should().Be("30"); - hbmComponent.unique.Should().Be.EqualTo(true); + Assert.That(hbmp1.length, Is.EqualTo("20")); + Assert.That(hbmp2.length, Is.EqualTo("30")); + Assert.That(hbmComponent.unique, Is.EqualTo(true)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs index 678aa2c3342..7623575b262 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/JoinedSubclassMappingRegistration.cs @@ -64,11 +64,11 @@ public void WhenRegisterClassMappingThroughTypeThenMapTheClass() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.JoinedSubclasses.Single(); - hbmClass.Should().Not.Be.Null(); - hbmClass.extends.Should().Contain("MyClass"); + Assert.That(hbmClass, Is.Not.Null); + Assert.That(hbmClass.extends, Is.StringContaining("MyClass")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("SomethingElse"); - hbmProperty.length.Should().Be("15"); + Assert.That(hbmProperty.name, Is.EqualTo("SomethingElse")); + Assert.That(hbmProperty.length, Is.EqualTo("15")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ModelMapperAddMappingByTypeTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ModelMapperAddMappingByTypeTests.cs index 98ccd4c36f5..0bda71bff9f 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ModelMapperAddMappingByTypeTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/ModelMapperAddMappingByTypeTests.cs @@ -18,14 +18,14 @@ public WithOutPublicParameterLessCtor(string something) public void WhenRegisterClassMappingThroughTypeThenCheckIConformistHoldersProvider() { var mapper = new ModelMapper(); - mapper.Executing(x => x.AddMapping(typeof(object))).Throws().And.ValueOf.Message.Should().Contain("IConformistHoldersProvider"); + Assert.That(() => mapper.AddMapping(typeof (object)), Throws.TypeOf().And.Message.ContainsSubstring("IConformistHoldersProvider")); } [Test] public void WhenRegisterClassMappingThroughTypeThenCheckParameterLessCtor() { var mapper = new ModelMapper(); - mapper.Executing(x => x.AddMapping(typeof(WithOutPublicParameterLessCtor))).Throws(); + Assert.That(() => mapper.AddMapping(typeof (WithOutPublicParameterLessCtor)), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/SubclassMappingRegistration.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/SubclassMappingRegistration.cs index d685ec462a9..50d0afcebb7 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/SubclassMappingRegistration.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/SubclassMappingRegistration.cs @@ -64,11 +64,11 @@ public void WhenRegisterClassMappingThroughTypeThenMapTheClass() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.SubClasses.Single(); - hbmClass.Should().Not.Be.Null(); - hbmClass.extends.Should().Contain("MyClass"); + Assert.That(hbmClass, Is.Not.Null); + Assert.That(hbmClass.extends, Is.StringContaining("MyClass")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("SomethingElse"); - hbmProperty.length.Should().Be("15"); + Assert.That(hbmProperty.name, Is.EqualTo("SomethingElse")); + Assert.That(hbmProperty.length, Is.EqualTo("15")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/UnionSubclassMappingRegistrationTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/UnionSubclassMappingRegistrationTest.cs index 883f012fc13..c11751de6a1 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/UnionSubclassMappingRegistrationTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/ConformistMappingRegistrationTests/UnionSubclassMappingRegistrationTest.cs @@ -64,11 +64,11 @@ public void WhenRegisterClassMappingThroughTypeThenMapTheClass() private void ModelIsWellFormed(HbmMapping hbmMapping) { var hbmClass = hbmMapping.UnionSubclasses.Single(); - hbmClass.Should().Not.Be.Null(); - hbmClass.extends.Should().Contain("MyClass"); + Assert.That(hbmClass, Is.Not.Null); + Assert.That(hbmClass.extends, Is.StringContaining("MyClass")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("SomethingElse"); - hbmProperty.length.Should().Be("15"); + Assert.That(hbmProperty.name, Is.EqualTo("SomethingElse")); + Assert.That(hbmProperty.length, Is.EqualTo("15")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/DynamicComponentMappingTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/DynamicComponentMappingTests.cs index accad2b57a1..09715f95cc2 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/DynamicComponentMappingTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/DynamicComponentMappingTests.cs @@ -34,8 +34,8 @@ public void WhenMapDynCompoThenMapItAndItsProperties() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Person) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmDynamicComponent = hbmClass.Properties.OfType().SingleOrDefault(); - hbmDynamicComponent.Should().Not.Be.Null(); - hbmDynamicComponent.Properties.Select(x=> x.Name).Should().Have.SameValuesAs("MyInt", "MyDate"); + Assert.That(hbmDynamicComponent, Is.Not.Null); + Assert.That(hbmDynamicComponent.Properties.Select(x=> x.Name), Is.EquivalentTo(new [] {"MyInt", "MyDate"})); } [Test] @@ -51,7 +51,7 @@ public void WhenMapDynCompoPropertiesThenShouldAssignPropertyType() var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Person) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmDynamicComponent = hbmClass.Properties.OfType().Single(); - hbmDynamicComponent.Properties.OfType().Select(x => x.type1).All(x=> x.Satisfy(value=> !string.IsNullOrEmpty(value))); + Assert.That(hbmDynamicComponent.Properties.OfType().All(x => !string.IsNullOrEmpty(x.type1)), Is.True); } [Test] @@ -62,23 +62,23 @@ public void WhenMapDynCompoAttributesThenMapAttributes() { map.Id(x => x.Id, idmap => { }); map.Component(x => x.Info, new { MyInt = 5}, z => - { + { z.Access(Accessor.Field); z.Insert(false); z.Update(false); z.Unique(true); z.OptimisticLock(false); - }); + }); }); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Person) }); var hbmClass = hbmMapping.RootClasses[0]; var hbmDynamicComponent = hbmClass.Properties.OfType().SingleOrDefault(); - hbmDynamicComponent.access.Should().Contain("field"); - hbmDynamicComponent.insert.Should().Be.False(); - hbmDynamicComponent.update.Should().Be.False(); - hbmDynamicComponent.optimisticlock.Should().Be.False(); - hbmDynamicComponent.unique.Should().Be.True(); + Assert.That(hbmDynamicComponent.access, Is.StringContaining("field")); + Assert.That(hbmDynamicComponent.insert, Is.False); + Assert.That(hbmDynamicComponent.update, Is.False); + Assert.That(hbmDynamicComponent.optimisticlock, Is.False); + Assert.That(hbmDynamicComponent.unique, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/IdBagMappingTest.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/IdBagMappingTest.cs index aa1455def93..67fac528f69 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/IdBagMappingTest.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/IdBagMappingTest.cs @@ -32,8 +32,8 @@ public void WhenIdBagWithManyToManyThenMapIt() var hbmMapping = mapper.CompileMappingFor(new[]{ typeof(Animal)}); var hbmClass = hbmMapping.RootClasses[0]; var hbmIdbag = hbmClass.Properties.OfType().SingleOrDefault(); - hbmIdbag.Should().Not.Be.Null(); - hbmIdbag.ElementRelationship.Should().Be.InstanceOf(); + Assert.That(hbmIdbag, Is.Not.Null); + Assert.That(hbmIdbag.ElementRelationship, Is.InstanceOf()); } [Test] @@ -45,7 +45,7 @@ public void WhenIdBagWithOneToManyThenThrow() map.Id(x => x.Id, idmap => { }); map.IdBag(x => x.Children, bag => { }, rel => rel.OneToMany()); }); - mapper.Executing(x=> x.CompileMappingFor(new[] { typeof(Animal) })).Throws(); + Assert.That(() => mapper.CompileMappingFor(new[] { typeof(Animal) }), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/MappingOfPrivateMembersOnRootEntity.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/MappingOfPrivateMembersOnRootEntity.cs index 10a83d16b21..8105d89e5b1 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/MappingOfPrivateMembersOnRootEntity.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/MappingOfPrivateMembersOnRootEntity.cs @@ -31,33 +31,32 @@ public void MapClassWithIdAndProperty() }); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.Should().Not.Be.Null(); + Assert.That(hbmClass, Is.Not.Null); var hbmId = hbmClass.Id; - hbmId.Should().Not.Be.Null(); - hbmId.name.Should().Be("id"); - hbmId.access.Should().Be("field"); + Assert.That(hbmId, Is.Not.Null); + Assert.That(hbmId.name, Is.EqualTo("id")); + Assert.That(hbmId.access, Is.EqualTo("field")); var hbmGenerator = hbmId.generator; - hbmGenerator.Should().Not.Be.Null(); - hbmGenerator.@class.Should().Be("hilo"); - hbmGenerator.param[0].name.Should().Be("max_low"); - hbmGenerator.param[0].GetText().Should().Be("100"); + Assert.That(hbmGenerator, Is.Not.Null); + Assert.That(hbmGenerator.@class, Is.EqualTo("hilo")); + Assert.That(hbmGenerator.param[0].name, Is.EqualTo("max_low")); + Assert.That(hbmGenerator.param[0].GetText(), Is.EqualTo("100")); var hbmVersion = hbmClass.Version; - hbmVersion.name.Should().Be("version"); + Assert.That(hbmVersion.name, Is.EqualTo("version")); var hbmProperty = hbmClass.Properties.OfType().Single(); - hbmProperty.name.Should().Be("something"); - hbmProperty.access.Should().Be("field"); - hbmProperty.length.Should().Be("150"); + Assert.That(hbmProperty.name, Is.EqualTo("something")); + Assert.That(hbmProperty.access, Is.EqualTo("field")); + Assert.That(hbmProperty.length, Is.EqualTo("150")); } [Test] public void WhenPrivateMemberDoesNotExistsThenThrow() { var mapper = new ModelMapper(); - Executing.This(() => - mapper.Class(ca => + Assert.That(() => mapper.Class(ca => { ca.Property("pizza", map => map.Length(150)); - })).Should().Throw(); + }), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NaturalIdTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NaturalIdTests.cs index 88f6f622515..35b81ce9bd2 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NaturalIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NaturalIdTests.cs @@ -39,17 +39,17 @@ public void WhenDefineNaturalIdThenRegister() nidm.Property(x => x.Name); nidm.ManyToOne(x => x.Related); nidm.Component(x => x.MyComponent, cmap => - { + { cmap.Property(y => y.FirstName); - }); + }); nidm.Any(x => x.Any, typeof(int), anymap => { }); }); }); - inspector.IsMemberOfNaturalId(For.Property(x => x.Name)).Should().Be.True(); - inspector.IsMemberOfNaturalId(For.Property(x => x.Related)).Should().Be.True(); - inspector.IsMemberOfNaturalId(For.Property(x => x.MyComponent)).Should().Be.True(); - inspector.IsMemberOfNaturalId(For.Property(x => x.Any)).Should().Be.True(); + Assert.That(inspector.IsMemberOfNaturalId(For.Property(x => x.Name)), Is.True); + Assert.That(inspector.IsMemberOfNaturalId(For.Property(x => x.Related)), Is.True); + Assert.That(inspector.IsMemberOfNaturalId(For.Property(x => x.MyComponent)), Is.True); + Assert.That(inspector.IsMemberOfNaturalId(For.Property(x => x.Any)), Is.True); } [Test] @@ -63,7 +63,7 @@ public void WhenDefineEmptyNaturalIdThenNoMapIt() }); var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmMapping.RootClasses[0]; - hbmClass.naturalid.Should().Be.Null(); + Assert.That(hbmClass.naturalid, Is.Null); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NestedComponetsTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NestedComponetsTests.cs index ec16ba5335d..0a8a4f926f5 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NestedComponetsTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/NestedComponetsTests.cs @@ -32,21 +32,21 @@ private HbmMapping GetMappingWithManyToOneInCompo() { var mapper = new ModelMapper(); mapper.Class(x => - { - x.Id(c => c.Id); - x.Component(c => c.Compo); - x.Bag(c => c.Compos, cm => { }); - }); + { + x.Id(c => c.Id); + x.Component(c => c.Compo); + x.Bag(c => c.Compos, cm => { }); + }); mapper.Component(x => - { - x.ManyToOne(c => c.AManyToOne); - x.Component(c => c.NestedCompo); - }); + { + x.ManyToOne(c => c.AManyToOne); + x.Component(c => c.NestedCompo); + }); mapper.Component(x => - { - x.Component(c => c.Owner); - x.Property(c => c.Something); - }); + { + x.Component(c => c.Owner); + x.Property(c => c.Something); + }); return mapper.CompileMappingForAllExplicitlyAddedEntities(); } @@ -81,9 +81,9 @@ public void WhenMapComoponetWithNestBidirectionalComponentThenMapParent() var hbmMyCompo = hbmClass.Properties.OfType().Single(); var hbmMyNestedCompo = hbmMyCompo.Properties.OfType().Single(); - hbmMyNestedCompo.Properties.Should().Have.Count.EqualTo(1); - hbmMyNestedCompo.Parent.Should().Not.Be.Null(); - hbmMyNestedCompo.Parent.name.Should().Be("Owner"); + Assert.That(hbmMyNestedCompo.Properties.Count(), Is.EqualTo(1)); + Assert.That(hbmMyNestedCompo.Parent, Is.Not.Null); + Assert.That(hbmMyNestedCompo.Parent.name, Is.EqualTo("Owner")); } [Test] @@ -97,9 +97,9 @@ public void WhenCollectionOfComoponetsWithNestBidirectionalComponentThenMapParen var hbmMyCompo = (HbmCompositeElement)hbmBag.ElementRelationship; var hbmMyNestedCompo = hbmMyCompo.Properties.OfType().Single(); - hbmMyNestedCompo.Properties.Should().Have.Count.EqualTo(1); - hbmMyNestedCompo.Parent.Should().Not.Be.Null(); - hbmMyNestedCompo.Parent.name.Should().Be("Owner"); + Assert.That(hbmMyNestedCompo.Properties.Count(), Is.EqualTo(1)); + Assert.That(hbmMyNestedCompo.Parent, Is.Not.Null); + Assert.That(hbmMyNestedCompo.Parent.name, Is.EqualTo("Owner")); } [Test] @@ -109,8 +109,8 @@ public void WhenMapComoponetWithManyToOneThenMapManyToOne() var hbmClass = mapping.RootClasses[0]; var hbmMyCompo = hbmClass.Properties.OfType().Single(); - hbmMyCompo.Properties.OfType().Should().Have.Count.EqualTo(1); - hbmMyCompo.Parent.Should().Be.Null(); + Assert.That(hbmMyCompo.Properties.OfType().Count(), Is.EqualTo(1)); + Assert.That(hbmMyCompo.Parent, Is.Null); } [Test] @@ -122,8 +122,8 @@ public void WhenCollectionOfComoponetsWithManyToOneThenMapManyToOne() var hbmBag = hbmClass.Properties.OfType().Single(); var hbmMyCompo = (HbmCompositeElement)hbmBag.ElementRelationship; - hbmMyCompo.Properties.OfType().Should().Have.Count.EqualTo(1); - hbmMyCompo.Parent.Should().Be.Null(); + Assert.That(hbmMyCompo.Properties.OfType().Count(), Is.EqualTo(1)); + Assert.That(hbmMyCompo.Parent, Is.Null); } [Test] @@ -133,9 +133,9 @@ public void WhenMapComoponetWithParentThenMapParent() var hbmClass = mapping.RootClasses[0]; var hbmMyCompo = hbmClass.Properties.OfType().Single(); - hbmMyCompo.Properties.OfType().Should().Be.Empty(); - hbmMyCompo.Parent.Should().Not.Be.Null(); - hbmMyCompo.Parent.name.Should().Be("AManyToOne"); + Assert.That(hbmMyCompo.Properties.OfType(), Is.Empty); + Assert.That(hbmMyCompo.Parent, Is.Not.Null); + Assert.That(hbmMyCompo.Parent.name, Is.EqualTo("AManyToOne")); } [Test] @@ -147,9 +147,9 @@ public void WhenCollectionOfComoponetsWithParentThenMapParent() var hbmBag = hbmClass.Properties.OfType().Single(); var hbmMyCompo = (HbmCompositeElement)hbmBag.ElementRelationship; - hbmMyCompo.Properties.OfType().Should().Be.Empty(); - hbmMyCompo.Parent.Should().Not.Be.Null(); - hbmMyCompo.Parent.name.Should().Be("AManyToOne"); + Assert.That(hbmMyCompo.Properties.OfType(), Is.Empty); + Assert.That(hbmMyCompo.Parent, Is.Not.Null); + Assert.That(hbmMyCompo.Parent.name, Is.EqualTo("AManyToOne")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/PoidTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/PoidTests.cs index 1f28f50a017..9877b5e9b1c 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/PoidTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/PoidTests.cs @@ -18,7 +18,7 @@ public void WhenPropertyUsedAsPoidThenRegister() var mapper = new ModelMapper(inspector); mapper.Class(map => map.Id(x => x.Id, idmap => { })); - inspector.IsPersistentId(For.Property(x => x.Id)).Should().Be.True(); + Assert.That(inspector.IsPersistentId(For.Property(x => x.Id)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/RootClassPropertiesSplitsTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/RootClassPropertiesSplitsTests.cs index 8891176166c..a407efeb333 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/RootClassPropertiesSplitsTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/RootClassPropertiesSplitsTests.cs @@ -40,7 +40,7 @@ public void WhenSplittedPropertiesThenRegisterSplitGroupIds() }); IEnumerable tablePerClassSplits = inspector.GetPropertiesSplits(typeof(MyClass)); - tablePerClassSplits.Should().Have.SameValuesAs("MyClassSplit1", "MyClassSplit2"); + Assert.That(tablePerClassSplits, Is.EquivalentTo(new [] {"MyClassSplit1", "MyClassSplit2"})); } [Test] @@ -64,13 +64,13 @@ public void WhenSplittedPropertiesThenRegister() map.Property(x => x.Something0); }); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.Something0)).Should().Be.False(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.Something0)).Should().Be.False(); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.Something0)), Is.False); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.Something0)), Is.False); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA1)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA2)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB1)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB2)).Should().Be.True(); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA1)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA2)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB1)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB2)), Is.True); } [Test] @@ -96,12 +96,12 @@ public void WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup() var hbmDoc = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = hbmDoc.RootClasses[0]; - hbmClass.Joins.Select(j => j.table).Should().Have.SameValuesAs("MyClassSplit1", "MyClassSplit2"); - hbmClass.Properties.Single().Name.Should().Be("Something0"); + Assert.That(hbmClass.Joins.Select(j => j.table), Is.EquivalentTo(new [] {"MyClassSplit1", "MyClassSplit2"})); + Assert.That(hbmClass.Properties.Single().Name, Is.EqualTo("Something0")); var hbmSplit1 = hbmClass.Joins.Single(j => "MyClassSplit1" == j.table); - hbmSplit1.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingA1", "SomethingA2"); + Assert.That(hbmSplit1.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingA1", "SomethingA2"})); var hbmSplit2 = hbmClass.Joins.Single(j => "MyClassSplit2" == j.table); - hbmSplit2.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingB1", "SomethingB2"); + Assert.That(hbmSplit2.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingB1", "SomethingB2"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/SubclassPropertiesSplitsTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/SubclassPropertiesSplitsTests.cs index cd46b21139e..50263a118ae 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/SubclassPropertiesSplitsTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/SubclassPropertiesSplitsTests.cs @@ -43,7 +43,7 @@ public void WhenSplittedPropertiesThenRegisterSplitGroupIds() }); IEnumerable tablePerClassSplits = inspector.GetPropertiesSplits(typeof(Inherited)); - tablePerClassSplits.Should().Have.SameValuesAs("MyClassSplit1", "MyClassSplit2"); + Assert.That(tablePerClassSplits, Is.EquivalentTo(new [] {"MyClassSplit1", "MyClassSplit2"})); } [Test] @@ -66,13 +66,13 @@ public void WhenSplittedPropertiesThenRegister() map.Property(x => x.Something0); }); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.Something0)).Should().Be.False(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.Something0)).Should().Be.False(); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.Something0)), Is.False); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.Something0)), Is.False); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA1)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA2)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB1)).Should().Be.True(); - inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB2)).Should().Be.True(); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA1)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For.Property(x => x.SomethingA2)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB1)), Is.True); + Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For.Property(x => x.SomethingB2)), Is.True); } [Test] @@ -98,12 +98,12 @@ public void WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup() var hbmDoc = mapper.CompileMappingFor(new[] { typeof(Inherited) }); var hbmClass = hbmDoc.SubClasses[0]; - hbmClass.Joins.Select(j => j.table).Should().Have.SameValuesAs("MyClassSplit1", "MyClassSplit2"); - hbmClass.Properties.Single().Name.Should().Be("Something0"); + Assert.That(hbmClass.Joins.Select(j => j.table), Is.EquivalentTo(new [] {"MyClassSplit1", "MyClassSplit2"})); + Assert.That(hbmClass.Properties.Single().Name, Is.EqualTo("Something0")); var hbmSplit1 = hbmClass.Joins.Single(j => "MyClassSplit1" == j.table); - hbmSplit1.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingA1", "SomethingA2"); + Assert.That(hbmSplit1.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingA1", "SomethingA2"})); var hbmSplit2 = hbmClass.Joins.Single(j => "MyClassSplit2" == j.table); - hbmSplit2.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingB1", "SomethingB2"); + Assert.That(hbmSplit2.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingB1", "SomethingB2"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/VersionTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/VersionTests.cs index 930d676076d..0f36c27cf96 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/VersionTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitMappingTests/VersionTests.cs @@ -27,7 +27,7 @@ public void WhenPropertyUsedAsVersionThenRegister() map.Version(x => x.Version, vm => { }); }); - inspector.IsVersion(For.Property(x => x.Version)).Should().Be.True(); + Assert.That(inspector.IsVersion(For.Property(x => x.Version)), Is.True); } [Test] @@ -42,7 +42,7 @@ public void WhenPropertyVersionFromBaseEntityThenFindItAsVersion() map.Version(x => x.Version, vm => { }); }); - inspector.IsVersion(For.Property(x => x.Version)).Should().Be.True(); + Assert.That(inspector.IsVersion(For.Property(x => x.Version)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs index b7403d9368d..1be9986a58b 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs @@ -17,7 +17,7 @@ public void WhenRegisteredAsComponentThenIsRegistered() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof(MyComponent)); - inspector.IsComponent(typeof(MyComponent)).Should().Be.True(); + Assert.That(inspector.IsComponent(typeof(MyComponent)), Is.True); } [Test] @@ -26,7 +26,7 @@ public void WhenRegisteredAsEntityThenCantRegisterAsComponent() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyComponent)); - inspector.Executing(x => x.AddAsComponent(typeof(MyComponent))).Throws(); + Assert.That(() => inspector.AddAsComponent(typeof(MyComponent)), Throws.TypeOf()); } [Test] @@ -35,7 +35,7 @@ public void WhenRegisteredAsComponetThenCantRegisterAsRootEntity() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof(MyComponent)); - inspector.Executing(x => x.AddAsRootEntity(typeof(MyComponent))).Throws(); + Assert.That(() => inspector.AddAsRootEntity(typeof(MyComponent)), Throws.TypeOf()); } [Test] @@ -44,11 +44,11 @@ public void WhenRegisteredAsComponetThenCantRegisterAsJoinedSubclass() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof (MyComponent)); - Executing.This(() => - { - inspector.AddAsTablePerClassEntity(typeof (MyComponent)); - inspector.IsTablePerClass(typeof (MyComponent)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassEntity(typeof (MyComponent)); + inspector.IsTablePerClass(typeof (MyComponent)); + }, Throws.TypeOf()); } [Test] @@ -57,11 +57,11 @@ public void WhenRegisteredAsComponetThenCantRegisterAsSubclass() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof (MyComponent)); - Executing.This(() => - { - inspector.AddAsTablePerClassHierarchyEntity(typeof (MyComponent)); - inspector.IsTablePerClassHierarchy(typeof (MyComponent)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassHierarchyEntity(typeof (MyComponent)); + inspector.IsTablePerClassHierarchy(typeof (MyComponent)); + }, Throws.TypeOf()); } [Test] @@ -70,11 +70,11 @@ public void WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsComponent(typeof (MyComponent)); - Executing.This(() => - { - inspector.AddAsTablePerConcreteClassEntity(typeof (MyComponent)); - inspector.IsTablePerConcreteClass(typeof (MyComponent)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerConcreteClassEntity(typeof (MyComponent)); + inspector.IsTablePerConcreteClass(typeof (MyComponent)); + }, Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs index 2427feae85f..861dbd3dee8 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs @@ -26,9 +26,9 @@ public void WhenRegisteredAsJoinedSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.True(); - inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited1)), Is.True); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.False); } [Test] @@ -38,9 +38,9 @@ public void WhenRegisteredAsDeppJoinedSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.True(); - inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited2)), Is.True); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited2)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited2)), Is.False); } [Test] @@ -50,11 +50,11 @@ public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsSubclass() inspector.AddAsRootEntity(typeof (MyClass)); inspector.AddAsTablePerClassEntity(typeof (Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1)); - inspector.IsTablePerClass(typeof (Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1)); + inspector.IsTablePerClass(typeof (Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -64,11 +64,11 @@ public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsUnionSubclass() inspector.AddAsRootEntity(typeof (MyClass)); inspector.AddAsTablePerClassEntity(typeof (Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); - inspector.IsTablePerClass(typeof (Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); + inspector.IsTablePerClass(typeof (Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -78,7 +78,7 @@ public void WhenRegisteredAsJoinedSubclassThenIsEntity() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.IsEntity(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs index ff85f5b23f5..7cf9dc9754f 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs @@ -22,7 +22,7 @@ public void WhenRegisterJoinedSubclassBeforeRootThenIsRegistered() inspector.AddAsTablePerClassEntity(typeof(Inherited1)); inspector.AddAsRootEntity(typeof(MyClass)); - inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited1)), Is.True); } [Test] @@ -31,7 +31,7 @@ public void WhenRegisterJoinedSubclassWithNoRootThenThrows() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.Executing(x => x.IsTablePerClass(typeof(Inherited1))).Throws(); + Assert.That(() => inspector.IsTablePerClass(typeof(Inherited1)), Throws.TypeOf()); } [Test] @@ -40,7 +40,7 @@ public void WhenRegisterJoinedSubclassWithNoRootThenCanAskForIsEntity() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.IsEntity(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs index 6a61f63d9b2..a7e64cc83b4 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs @@ -24,9 +24,9 @@ public void WhenRegisteredAsRootThenDoesNotRegisterTheStrategy() { var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False); } [Test] @@ -35,9 +35,9 @@ public void WhenRegisteredJoinedSubclassThenTheStrategyIsDefinedEvenForRoot() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.True); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False); } [Test] @@ -46,9 +46,9 @@ public void WhenRegisteredJoinedDeepSubclassThenTheStrategyIsDefinedEvenForRoot( var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.True); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False); } [Test] @@ -57,9 +57,9 @@ public void WhenRegisteredSubclassThenTheStrategyIsDefinedEvenForRoot() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.True); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False); } [Test] @@ -69,9 +69,9 @@ public void WhenRegisteredDeepSubclassThenTheStrategyIsDefinedEvenForRoot() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.True); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False); } @@ -82,9 +82,9 @@ public void WhenRegisteredConcreteClassThenTheStrategyIsDefinedEvenForRoot() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.True); } [Test] @@ -94,9 +94,9 @@ public void WhenRegisteredDeepConcreteClassThenTheStrategyIsDefinedEvenForRoot() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.True); } [Test] @@ -104,11 +104,11 @@ public void WhenRegisteredAsRootThenCantRegisterAsSubclass() { var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof (MyClass)); - Executing.This(() => - { - inspector.AddAsTablePerClassHierarchyEntity(typeof (MyClass)); - inspector.IsTablePerClassHierarchy(typeof (MyClass)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassHierarchyEntity(typeof (MyClass)); + inspector.IsTablePerClassHierarchy(typeof (MyClass)); + }, Throws.TypeOf()); } [Test] @@ -116,11 +116,11 @@ public void WhenRegisteredAsRootThenCantRegisterAsJoinedSubclass() { var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof (MyClass)); - Executing.This(() => - { - inspector.AddAsTablePerClassEntity(typeof (MyClass)); - inspector.IsTablePerClass(typeof (MyClass)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassEntity(typeof (MyClass)); + inspector.IsTablePerClass(typeof (MyClass)); + }, Throws.TypeOf()); } [Test] @@ -128,11 +128,11 @@ public void WhenRegisteredAsRootThenCantRegisterAsUnionSubclass() { var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof (MyClass)); - Executing.This(() => - { - inspector.AddAsTablePerConcreteClassEntity(typeof (MyClass)); - inspector.IsTablePerClass(typeof (MyClass)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerConcreteClassEntity(typeof (MyClass)); + inspector.IsTablePerClass(typeof (MyClass)); + }, Throws.TypeOf()); } [Test] @@ -141,7 +141,7 @@ public void WhenRegisteredAsRootThenIsEntity() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); - inspector.IsEntity(typeof(MyClass)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(MyClass)), Is.True); } [Test] @@ -150,11 +150,11 @@ public void WhenMultipleRootRegisteredThenThrowsMappingException() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsRootEntity(typeof(Inherited1)); - Executing.This(()=> - { - inspector.AddAsTablePerClassEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(Inherited2)); - }).Should().Throw(); + Assert.That(()=> + { + inspector.AddAsTablePerClassEntity(typeof(Inherited2)); + inspector.IsTablePerClass(typeof(Inherited2)); + }, Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SplitPropertiesRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SplitPropertiesRegistrationTests.cs index c84f682ed34..746e9940e54 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SplitPropertiesRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SplitPropertiesRegistrationTests.cs @@ -23,8 +23,8 @@ public void WhenRegisterPropertySplitsThenTypeHasSplitGroups() inspector.AddAsPropertySplit(new SplitDefinition(typeof(MyClass), "group", For.Property(x => x.Something))); inspector.AddAsPropertySplit(new SplitDefinition(typeof(Inherited), "group1", For.Property(x => x.SomethingElse))); - inspector.GetSplitGroupsFor(typeof(MyClass)).Should().Have.SameValuesAs("group"); - inspector.GetSplitGroupsFor(typeof(Inherited)).Should().Have.SameValuesAs("group1"); + Assert.That(inspector.GetSplitGroupsFor(typeof(MyClass)), Is.EquivalentTo(new [] {"group"})); + Assert.That(inspector.GetSplitGroupsFor(typeof(Inherited)), Is.EquivalentTo(new [] {"group1"})); } [Test] @@ -37,11 +37,11 @@ public void WhenRegisterPropertySplitMoreThanOnceThenIgnore() inspector.AddAsPropertySplit(new SplitDefinition(typeof(MyClass), "group", memberFromDeclaringType)); inspector.AddAsPropertySplit(new SplitDefinition(typeof(Inherited), "group1", memberFromReferencedType)); - inspector.GetSplitGroupsFor(typeof(MyClass)).Should().Have.SameValuesAs("group"); - inspector.GetSplitGroupsFor(typeof(Inherited)).Should().Be.Empty(); + Assert.That(inspector.GetSplitGroupsFor(typeof(MyClass)), Is.EquivalentTo(new [] {"group"})); + Assert.That(inspector.GetSplitGroupsFor(typeof(Inherited)), Is.Empty); - inspector.GetSplitGroupFor(memberFromDeclaringType).Should().Be("group"); - inspector.GetSplitGroupFor(memberFromReferencedType).Should().Be("group"); + Assert.That(inspector.GetSplitGroupFor(memberFromDeclaringType), Is.EqualTo("group")); + Assert.That(inspector.GetSplitGroupFor(memberFromReferencedType), Is.EqualTo("group")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs index 411865b093f..55846df1675 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs @@ -26,9 +26,9 @@ public void WhenRegisteredAsSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True(); - inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited1)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Is.True); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.False); } [Test] @@ -38,9 +38,9 @@ public void WhenRegisteredAsDeepSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True(); - inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited2)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited2)), Is.True); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited2)), Is.False); } [Test] @@ -50,11 +50,11 @@ public void WhenRegisteredAsSubclassThenCantRegisterAsJoinedSubclass() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerClassEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassEntity(typeof(Inherited1)); + inspector.IsTablePerClass(typeof(Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -64,11 +64,11 @@ public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass() inspector.AddAsRootEntity(typeof (MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); - inspector.IsTablePerClassHierarchy(typeof (Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); + inspector.IsTablePerClassHierarchy(typeof (Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -78,7 +78,7 @@ public void WhenRegisteredAsSubclassThenIsEntity() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); - inspector.IsEntity(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs index c2d05808fe5..d8b08c63f1d 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs @@ -22,7 +22,7 @@ public void WhenRegisterSubclassBeforeRootThenIsRegistered() inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); inspector.AddAsRootEntity(typeof(MyClass)); - inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Is.True); } [Test] @@ -31,7 +31,7 @@ public void WhenRegisterSubclassWithNoRootThenThrows() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1)); - inspector.Executing(x => x.IsTablePerClassHierarchy(typeof(Inherited1))).Throws(); + Assert.That(() => inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs index 12d135c4318..559d9f9dd34 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs @@ -26,9 +26,9 @@ public void WhenRegisteredAsUnionSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1)); - inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited1)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.True); } [Test] @@ -38,9 +38,9 @@ public void WhenRegisteredAsDeepUnionSubclassThenIsRegistered() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited2)); - inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False(); - inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False(); - inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(Inherited2)), Is.False); + Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited2)), Is.False); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited2)), Is.True); } [Test] @@ -50,11 +50,11 @@ public void WhenRegisteredAsUnionSubclassThenCantRegisterAsSubclass() inspector.AddAsRootEntity(typeof (MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1)); - inspector.IsTablePerConcreteClass(typeof (Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1)); + inspector.IsTablePerConcreteClass(typeof (Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -64,11 +64,11 @@ public void WhenRegisteredAsUnionSubclassThenCantRegisterAsJoinedSubclass() inspector.AddAsRootEntity(typeof (MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1)); - Executing.This(() => - { - inspector.AddAsTablePerClassEntity(typeof (Inherited1)); - inspector.IsTablePerConcreteClass(typeof (Inherited1)); - }).Should().Throw(); + Assert.That(() => + { + inspector.AddAsTablePerClassEntity(typeof (Inherited1)); + inspector.IsTablePerConcreteClass(typeof (Inherited1)); + }, Throws.TypeOf()); } [Test] @@ -78,7 +78,7 @@ public void WhenRegisteredAsUnionSubclassThenIsEntity() inspector.AddAsRootEntity(typeof(MyClass)); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1)); - inspector.IsEntity(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs index 6e849c1909e..f883c649b9d 100644 --- a/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs +++ b/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs @@ -22,7 +22,7 @@ public void WhenRegisterUnionSubclassBeforeRootThenIsRegistered() inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1)); inspector.AddAsRootEntity(typeof(MyClass)); - inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.True(); + Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.True); } [Test] @@ -31,7 +31,7 @@ public void WhenRegisterUnionSubclassWithNoRootThenThrows() var inspector = new ExplicitlyDeclaredModel(); inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1)); - inspector.Executing(x => x.IsTablePerConcreteClass(typeof(Inherited1))).Throws(); + Assert.That(() => inspector.IsTablePerConcreteClass(typeof(Inherited1)), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ImportTests.cs b/src/NHibernate.Test/MappingByCode/ImportTests.cs index 397f69d7ef7..fd904f8faff 100644 --- a/src/NHibernate.Test/MappingByCode/ImportTests.cs +++ b/src/NHibernate.Test/MappingByCode/ImportTests.cs @@ -23,13 +23,13 @@ public void ImportClass() var hbmMapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); - hbmMapping.Imports.Length.Should().Be.EqualTo(2); + Assert.That(hbmMapping.Imports.Length, Is.EqualTo(2)); - hbmMapping.Imports[0].@class.Should().Be.EqualTo("Dto"); - hbmMapping.Imports[0].rename.Should().Be.EqualTo("Dto"); + Assert.That(hbmMapping.Imports[0].@class, Is.EqualTo("Dto")); + Assert.That(hbmMapping.Imports[0].rename, Is.EqualTo("Dto")); - hbmMapping.Imports[1].@class.Should().Be.EqualTo("Dto"); - hbmMapping.Imports[1].rename.Should().Be.EqualTo("DtoRenamed"); + Assert.That(hbmMapping.Imports[1].@class, Is.EqualTo("Dto")); + Assert.That(hbmMapping.Imports[1].rename, Is.EqualTo("DtoRenamed")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/IntegrationTests/NH2738/Fixture.cs b/src/NHibernate.Test/MappingByCode/IntegrationTests/NH2738/Fixture.cs index 497caacc194..9795468108a 100644 --- a/src/NHibernate.Test/MappingByCode/IntegrationTests/NH2738/Fixture.cs +++ b/src/NHibernate.Test/MappingByCode/IntegrationTests/NH2738/Fixture.cs @@ -21,15 +21,15 @@ public void WhenMapEmptyEnumThenThrowsExplicitException() { var mapper = new ModelMapper(); mapper.Class(rc => - { + { rc.Id(x => x.Id); rc.Property(x => x.MyEmptyEnum); - }); + }); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); var conf = TestConfigurationHelper.GetDefaultConfiguration(); conf.AddMapping(mappings); - conf.Executing(c => c.BuildSessionFactory()).Throws().And.ValueOf.Message.Should().Contain("MyEmptyEnum"); + Assert.That(() => conf.BuildSessionFactory(), Throws.TypeOf().And.Message.ContainsSubstring("MyEmptyEnum")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/AbstractPropertyContainerMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/AbstractPropertyContainerMapperTest.cs index 10c54484411..656e91cc4d6 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/AbstractPropertyContainerMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/AbstractPropertyContainerMapperTest.cs @@ -41,13 +41,13 @@ private class MyClassWithDynamic [Test] public void CantCreateWithoutHbmMapping() { - Executing.This(() => new HackPropertyContainerMapper(typeof(EntitySimple), null)).Should().Throw(); + Assert.That(() => new HackPropertyContainerMapper(typeof(EntitySimple), null), Throws.TypeOf()); } [Test] public void CantCreateWithoutContainerType() { - Executing.This(() => new HackPropertyContainerMapper(null, new HbmMapping())).Should().Throw(); + Assert.That(() => new HackPropertyContainerMapper(null, new HbmMapping()), Throws.TypeOf()); } [Test] @@ -57,8 +57,8 @@ public void CanAddSimpleProperty() var map = new StubPropertyContainerMapper(properties); map.Property(typeof (EntitySimple).GetProperty("Name"), x => { }); - properties.Should().Have.Count.EqualTo(1); - properties.First().Should().Be.OfType().And.ValueOf.Name.Should().Be.EqualTo("Name"); + Assert.That(properties, Has.Count.EqualTo(1)); + Assert.That(properties.First(), Is.TypeOf().And.Property("Name").EqualTo("Name")); } [Test] @@ -69,14 +69,14 @@ public void CallPropertyMapper() var called = false; map.Property(typeof(EntitySimple).GetProperty("Name"), x => called = true ); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] public void CantAddPropertyOfNotInheritedType() { var map = new StubPropertyContainerMapper(new List()); - Executing.This(() => map.Property(typeof(EntitySimple).GetProperty("Name"), x => { })).Should().Throw(); + Assert.That(() => map.Property(typeof(EntitySimple).GetProperty("Name"), x => { }), Throws.TypeOf()); } [Test] @@ -86,8 +86,8 @@ public void CanAddPropertyOfInheritedType() var map = new StubPropertyContainerMapper(properties); map.Property(typeof(InheritedEntitySimple).GetProperty("Name"), x => { }); - properties.Should().Have.Count.EqualTo(1); - properties.First().Should().Be.OfType().And.ValueOf.Name.Should().Be.EqualTo("Name"); + Assert.That(properties, Has.Count.EqualTo(1)); + Assert.That(properties.First(), Is.TypeOf().And.Property("Name").EqualTo("Name")); } [Test] @@ -98,7 +98,7 @@ public void CallAnyMapper() var called = false; map.Any(typeof(MyClass).GetProperty("Reference"), typeof(int), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -110,11 +110,11 @@ public void CallDictionaryMappers() var keyRelationCalled = false; var elementRelationCalled = false; map.Map(typeof (MyClassWithDictionary).GetProperty("Dictionary"), cp => collectionPropsCalled = true, - km => keyRelationCalled = true, er => elementRelationCalled = true); + km => keyRelationCalled = true, er => elementRelationCalled = true); - collectionPropsCalled.Should().Be.True(); - keyRelationCalled.Should().Be.True(); - elementRelationCalled.Should().Be.True(); + Assert.That(collectionPropsCalled, Is.True); + Assert.That(keyRelationCalled, Is.True); + Assert.That(elementRelationCalled, Is.True); } [Test] @@ -123,7 +123,7 @@ public void AddDynamicComponentProperty() var properties = new List(); var map = new StubPropertyContainerMapper(properties); map.Component(For.Property(x => x.DynCompo), (IDynamicComponentMapper cp) => { }); - properties.Single().Should().Be.OfType().And.ValueOf.Name.Should().Be.EqualTo("DynCompo"); + Assert.That(properties.Single(), Is.TypeOf().And.Property("Name").EqualTo("DynCompo")); } [Test] @@ -133,7 +133,7 @@ public void CallDynamicComponentMapper() var map = new StubPropertyContainerMapper(properties); var called = false; map.Component(For.Property(x=> x.DynCompo), (IDynamicComponentMapper cp) => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } private class HackPropertyContainerMapper : AbstractPropertyContainerMapper diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/AnyMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/AnyMapperTest.cs index 2197db9bb57..c74b5310c48 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/AnyMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/AnyMapperTest.cs @@ -26,7 +26,7 @@ public void AtCreationSetIdType() var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); new AnyMapper(null, typeof(int), hbmAny, hbmMapping); - hbmAny.idtype.Should().Be("Int32"); + Assert.That(hbmAny.idtype, Is.EqualTo("Int32")); } [Test] @@ -35,8 +35,8 @@ public void AtCreationSetTheTwoRequiredColumnsNodes() var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); new AnyMapper(null, typeof(int), hbmAny, hbmMapping); - hbmAny.Columns.Should().Have.Count.EqualTo(2); - hbmAny.Columns.Select(c => c.name).All(n => n.Satisfy(name => !string.IsNullOrEmpty(name))); + Assert.That(hbmAny.Columns.Count(), Is.EqualTo(2)); + Assert.That(hbmAny.Columns.All(c => !string.IsNullOrEmpty(c.name)), Is.True); } [Test] @@ -46,7 +46,7 @@ public void CanSetIdTypeThroughIType() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.IdType(NHibernateUtil.Int64); - hbmAny.idtype.Should().Be("Int64"); + Assert.That(hbmAny.idtype, Is.EqualTo("Int64")); } [Test] @@ -56,7 +56,7 @@ public void CanSetIdTypeThroughGenericMethod() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.IdType(); - hbmAny.idtype.Should().Be("Int64"); + Assert.That(hbmAny.idtype, Is.EqualTo("Int64")); } [Test] @@ -66,7 +66,7 @@ public void CanSetIdTypeThroughType() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.IdType(typeof(long)); - hbmAny.idtype.Should().Be("Int64"); + Assert.That(hbmAny.idtype, Is.EqualTo("Int64")); } [Test] @@ -76,7 +76,7 @@ public void CanSetMetaTypeThroughIType() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(NHibernateUtil.Character); - hbmAny.MetaType.Should().Be("Char"); + Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); } [Test] @@ -86,7 +86,7 @@ public void CanSetMetaTypeThroughGenericMethod() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(); - hbmAny.MetaType.Should().Be("Char"); + Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); } [Test] @@ -96,7 +96,7 @@ public void CanSetMetaTypeThroughType() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(typeof(char)); - hbmAny.MetaType.Should().Be("Char"); + Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); } [Test] @@ -106,7 +106,7 @@ public void CanSetCascade() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.All); - hbmAny.cascade.Should().Be("all"); + Assert.That(hbmAny.cascade, Is.EqualTo("all")); } [Test] @@ -116,7 +116,7 @@ public void AutoCleanInvalidCascade() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.All | Mapping.ByCode.Cascade.DeleteOrphans); - hbmAny.cascade.Should().Be("all"); + Assert.That(hbmAny.cascade, Is.EqualTo("all")); } [Test] @@ -126,7 +126,7 @@ public void CanSetIndex() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Index("pizza"); - hbmAny.index.Should().Be("pizza"); + Assert.That(hbmAny.index, Is.EqualTo("pizza")); } [Test] @@ -136,7 +136,7 @@ public void CanSetLazy() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Lazy(true); - hbmAny.lazy.Should().Be(true); + Assert.That(hbmAny.lazy, Is.EqualTo(true)); } [Test] @@ -149,8 +149,8 @@ public void WhenSetIdColumnPropertiesThenWorkOnSameHbmColumnCreatedAtCtor() var columnsBefore = hbmAny.Columns.ToArray(); mapper.Columns(idcm => idcm.Length(10), metacm => { }); var columnsAfter = hbmAny.Columns.ToArray(); - columnsBefore[idColumnIndex].Should().Be.SameInstanceAs(columnsAfter[idColumnIndex]); - columnsBefore[idColumnIndex].length.Should().Be("10"); + Assert.That(columnsBefore[idColumnIndex], Is.SameAs(columnsAfter[idColumnIndex])); + Assert.That(columnsBefore[idColumnIndex].length, Is.EqualTo("10")); } [Test] @@ -164,8 +164,8 @@ public void WhenSetMetaColumnPropertiesThenWorkOnSameHbmColumnCreatedAtCtor() var columnsBefore = hbmAny.Columns.ToArray(); mapper.Columns(idcm => { }, metacm => metacm.Length(500)); var columnsAfter = hbmAny.Columns.ToArray(); - columnsBefore[metaValueColumnIndex].Should().Be.SameInstanceAs(columnsAfter[metaValueColumnIndex]); - columnsBefore[metaValueColumnIndex].length.Should().Be("500"); + Assert.That(columnsBefore[metaValueColumnIndex], Is.SameAs(columnsAfter[metaValueColumnIndex])); + Assert.That(columnsBefore[metaValueColumnIndex].length, Is.EqualTo("500")); } [Test] @@ -175,8 +175,8 @@ public void MetaTypeShouldBeImmutable() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); - Executing.This(() => mapper.MetaType(NHibernateUtil.Int32)).Should().Throw(); - Executing.This(mapper.MetaType).Should().Throw(); + Assert.That(() => mapper.MetaType(NHibernateUtil.Int32), Throws.TypeOf()); + Assert.That(() => mapper.MetaType(), Throws.TypeOf()); } [Test] @@ -185,8 +185,8 @@ public void WhenNullParameterThenThrow() var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); - Executing.This(() => mapper.MetaValue(null, typeof(MyReferenceClass))).Should().Throw(); - Executing.This(() => mapper.MetaValue('A', null)).Should().Throw(); + Assert.That(() => mapper.MetaValue(null, typeof(MyReferenceClass)), Throws.TypeOf()); + Assert.That(() => mapper.MetaValue('A', null), Throws.TypeOf()); } [Test] @@ -196,7 +196,7 @@ public void WhenSetFirstMetaValueThenSetMetaTypeIfNotClass() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); - hbmAny.MetaType.Should().Be("Char"); + Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); } [Test] @@ -205,7 +205,7 @@ public void WhenSetMetaValueWithClassThenThrow() var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); - Executing.This(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass))).Should().Throw(); + Assert.That(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass)), Throws.TypeOf()); } [Test] @@ -215,7 +215,7 @@ public void WhenSetSecondMetaValueThenCheckCompatibility() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); - Executing.This(() => mapper.MetaValue(5, typeof(MyClass))).Should().Throw(); + Assert.That(() => mapper.MetaValue(5, typeof(MyClass)), Throws.TypeOf()); } [Test] @@ -226,7 +226,7 @@ public void WhenDuplicatedMetaValueThenRegisterOne() var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('A', typeof(MyReferenceClass)); - hbmAny.metavalue.Should().Have.Count.EqualTo(1); + Assert.That(hbmAny.metavalue, Has.Length.EqualTo(1)); } [Test] @@ -236,7 +236,7 @@ public void WhenDuplicatedMetaValueWithDifferentTypeThenThrow() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); - Executing.This(() => mapper.MetaValue('A', typeof(MyClass))).Should().Throw(); + Assert.That(() => mapper.MetaValue('A', typeof(MyClass)), Throws.TypeOf()); } [Test] @@ -247,10 +247,10 @@ public void WhenSetTwoMetaValueThenHasTwoMetaValues() var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('B', typeof(MyClass)); - hbmAny.metavalue.Should().Have.Count.EqualTo(2); - hbmAny.metavalue.Select(mv => mv.value).Should().Have.SameValuesAs("A", "B"); - hbmAny.metavalue.Select(mv => mv.@class).Satisfy(c => c.Any(clazz => clazz.Contains("MyReferenceClass"))); - hbmAny.metavalue.Select(mv => mv.@class).Satisfy(c => c.Any(clazz => clazz.Contains("MyClass"))); + Assert.That(hbmAny.metavalue, Has.Length.EqualTo(2)); + Assert.That(hbmAny.metavalue.Select(mv => mv.value), Is.EquivalentTo(new [] {"A", "B"})); + Assert.That(hbmAny.metavalue.Any(mv => mv.@class.Contains("MyReferenceClass")), Is.True); + Assert.That(hbmAny.metavalue.Any(mv => mv.@class.Contains("MyClass")), Is.True); } [Test] @@ -260,8 +260,8 @@ public void AtCreationSetColumnsUsingMemberName() var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); new AnyMapper(member, typeof(int), hbmAny, hbmMapping); - hbmAny.Columns.ElementAt(0).name.Should().Contain("MyReferenceClass"); - hbmAny.Columns.ElementAt(1).name.Should().Contain("MyReferenceClass"); + Assert.That(hbmAny.Columns.ElementAt(0).name, Is.StringContaining("MyReferenceClass")); + Assert.That(hbmAny.Columns.ElementAt(1).name, Is.StringContaining("MyReferenceClass")); } [Test] @@ -271,10 +271,10 @@ public void IdMetaTypeShouldBeImmutableAfterAddMetaValues() var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); - Executing.This(() => mapper.IdType(NHibernateUtil.Int32)).Should().NotThrow(); - Executing.This(mapper.IdType).Should().NotThrow(); - Executing.This(mapper.IdType).Should().Throw(); - Executing.This(() => mapper.IdType(NHibernateUtil.String)).Should().Throw(); + Assert.That(() => mapper.IdType(NHibernateUtil.Int32), Throws.Nothing); + Assert.That(() => mapper.IdType(), Throws.Nothing); + Assert.That(() => mapper.IdType(), Throws.TypeOf()); + Assert.That(() => mapper.IdType(NHibernateUtil.String), Throws.TypeOf()); } [Test] @@ -285,7 +285,7 @@ public void CanSetUpdate() var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Update(false); - hbmAny.update.Should().Be.False(); + Assert.That(hbmAny.update, Is.False); } [Test] @@ -296,7 +296,7 @@ public void CanSetInsert() var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Insert(false); - hbmAny.insert.Should().Be.False(); + Assert.That(hbmAny.insert, Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/CheckMixingPOIDStrategiesTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/CheckMixingPOIDStrategiesTests.cs index e35e7b070a6..eddcdcf5917 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/CheckMixingPOIDStrategiesTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/CheckMixingPOIDStrategiesTests.cs @@ -31,9 +31,7 @@ public void WhenMixComposedIdWithComponentAsIdThenThrows() var mapper = new ClassMapper(typeof (Person), mapdoc, For.Property(x => x.Id)); mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })); - Executing.This(() => - mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })) - ).Should().Throw(); + Assert.That(() => mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })), Throws.TypeOf()); } [Test] @@ -43,9 +41,7 @@ public void WhenMixComponentAsIdWithComposedIdThenThrows() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })); - Executing.This(() => - mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })) - ).Should().Throw(); + Assert.That(() => mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })), Throws.TypeOf()); } [Test] @@ -55,9 +51,7 @@ public void WhenMixComposedIdWithSimpleIdThenThrows() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })); - Executing.This(() => - mapper.Id(For.Property(x => x.Poid), pm => { }) - ).Should().Throw(); + Assert.That(() => mapper.Id(For.Property(x => x.Poid), pm => { }), Throws.TypeOf()); } [Test] @@ -67,9 +61,7 @@ public void WhenMixComponentAsIdWithSimpleIdThenThrows() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })); - Executing.This(() => - mapper.Id(For.Property(x => x.Poid), pm => { }) - ).Should().Throw(); + Assert.That(() => mapper.Id(For.Property(x => x.Poid), pm => { }), Throws.TypeOf()); } [Test] @@ -79,9 +71,7 @@ public void WhenMixSimpleIdWithComposedIdThenThrows() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.Id(For.Property(x => x.Poid), pm => { }); - Executing.This(() => - mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })) - ).Should().Throw(); + Assert.That(() => mapper.ComposedId(map => map.Property(For.Property(x => x.Name), pm => { })), Throws.TypeOf()); } [Test] @@ -91,9 +81,7 @@ public void WhenMixSimpleIdWithComponentAsIdThenThrows() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.Id(For.Property(x => x.Poid), pm => { }); - Executing.This(() => - mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })) - ).Should().Throw(); + Assert.That(() => mapper.ComponentAsId(For.Property(x => x.Id), map => map.Property(For.Property(x => x.Email), pm => { })), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ClassMapperWithJoinPropertiesTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ClassMapperWithJoinPropertiesTest.cs index d8ceed0cc99..4a5701ff469 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ClassMapperWithJoinPropertiesTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ClassMapperWithJoinPropertiesTest.cs @@ -23,9 +23,9 @@ public void WhenDefineJoinThenAddJoinWithTableNameAndKey() var hbmClass = mapdoc.RootClasses[0]; var hbmJoin = hbmClass.Joins.Single(); - hbmJoin.table.Should().Be("MyTable"); - hbmJoin.key.Should().Not.Be.Null(); - hbmJoin.key.column1.Should().Not.Be.Null(); + Assert.That(hbmJoin.table, Is.EqualTo("MyTable")); + Assert.That(hbmJoin.key, Is.Not.Null); + Assert.That(hbmJoin.key.column1, Is.Not.Null); } [Test] @@ -35,12 +35,12 @@ public void WhenDefineJoinThenCallJoinMapper() var mapper = new ClassMapper(typeof(MyClass), mapdoc, For.Property(x => x.Id)); var called = false; mapper.Join("MyTable", x => - { - x.Should().Not.Be.Null(); + { + Assert.That(x, Is.Not.Null); called = true; - }); + }); - called.Should().Be.True(); + Assert.That(called, Is.True); } //[Test] @@ -66,8 +66,8 @@ public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() mapper.Join("T2",x => { }); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Joins.Should().Have.Count.EqualTo(2); - hbmClass.Joins.Select(x=> x.table).Should().Have.UniqueValues(); + Assert.That(hbmClass.Joins.Count(), Is.EqualTo(2)); + Assert.That(hbmClass.Joins.Select(x => x.table), Is.Unique); } [Test] @@ -81,9 +81,9 @@ public void WhenDefineMoreJoinsWithSameIdThenUseSameJoinMapperInstance() mapper.Join("T1", x => firstCallInstance = x); mapper.Join("T1", x => secondCallInstance = x); - firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance); + Assert.That(firstCallInstance, Is.SameAs(secondCallInstance)); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Joins.Should().Have.Count.EqualTo(1); + Assert.That(hbmClass.Joins.Count(), Is.EqualTo(1)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComponetAsIdTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComponetAsIdTests.cs index 9dfdaaa29d6..8c87847e15a 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComponetAsIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComponetAsIdTests.cs @@ -39,17 +39,17 @@ public void WhenClassWithComponentIdThenTheIdIsConpositeId() var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); mapper.ComponentAsId(For.Property(x => x.Id), map => - { + { map.Property(For.Property(x => x.Email), pm => { }); map.ManyToOne(For.Property(x => x.User), pm => { }); }); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Id.Should().Be.Null(); + Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; - hbmCompositeId.Should().Not.Be.Null(); - hbmCompositeId.@class.Should().Not.Be.Null(); - hbmCompositeId.Items.Should().Have.Count.EqualTo(2); - hbmCompositeId.Items.Select(x => x.GetType()).Should().Have.SameValuesAs(typeof(HbmKeyProperty),typeof(HbmKeyManyToOne)); + Assert.That(hbmCompositeId, Is.Not.Null); + Assert.That(hbmCompositeId.@class, Is.Not.Null); + Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmCompositeId.Items.Select(x => x.GetType()), Is.EquivalentTo(new [] {typeof(HbmKeyProperty), typeof(HbmKeyManyToOne)})); } [Test] @@ -66,10 +66,10 @@ public void WhenComponentIdCustomizedMoreThanOnceThenMerge() mapper.ComponentAsId(For.Property(x => x.Id), map => map.Access(Accessor.Field)); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Id.Should().Be.Null(); + Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; - hbmCompositeId.Items.Should().Have.Count.EqualTo(2); - hbmCompositeId.access.Should().Contain("field"); + Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmCompositeId.access, Is.StringContaining("field")); } [Test] @@ -78,7 +78,7 @@ public void WhenMapExternalMemberAsComponentIdThenThrows() var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For.Property(x => x.Id)); - mapper.Executing(m => m.ComponentAsId(For.Property(x => x.Id), map => map.Access(Accessor.Field))).Throws(); + Assert.That(() => mapper.ComponentAsId(For.Property(x => x.Id), map => map.Access(Accessor.Field)), Throws.TypeOf()); } } diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComposedIdTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComposedIdTests.cs index f8955e0fb95..57e8dadeb48 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComposedIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/ComposedIdTests.cs @@ -31,12 +31,12 @@ public void WhenClassWithComposedIdThenTheIdIsConpositeId() map.ManyToOne(For.Property(x => x.User), pm => { }); }); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Id.Should().Be.Null(); + Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; - hbmCompositeId.Should().Not.Be.Null(); - hbmCompositeId.@class.Should().Be.Null(); - hbmCompositeId.Items.Should().Have.Count.EqualTo(2); - hbmCompositeId.Items.Select(x => x.GetType()).Should().Have.SameValuesAs(typeof(HbmKeyProperty), typeof(HbmKeyManyToOne)); + Assert.That(hbmCompositeId, Is.Not.Null); + Assert.That(hbmCompositeId.@class, Is.Null); + Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); + Assert.That(hbmCompositeId.Items.Select(x => x.GetType()), Is.EquivalentTo(new [] {typeof(HbmKeyProperty), typeof(HbmKeyManyToOne)})); } [Test] @@ -49,9 +49,9 @@ public void WhenComposedIdCustomizedMoreThanOnceThenMerge() mapper.ComposedId(map => map.ManyToOne(For.Property(x => x.User), pm => { })); var hbmClass = mapdoc.RootClasses[0]; - hbmClass.Id.Should().Be.Null(); + Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; - hbmCompositeId.Items.Should().Have.Count.EqualTo(2); + Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/SetPersisterTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/SetPersisterTests.cs index 780df2975b9..327823fd2e0 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/SetPersisterTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/SetPersisterTests.cs @@ -19,7 +19,7 @@ public void CanSetPersister() var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); rc.Persister(); - mapdoc.RootClasses[0].Persister.Should().Contain("SingleTableEntityPersister"); + Assert.That(mapdoc.RootClasses[0].Persister, Is.StringContaining("SingleTableEntityPersister")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/TablesSincronizationTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/TablesSincronizationTests.cs index 2299b81e0f0..7be2c35cf7d 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/TablesSincronizationTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ClassMapperTests/TablesSincronizationTests.cs @@ -18,7 +18,7 @@ public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); - rc.Executing(x=>x.Synchronize(null)).NotThrows(); + Assert.That(() => rc.Synchronize(null), Throws.Nothing); } [Test] @@ -27,7 +27,7 @@ public void WhenSetSyncMixedWithNullAndEmptyThenAddOnlyValid() var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); rc.Synchronize("", " ATable ", " ", null); - mapdoc.RootClasses[0].Synchronize.Single().table.Should().Be("ATable"); + Assert.That(mapdoc.RootClasses[0].Synchronize.Single().table, Is.EqualTo("ATable")); } [Test] @@ -36,7 +36,7 @@ public void WhenSetMoreSyncThenAddAll() var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); rc.Synchronize("T1", "T2", "T3", null); - mapdoc.RootClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.RootClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -46,7 +46,7 @@ public void WhenSetMoreThenOnceThenAddAll() var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); rc.Synchronize("T1", "T2"); rc.Synchronize("T3"); - mapdoc.RootClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.RootClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -56,7 +56,7 @@ public void WhenSetMoreThenOnceThenDoesNotDuplicate() var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For.Property(x => x.Id)); rc.Synchronize("T1", "T2"); rc.Synchronize("T3", "T2"); - mapdoc.RootClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.RootClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/CollectionIdMapperTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/CollectionIdMapperTests.cs index 801aa9b9586..299347ccf4f 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/CollectionIdMapperTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/CollectionIdMapperTests.cs @@ -16,8 +16,8 @@ public void WhenCreateThenHasDefaultTypeAndGenerator() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId); - hbmId.generator.@class.Should().Not.Be.NullOrEmpty(); - hbmId.type.Should().Not.Be.NullOrEmpty(); + Assert.That(hbmId.generator.@class, Is.Not.Null.And.Not.Empty); + Assert.That(hbmId.type, Is.Not.Null.And.Not.Empty); } [Test] @@ -26,8 +26,8 @@ public void WhenSetGeneratorThenChangeType() var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.HighLow); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); - hbmId.type.ToLowerInvariant().Should().Contain("int"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); + Assert.That(hbmId.type.ToLowerInvariant(), Is.StringContaining("int")); } [Test] @@ -38,8 +38,8 @@ public void WhenForceTypeThenNotChangeType() collectionIdMapper.Type((IIdentifierType) NHibernateUtil.Int64); collectionIdMapper.Generator(Generators.HighLow); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); - hbmId.type.Should().Be("Int64"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); + Assert.That(hbmId.type, Is.EqualTo("Int64")); } [Test] @@ -47,7 +47,7 @@ public void CanSetGenerator() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.HighLow); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); } [Test] @@ -55,10 +55,10 @@ public void CanSetGeneratorWithParameters() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" })); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); - hbmId.generator.param.Should().Have.Count.EqualTo(2); - hbmId.generator.param.Select(p => p.name).Should().Have.SameValuesAs("max_low", "where"); - hbmId.generator.param.Select(p => p.GetText()).Should().Have.SameValuesAs("99", "TableName"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); + Assert.That(hbmId.generator.param, Has.Length.EqualTo(2)); + Assert.That(hbmId.generator.param.Select(p => p.name), Is.EquivalentTo(new [] {"max_low", "where"})); + Assert.That(hbmId.generator.param.Select(p => p.GetText()), Is.EquivalentTo(new [] {"99", "TableName"})); } [Test] @@ -66,7 +66,7 @@ public void CanSetGeneratorGuid() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.Guid); - hbmId.generator.@class.Should().Be.EqualTo("guid"); + Assert.That(hbmId.generator.@class, Is.EqualTo("guid")); } [Test] @@ -74,7 +74,7 @@ public void CanSetGeneratorGuidComb() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.GuidComb); - hbmId.generator.@class.Should().Be.EqualTo("guid.comb"); + Assert.That(hbmId.generator.@class, Is.EqualTo("guid.comb")); } [Test] @@ -82,7 +82,7 @@ public void CanSetGeneratorSequence() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.Sequence); - hbmId.generator.@class.Should().Be.EqualTo("sequence"); + Assert.That(hbmId.generator.@class, Is.EqualTo("sequence")); } [Test] @@ -90,7 +90,7 @@ public void CanSetGeneratorIdentity() { var hbmId = new HbmCollectionId(); new CollectionIdMapper(hbmId).Generator(Generators.Identity); - hbmId.generator.@class.Should().Be.EqualTo("identity"); + Assert.That(hbmId.generator.@class, Is.EqualTo("identity")); } [Test] @@ -98,7 +98,7 @@ public void CantSetGeneratorAssigned() { var hbmId = new HbmCollectionId(); var collectionIdMapper = new CollectionIdMapper(hbmId); - collectionIdMapper.Executing(x=> x.Generator(Generators.Assigned)).Throws(); + Assert.That(() => collectionIdMapper.Generator(Generators.Assigned), Throws.TypeOf()); } [Test] @@ -107,7 +107,7 @@ public void CanSetColumnName() var hbmId = new HbmCollectionId(); var mapper = new CollectionIdMapper(hbmId); mapper.Column("MyName"); - hbmId.Columns.Single().name.Should().Be("MyName"); + Assert.That(hbmId.Columns.Single().name, Is.EqualTo("MyName")); } [Test] @@ -116,7 +116,7 @@ public void CanSetLength() var hbmId = new HbmCollectionId(); var mapper = new CollectionIdMapper(hbmId); mapper.Length(10); - hbmId.length.Should().Be("10"); + Assert.That(hbmId.length, Is.EqualTo("10")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ComponentAsIdTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ComponentAsIdTests.cs index 4d5a59b5ad8..6f1e7499dcc 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ComponentAsIdTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ComponentAsIdTests.cs @@ -33,7 +33,7 @@ public void WhenCreatedThenSetTheComponentClass() var component = new HbmCompositeId(); new ComponentAsIdMapper(typeof(PersonId), For.Property(x=> x.Id), component, mapdoc); - component.@class.Should().Contain("PersonId"); + Assert.That(component.@class, Is.StringContaining("PersonId")); } [Test] @@ -45,9 +45,9 @@ public void CanMapProperty() mapper.Property(For.Property(ts => ts.Email), x => { }); - compositeId.Items.Should().Have.Count.EqualTo(1); - compositeId.Items.First().Should().Be.OfType(); - compositeId.Items.OfType().First().Name.Should().Be.EqualTo("Email"); + Assert.That(compositeId.Items, Has.Length.EqualTo(1)); + Assert.That(compositeId.Items.First(), Is.TypeOf()); + Assert.That(compositeId.Items.OfType().First().Name, Is.EqualTo("Email")); } [Test] @@ -60,7 +60,7 @@ public void CallPropertyMapper() mapper.Property(For.Property(ts => ts.Email), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -72,9 +72,9 @@ public void CanMapManyToOne() mapper.ManyToOne(For.Property(ts => ts.User), x => { }); - compositeId.Items.Should().Have.Count.EqualTo(1); - compositeId.Items.First().Should().Be.OfType(); - compositeId.Items.OfType().First().Name.Should().Be.EqualTo("User"); + Assert.That(compositeId.Items, Has.Length.EqualTo(1)); + Assert.That(compositeId.Items.First(), Is.TypeOf()); + Assert.That(compositeId.Items.OfType().First().Name, Is.EqualTo("User")); } [Test] @@ -87,7 +87,7 @@ public void CallMapManyToOneMapper() mapper.ManyToOne(For.Property(ts => ts.User), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ComposedIdMapperTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ComposedIdMapperTests.cs index 8528ee7b356..9e77e932287 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ComposedIdMapperTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ComposedIdMapperTests.cs @@ -28,9 +28,9 @@ public void CanMapProperty() mapper.Property(For.Property(ts => ts.Email), x => { }); - compositeId.Items.Should().Have.Count.EqualTo(1); - compositeId.Items.First().Should().Be.OfType(); - compositeId.Items.OfType().First().Name.Should().Be.EqualTo("Email"); + Assert.That(compositeId.Items, Has.Length.EqualTo(1)); + Assert.That(compositeId.Items.First(), Is.TypeOf()); + Assert.That(compositeId.Items.OfType().First().Name, Is.EqualTo("Email")); } [Test] @@ -43,7 +43,7 @@ public void CallPropertyMapper() mapper.Property(For.Property(ts => ts.Email), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -55,9 +55,9 @@ public void CanMapManyToOne() mapper.ManyToOne(For.Property(ts => ts.User), x => { }); - compositeId.Items.Should().Have.Count.EqualTo(1); - compositeId.Items.First().Should().Be.OfType(); - compositeId.Items.OfType().First().Name.Should().Be.EqualTo("User"); + Assert.That(compositeId.Items, Has.Length.EqualTo(1)); + Assert.That(compositeId.Items.First(), Is.TypeOf()); + Assert.That(compositeId.Items.OfType().First().Name, Is.EqualTo("User")); } [Test] @@ -70,7 +70,7 @@ public void CallMapManyToOneMapper() mapper.ManyToOne(For.Property(ts => ts.User), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/AnyPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/AnyPropertyOnDynamicCompoTests.cs index 28e78081fcf..557135964cf 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/AnyPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/AnyPropertyOnDynamicCompoTests.cs @@ -30,7 +30,7 @@ public void WhenAddThenHas() mapper.Any(propertyInfo, typeof(int), x => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -44,7 +44,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Any(propertyInfo, typeof(int), x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -57,7 +57,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Any(propertyInfo, typeof(int), x => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/BagPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/BagPropertyOnDynamicCompoTests.cs index f81e74170c4..672bc0f9d28 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/BagPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/BagPropertyOnDynamicCompoTests.cs @@ -31,7 +31,7 @@ public void WhenAddThenHas() mapper.Bag(propertyInfo, x => { }, rel => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -45,7 +45,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Bag(propertyInfo, x => called = true, rel => { }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,7 +58,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Bag(propertyInfo, x => x.Access(Accessor.Field), rel => { }); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ComponentPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ComponentPropertyOnDynamicCompoTests.cs index 66e308c6f3d..a88d5b99875 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ComponentPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ComponentPropertyOnDynamicCompoTests.cs @@ -34,7 +34,7 @@ public void WhenAddThenHas() mapper.Component(propertyInfo, (IComponentMapper x) => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -48,7 +48,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Component(propertyInfo, (IComponentMapper x) => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -61,7 +61,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Component(propertyInfo, (IComponentMapper x) => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynCompAttributesSettingTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynCompAttributesSettingTest.cs index ef393bf5b03..92dd18042b4 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynCompAttributesSettingTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynCompAttributesSettingTest.cs @@ -28,7 +28,7 @@ public void CanSetAccessor() var mapper = new DynamicComponentMapper(component, For.Property(p => p.Info), mapdoc); mapper.Access(Accessor.Field); - component.access.Should().Be("field.camelcase"); + Assert.That(component.access, Is.EqualTo("field.camelcase")); } [Test] @@ -39,7 +39,7 @@ public void CanSetUpdate() var mapper = new DynamicComponentMapper(component, For.Property(p => p.Info), mapdoc); mapper.Update(false); - component.update.Should().Be.False(); + Assert.That(component.update, Is.False); } [Test] @@ -50,7 +50,7 @@ public void CanSetInsert() var mapper = new DynamicComponentMapper(component, For.Property(p => p.Info), mapdoc); mapper.Insert(false); - component.insert.Should().Be.False(); + Assert.That(component.insert, Is.False); } [Test] @@ -61,7 +61,7 @@ public void CanSetOptimisticLock() var mapper = new DynamicComponentMapper(component, For.Property(p => p.Info), mapdoc); mapper.OptimisticLock(false); - component.OptimisticLock.Should().Be.False(); + Assert.That(component.OptimisticLock, Is.False); } [Test] @@ -73,7 +73,7 @@ public void CanAddSimpleProperty() var dynObject = new { Pizza = 5 }; mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { }); - component.Properties.Single().Should().Be.OfType().And.ValueOf.Name.Should().Be.EqualTo("Pizza"); + Assert.That(component.Properties.Single(), Is.TypeOf().And.Property("Name").EqualTo("Pizza")); } } diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynComponentPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynComponentPropertyOnDynamicCompoTests.cs index 499d9d113a5..7f1c08d8dc7 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynComponentPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/DynComponentPropertyOnDynamicCompoTests.cs @@ -30,7 +30,7 @@ public void WhenAddThenHas() mapper.Component(propertyInfo, (IDynamicComponentMapper x) => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("Info"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "Info" })); } [Test] @@ -44,7 +44,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Component(propertyInfo, (IDynamicComponentMapper x) => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -57,7 +57,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Component(propertyInfo, (IDynamicComponentMapper x) => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/IdBagPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/IdBagPropertyOnDynamicCompoTests.cs index a20c3372e54..0acebea3b43 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/IdBagPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/IdBagPropertyOnDynamicCompoTests.cs @@ -31,7 +31,7 @@ public void WhenAddThenHas() mapper.IdBag(propertyInfo, x => { }, rel => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -45,7 +45,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.IdBag(propertyInfo, x => called = true, rel => { }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,7 +58,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.IdBag(propertyInfo, x => x.Access(Accessor.Field), rel => { }); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ListPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ListPropertyOnDynamicCompoTests.cs index bace1343579..1bfd1f00363 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ListPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ListPropertyOnDynamicCompoTests.cs @@ -31,7 +31,7 @@ public void WhenAddThenHas() mapper.List(propertyInfo, x => { }, rel => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -45,7 +45,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.List(propertyInfo, x => called = true, rel => { }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,7 +58,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.List(propertyInfo, x => x.Access(Accessor.Field), rel => { }); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ManyToOnePropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ManyToOnePropertyOnDynamicCompoTests.cs index 2353d76d667..e5812dcc88c 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ManyToOnePropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/ManyToOnePropertyOnDynamicCompoTests.cs @@ -34,7 +34,7 @@ public void WhenAddThenHas() mapper.ManyToOne(propertyInfo, x => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -48,7 +48,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.ManyToOne(propertyInfo, x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -61,7 +61,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.ManyToOne(propertyInfo, x => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/MapPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/MapPropertyOnDynamicCompoTests.cs index d12c3eeb834..b579244f144 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/MapPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/MapPropertyOnDynamicCompoTests.cs @@ -31,7 +31,7 @@ public void WhenAddThenHas() mapper.Map(propertyInfo, x => { }, km => { }, rel => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -45,7 +45,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Map(propertyInfo, x => called = true, km => { }, rel => { }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,7 +58,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Map(propertyInfo, x => x.Access(Accessor.Field), km => { }, rel => { }); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/OneToOnePropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/OneToOnePropertyOnDynamicCompoTests.cs index c4240c82614..d951fcd26d5 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/OneToOnePropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/OneToOnePropertyOnDynamicCompoTests.cs @@ -34,7 +34,7 @@ public void WhenAddThenHas() mapper.OneToOne(propertyInfo, x => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -48,7 +48,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.OneToOne(propertyInfo, x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -61,7 +61,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.OneToOne(propertyInfo, x => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SetPropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SetPropertyOnDynamicCompoTests.cs index 5b7ee8df69b..66405c0c3b2 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SetPropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SetPropertyOnDynamicCompoTests.cs @@ -31,7 +31,7 @@ public void WhenAddThenHas() mapper.Set(propertyInfo, x => { }, rel => { }); - component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); } [Test] @@ -45,7 +45,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Set(propertyInfo, x => called = true, rel => { }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,7 +58,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Set(propertyInfo, x => x.Access(Accessor.Field), rel => { }); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SimplePropertyOnDynamicCompoTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SimplePropertyOnDynamicCompoTests.cs index 29f34256ece..2ee236c8fcf 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SimplePropertyOnDynamicCompoTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/DynamicComponentMapperTests/SimplePropertyOnDynamicCompoTests.cs @@ -29,8 +29,8 @@ public void WhenAddThenHas() var propertyInfo = (new { A = 5 }).GetType().GetProperty("A"); mapper.Property(propertyInfo, x => { }); - - component.Properties.Select(x=> x.Name).Should().Have.SameSequenceAs("A"); + + Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] {"A"})); } [Test] @@ -43,7 +43,7 @@ public void WhenCustomizeThenCallCustomizer() var called = false; mapper.Property(propertyInfo, x => called = true); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -56,7 +56,7 @@ public void WhenCustomizeAccessorThenIgnore() mapper.Property(propertyInfo, x => x.Access(Accessor.Field)); - component.Properties.OfType().Single().Access.Should().Be.NullOrEmpty(); + Assert.That(component.Properties.OfType().Single().Access, Is.Null.Or.Empty); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/IdBagMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/IdBagMapperTest.cs index ed8a6ce3dea..afa656c33dd 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/IdBagMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/IdBagMapperTest.cs @@ -26,7 +26,7 @@ public void WhenCreatedHasId() { var hbm = new HbmIdbag(); new IdBagMapper(typeof(Animal), typeof(Animal), hbm); - hbm.collectionid.Should().Not.Be.Null(); + Assert.That(hbm.collectionid, Is.Not.Null); } [Test] @@ -39,7 +39,7 @@ public void WhenConfigureIdMoreThanOnceThenUseSameMapper() mapper.Id(x => firstInstance = x); mapper.Id(x => secondInstance = x); - firstInstance.Should().Be.SameInstanceAs(secondInstance); + Assert.That(firstInstance, Is.SameAs(secondInstance)); } [Test] @@ -49,7 +49,7 @@ public void WhenConfigureIdThenCallMapper() var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Id(x => x.Column("catchMe")); - hbm.collectionid.Columns.Single().name.Should().Be("catchMe"); + Assert.That(hbm.collectionid.Columns.Single().name, Is.EqualTo("catchMe")); } [Test] @@ -58,9 +58,9 @@ public void SetInverse() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Inverse(true); - hbm.Inverse.Should().Be.True(); + Assert.That(hbm.Inverse, Is.True); mapper.Inverse(false); - hbm.Inverse.Should().Be.False(); + Assert.That(hbm.Inverse, Is.False); } [Test] @@ -69,9 +69,9 @@ public void SetMutable() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Mutable(true); - hbm.Mutable.Should().Be.True(); + Assert.That(hbm.Mutable, Is.True); mapper.Mutable(false); - hbm.Mutable.Should().Be.False(); + Assert.That(hbm.Mutable, Is.False); } [Test] @@ -80,7 +80,7 @@ public void SetWhere() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Where("c > 10"); - hbm.Where.Should().Be.EqualTo("c > 10"); + Assert.That(hbm.Where, Is.EqualTo("c > 10")); } [Test] @@ -89,7 +89,7 @@ public void SetBatchSize() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.BatchSize(10); - hbm.BatchSize.Should().Be.EqualTo(10); + Assert.That(hbm.BatchSize, Is.EqualTo(10)); } [Test] @@ -98,11 +98,11 @@ public void SetLazy() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Lazy(CollectionLazy.Extra); - hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.Extra); + Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.Extra)); mapper.Lazy(CollectionLazy.NoLazy); - hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.False); + Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.False)); mapper.Lazy(CollectionLazy.Lazy); - hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.True); + Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.True)); } [Test] @@ -112,8 +112,8 @@ public void CallKeyMapper() var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); bool kmCalled = false; mapper.Key(km => kmCalled = true); - hbm.Key.Should().Not.Be.Null(); - kmCalled.Should().Be.True(); + Assert.That(hbm.Key, Is.Not.Null); + Assert.That(kmCalled, Is.True); } [Test] @@ -121,8 +121,8 @@ public void SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); - Executing.This(() => mapper.Type(null)).Should().Throw(); - Executing.This(() => mapper.Type(typeof(object))).Should().Throw(); + Assert.That(() => mapper.Type(null), Throws.TypeOf()); + Assert.That(() => mapper.Type(typeof(object)), Throws.TypeOf()); } [Test] @@ -131,7 +131,7 @@ public void SetCollectionTypeByGenericType() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type(); - hbm.CollectionType.Should().Contain("FakeUserCollectionType"); + Assert.That(hbm.CollectionType, Is.StringContaining("FakeUserCollectionType")); } [Test] @@ -140,7 +140,7 @@ public void SetCollectionTypeByType() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type(typeof(FakeUserCollectionType)); - hbm.CollectionType.Should().Contain("FakeUserCollectionType"); + Assert.That(hbm.CollectionType, Is.StringContaining("FakeUserCollectionType")); } [Test] @@ -150,7 +150,7 @@ public void CanChangeAccessor() var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Access(Accessor.Field); - hbm.Access.Should().Not.Be.Null(); + Assert.That(hbm.Access, Is.Not.Null); } [Test] @@ -160,7 +160,7 @@ public void CanSetCache() var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Cache(x => x.Region("pizza")); - hbm.cache.Should().Not.Be.Null(); + Assert.That(hbm.cache, Is.Not.Null); } [Test] @@ -172,9 +172,9 @@ public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostT mapper.Cache(ch => ch.Usage(CacheUsage.NonstrictReadWrite)); var hbmCache = hbm.cache; - hbmCache.Should().Not.Be.Null(); - hbmCache.region.Should().Be("pizza"); - hbmCache.usage.Should().Be(HbmCacheUsage.NonstrictReadWrite); + Assert.That(hbmCache, Is.Not.Null); + Assert.That(hbmCache.region, Is.EqualTo("pizza")); + Assert.That(hbmCache.usage, Is.EqualTo(HbmCacheUsage.NonstrictReadWrite)); } [Test] @@ -183,8 +183,9 @@ public void CanSetAFilterThroughAction() var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); - hbm.filter.Length.Should().Be(1); - hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == "condition1"); + Assert.That(hbm.filter.Length, Is.EqualTo(1)); + Assert.That(hbm.filter[0].condition, Is.EqualTo("condition1")); + Assert.That(hbm.filter[0].name, Is.EqualTo("filter1")); } [Test] @@ -194,9 +195,9 @@ public void CanSetMoreFiltersThroughAction() var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); mapper.Filter("filter2", f => f.Condition("condition2")); - hbm.filter.Length.Should().Be(2); - hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter1" && f.condition == "condition1")); - hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter2" && f.condition == "condition2")); + Assert.That(hbm.filter.Length, Is.EqualTo(2)); + Assert.True(hbm.filter.Any(f => f.name == "filter1" && f.condition == "condition1")); + Assert.True(hbm.filter.Any(f => f.name == "filter2" && f.condition == "condition2")); } [Test] @@ -207,9 +208,9 @@ public void WhenSameNameThenOverrideCondition() mapper.Filter("filter1", f => f.Condition("condition1")); mapper.Filter("filter2", f => f.Condition("condition2")); mapper.Filter("filter1", f => f.Condition("anothercondition1")); - hbm.filter.Length.Should().Be(2); - hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter1" && f.condition == "anothercondition1")); - hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter2" && f.condition == "condition2")); + Assert.That(hbm.filter.Length, Is.EqualTo(2)); + Assert.That(hbm.filter.Any(f => f.name == "filter1" && f.condition == "anothercondition1"), Is.True); + Assert.That(hbm.filter.Any(f => f.name == "filter2" && f.condition == "condition2"), Is.True); } [Test] @@ -218,8 +219,10 @@ public void WhenActionIsNullThenAddFilterName() var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", null); - hbm.filter.Length.Should().Be(1); - hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == null); + Assert.That(hbm.filter.Length, Is.EqualTo(1)); + var filter = hbm.filter[0]; + Assert.That(filter.condition, Is.EqualTo(null)); + Assert.That(filter.name, Is.EqualTo("filter1")); } [Test] @@ -228,14 +231,14 @@ public void SetFetchMode() var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Fetch(CollectionFetchMode.Subselect); - hbm.fetch.Should().Be(HbmCollectionFetchMode.Subselect); - hbm.fetchSpecified.Should().Be.True(); + Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Subselect)); + Assert.That(hbm.fetchSpecified, Is.True); mapper.Fetch(CollectionFetchMode.Join); - hbm.fetch.Should().Be(HbmCollectionFetchMode.Join); - hbm.fetchSpecified.Should().Be.True(); + Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Join)); + Assert.That(hbm.fetchSpecified, Is.True); mapper.Fetch(CollectionFetchMode.Select); - hbm.fetch.Should().Be(HbmCollectionFetchMode.Select); - hbm.fetchSpecified.Should().Be.False(); + Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Select)); + Assert.That(hbm.fetchSpecified, Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/IdMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/IdMapperTest.cs index 6ee5bcfb1da..427f4a26c3f 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/IdMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/IdMapperTest.cs @@ -23,7 +23,7 @@ public void CanSetGenerator() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.HighLow); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); } [Test] @@ -31,10 +31,10 @@ public void CanSetGeneratorWithParameters() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" })); - hbmId.generator.@class.Should().Be.EqualTo("hilo"); - hbmId.generator.param.Should().Have.Count.EqualTo(2); - hbmId.generator.param.Select(p => p.name).Should().Have.SameValuesAs("max_low", "where"); - hbmId.generator.param.Select(p => p.GetText()).Should().Have.SameValuesAs("99", "TableName"); + Assert.That(hbmId.generator.@class, Is.EqualTo("hilo")); + Assert.That(hbmId.generator.param, Has.Length.EqualTo(2)); + Assert.That(hbmId.generator.param.Select(p => p.name), Is.EquivalentTo(new [] {"max_low", "where"})); + Assert.That(hbmId.generator.param.Select(p => p.GetText()), Is.EquivalentTo(new [] {"99", "TableName"})); } [Test] @@ -42,7 +42,7 @@ public void CanSetGeneratorGuid() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.Guid); - hbmId.generator.@class.Should().Be.EqualTo("guid"); + Assert.That(hbmId.generator.@class, Is.EqualTo("guid")); } [Test] @@ -50,7 +50,7 @@ public void CanSetGeneratorGuidComb() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.GuidComb); - hbmId.generator.@class.Should().Be.EqualTo("guid.comb"); + Assert.That(hbmId.generator.@class, Is.EqualTo("guid.comb")); } [Test] @@ -58,7 +58,7 @@ public void CanSetGeneratorSequence() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.Sequence); - hbmId.generator.@class.Should().Be.EqualTo("sequence"); + Assert.That(hbmId.generator.@class, Is.EqualTo("sequence")); } [Test] @@ -66,7 +66,7 @@ public void CanSetGeneratorIdentity() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.Identity); - hbmId.generator.@class.Should().Be.EqualTo("identity"); + Assert.That(hbmId.generator.@class, Is.EqualTo("identity")); } private class MyClass @@ -85,9 +85,11 @@ public void CanSetGeneratorForeign() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.Foreign(mc => mc.OneToOne)); - hbmId.generator.@class.Should().Be.EqualTo("foreign"); - hbmId.generator.param.Should().Not.Be.Null().And.Have.Count.EqualTo(1); - hbmId.generator.param.Single().Satisfy(p => p.name == "property" && p.GetText() == "OneToOne"); + Assert.That(hbmId.generator.@class, Is.EqualTo("foreign")); + Assert.That(hbmId.generator.param, Is.Not.Null.And.Length.EqualTo(1)); + var p = hbmId.generator.param.Single(); + Assert.That(p.GetText(), Is.EqualTo("OneToOne")); + Assert.That(p.name, Is.EqualTo("property")); } [Test] @@ -95,7 +97,7 @@ public void CanSetGeneratorAssigned() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.Assigned); - hbmId.generator.@class.Should().Be.EqualTo("assigned"); + Assert.That(hbmId.generator.@class, Is.EqualTo("assigned")); } [Test] @@ -103,7 +105,7 @@ public void CanSetGeneratorEnhancedSequence() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.EnhancedSequence); - hbmId.generator.@class.Should().Be.EqualTo("enhanced-sequence"); + Assert.That(hbmId.generator.@class, Is.EqualTo("enhanced-sequence")); } [Test] @@ -111,7 +113,7 @@ public void CanSetGeneratorEnhancedTable() { var hbmId = new HbmId(); new IdMapper(hbmId).Generator(Generators.EnhancedTable); - hbmId.generator.@class.Should().Be.EqualTo("enhanced-table"); + Assert.That(hbmId.generator.@class, Is.EqualTo("enhanced-table")); } private class BaseEntity { @@ -137,7 +139,7 @@ public void WhenHasMemberCanSetAccessor() var hbmId = new HbmId(); var mapper = new IdMapper(member, hbmId); mapper.Access(Accessor.NoSetter); - hbmId.access.Should().Be("nosetter.camelcase"); + Assert.That(hbmId.access, Is.EqualTo("nosetter.camelcase")); } [Test] @@ -146,7 +148,7 @@ public void CanSetColumnName() var hbmId = new HbmId(); var mapper = new IdMapper(null, hbmId); mapper.Column("MyName"); - hbmId.Columns.Single().name.Should().Be("MyName"); + Assert.That(hbmId.Columns.Single().name, Is.EqualTo("MyName")); } [TestCase(-1, "-1")] @@ -156,7 +158,7 @@ public void CanSetUnsavedValue(object unsavedValue, string expectedUnsavedValue) var hbmId = new HbmId(); var mapper = new IdMapper(null, hbmId); mapper.UnsavedValue(unsavedValue); - hbmId.unsavedvalue.Should().Be(expectedUnsavedValue); + Assert.That(hbmId.unsavedvalue, Is.EqualTo(expectedUnsavedValue)); } [Test] @@ -164,7 +166,7 @@ public void UnsavedValueUnsetWhenNotSet() { var hbmId = new HbmId(); var mapper = new IdMapper(null, hbmId); - hbmId.unsavedvalue.Should().Be(null); + Assert.That(hbmId.unsavedvalue, Is.EqualTo(null)); } [Test] @@ -173,7 +175,7 @@ public void CanSetLength() var hbmId = new HbmId(); var mapper = new IdMapper(null, hbmId); mapper.Length(10); - hbmId.length.Should().Be("10"); + Assert.That(hbmId.length, Is.EqualTo("10")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs index 06ddbae340c..82126c327e0 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using NHibernate.Cfg.MappingSchema; using NHibernate.Mapping.ByCode; using NHibernate.Mapping.ByCode.Impl; @@ -19,16 +20,16 @@ public void WhenCreateWithEmptySplitGroupThenThrows() { var mapdoc = new HbmMapping(); var hbmJoin = new HbmJoin(); - Executing.This(() => new JoinMapper(typeof(MyClass), null, hbmJoin, mapdoc)).Should().Throw(); - Executing.This(() => new JoinMapper(typeof(MyClass), "", hbmJoin, mapdoc)).Should().Throw(); - Executing.This(() => new JoinMapper(typeof(MyClass), " ", hbmJoin, mapdoc)).Should().Throw(); + Assert.That(() => new JoinMapper(typeof(MyClass), null, hbmJoin, mapdoc), Throws.TypeOf()); + Assert.That(() => new JoinMapper(typeof(MyClass), "", hbmJoin, mapdoc), Throws.TypeOf()); + Assert.That(() => new JoinMapper(typeof(MyClass), " ", hbmJoin, mapdoc), Throws.TypeOf()); } [Test] public void WhenCreateWithNullHbmJoinThenThrows() { var mapdoc = new HbmMapping(); - Executing.This(() => new JoinMapper(typeof(MyClass), "AA", null, mapdoc)).Should().Throw(); + Assert.That(() => new JoinMapper(typeof(MyClass), "AA", null, mapdoc), Throws.TypeOf()); } [Test] @@ -37,7 +38,7 @@ public void WhenCreateThenSetDefaultTableName() var mapdoc = new HbmMapping(); var hbmJoin = new HbmJoin(); new JoinMapper(typeof(MyClass), " AA ", hbmJoin, mapdoc); - hbmJoin.table.Should().Be("AA"); + Assert.That(hbmJoin.table, Is.EqualTo("AA")); } [Test] @@ -47,7 +48,7 @@ public void CanSetTable() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Table(" Pizza "); - hbmJoin.table.Should().Be("Pizza"); + Assert.That(hbmJoin.table, Is.EqualTo("Pizza")); } [Test] @@ -56,9 +57,9 @@ public void WhenSetTableNameEmptyThenThrows() var mapdoc = new HbmMapping(); var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); - mapper.Executing(x => x.Table(null)).Throws(); - mapper.Executing(x => x.Table("")).Throws(); - mapper.Executing(x => x.Table(" ")).Throws(); + Assert.That(() => mapper.Table(null), Throws.TypeOf()); + Assert.That(() => mapper.Table(""), Throws.TypeOf()); + Assert.That(() => mapper.Table(" "), Throws.TypeOf()); } [Test] @@ -69,14 +70,14 @@ public void WhenTableNameChangesValueThenNotify() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.TableNameChanged += (m, x) => - { - m.Should().Be.SameInstanceAs(mapper); - x.OldName.Should().Be("AA"); - x.NewName.Should().Be("Pizza"); + { + Assert.That(m, Is.SameAs(mapper)); + Assert.That(x.OldName, Is.EqualTo("AA")); + Assert.That(x.NewName, Is.EqualTo("Pizza")); eventCalled = true; }; mapper.Table(" Pizza "); - eventCalled.Should().Be.True(); + Assert.That(eventCalled, Is.True); } [Test] @@ -86,7 +87,7 @@ public void CanSetCatalog() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Catalog("pizza"); - hbmJoin.catalog.Should().Be("pizza"); + Assert.That(hbmJoin.catalog, Is.EqualTo("pizza")); } [Test] @@ -96,7 +97,7 @@ public void CanSetSchema() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Schema("pizza"); - hbmJoin.schema.Should().Be("pizza"); + Assert.That(hbmJoin.schema, Is.EqualTo("pizza")); } [Test] @@ -107,8 +108,8 @@ public void CanSetSqlInsert() var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.SqlInsert("blah"); - hbmJoin.SqlInsert.Should().Not.Be.Null(); - hbmJoin.SqlInsert.Text[0].Should().Be("blah"); + Assert.That(hbmJoin.SqlInsert, Is.Not.Null); + Assert.That(hbmJoin.SqlInsert.Text[0], Is.EqualTo("blah")); } [Test] @@ -119,8 +120,8 @@ public void SetSqlUpdate() var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.SqlUpdate("blah"); - hbmJoin.SqlUpdate.Should().Not.Be.Null(); - hbmJoin.SqlUpdate.Text[0].Should().Be("blah"); + Assert.That(hbmJoin.SqlUpdate, Is.Not.Null); + Assert.That(hbmJoin.SqlUpdate.Text[0], Is.EqualTo("blah")); } [Test] @@ -131,8 +132,8 @@ public void SetSqlDelete() var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.SqlDelete("blah"); - hbmJoin.SqlDelete.Should().Not.Be.Null(); - hbmJoin.SqlDelete.Text[0].Should().Be("blah"); + Assert.That(hbmJoin.SqlDelete, Is.Not.Null); + Assert.That(hbmJoin.SqlDelete.Text[0], Is.EqualTo("blah")); } [Test] @@ -143,8 +144,8 @@ public void CanSetSqlSubselect() var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Subselect("blah"); - hbmJoin.Subselect.Should().Not.Be.Null(); - hbmJoin.subselect.Text[0].Should().Be("blah"); + Assert.That(hbmJoin.Subselect, Is.Not.Null); + Assert.That(hbmJoin.subselect.Text[0], Is.EqualTo("blah")); } [Test] @@ -154,7 +155,7 @@ public void CanSetInverse() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Inverse(true); - hbmJoin.inverse.Should().Be.True(); + Assert.That(hbmJoin.inverse, Is.True); } [Test] @@ -164,7 +165,7 @@ public void CanSetOptional() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Optional(true); - hbmJoin.optional.Should().Be.True(); + Assert.That(hbmJoin.optional, Is.True); } [Test] @@ -174,7 +175,7 @@ public void CanSetFetch() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); mapper.Fetch(FetchKind.Select); - hbmJoin.fetch.Should().Be(HbmJoinFetch.Select); + Assert.That(hbmJoin.fetch, Is.EqualTo(HbmJoinFetch.Select)); } [Test] @@ -187,7 +188,7 @@ public void CallKeyMapper() mapper.Key(km => keyMapperCalled = true); - keyMapperCalled.Should().Be.True(); + Assert.That(keyMapperCalled, Is.True); } [Test] @@ -197,7 +198,7 @@ public void WhenCallKeyMapperThenKeyMapperIsNotNull() var hbmJoin = new HbmJoin(); var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc); - mapper.Key(km => km.Should().Not.Be.Null()); + mapper.Key(km => Assert.That(km, Is.Not.Null)); } [Test] @@ -212,7 +213,7 @@ public void WhenCallKeyMapperMoreThanOnceThenKeyMapperIsTheSame() mapper.Key(km => firstCallInstance = km); mapper.Key(km => secondCallInstance = km); - firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance); + Assert.That(firstCallInstance, Is.SameAs(secondCallInstance)); } [Test] @@ -224,7 +225,7 @@ public void WhenAddPropertyThenAddItem() mapper.Property(For.Property(mc => mc.Something), x => { }); - hbmJoin.Properties.Should().Have.Count.EqualTo(1); + Assert.That(hbmJoin.Properties.Count(), Is.EqualTo(1)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/SetPersisterTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/SetPersisterTests.cs index 02e8b704c3b..a77fa142a55 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/SetPersisterTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/SetPersisterTests.cs @@ -23,7 +23,7 @@ public void CanSetPersister() var mapdoc = new HbmMapping(); var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Persister(); - mapdoc.JoinedSubclasses[0].Persister.Should().Contain("JoinedSubclassEntityPersister"); + Assert.That(mapdoc.JoinedSubclasses[0].Persister, Is.StringContaining("JoinedSubclassEntityPersister")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/TablesSincronizationTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/TablesSincronizationTests.cs index 37379014161..b188b7f76bb 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/TablesSincronizationTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/JoinedSubclassMapperTests/TablesSincronizationTests.cs @@ -22,7 +22,7 @@ public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); - rc.Executing(x => x.Synchronize(null)).NotThrows(); + Assert.That(() => rc.Synchronize(null), Throws.Nothing); } [Test] @@ -31,7 +31,7 @@ public void WhenSetSyncMixedWithNullAndEmptyThenAddOnlyValid() var mapdoc = new HbmMapping(); var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("", " ATable ", " ", null); - mapdoc.JoinedSubclasses[0].Synchronize.Single().table.Should().Be("ATable"); + Assert.That(mapdoc.JoinedSubclasses[0].Synchronize.Single().table, Is.EqualTo("ATable")); } [Test] @@ -40,7 +40,7 @@ public void WhenSetMoreSyncThenAddAll() var mapdoc = new HbmMapping(); var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2", "T3", null); - mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -50,7 +50,7 @@ public void WhenSetMoreThenOnceThenAddAll() var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3"); - mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -60,7 +60,7 @@ public void WhenSetMoreThenOnceThenDoesNotDuplicate() var rc = new JoinedSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3", "T2"); - mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.JoinedSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/ManyToOneMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/ManyToOneMapperTest.cs index fdc74ab0a46..03113db2f14 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/ManyToOneMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/ManyToOneMapperTest.cs @@ -35,7 +35,7 @@ public void AssignCascadeStyle() var hbm = new HbmManyToOne(); var mapper = new ManyToOneMapper(null, hbm, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.Remove); - hbm.cascade.Split(',').Select(w => w.Trim()).Should().Contain("persist").And.Contain("delete"); + Assert.That(hbm.cascade.Split(',').Select(w => w.Trim()), Contains.Item("persist").And.Contains("delete")); } [Test] @@ -45,7 +45,7 @@ public void AutoCleanUnsupportedCascadeStyle() var hbm = new HbmManyToOne(); var mapper = new ManyToOneMapper(null, hbm, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.DeleteOrphans | Mapping.ByCode.Cascade.Remove); - hbm.cascade.Split(',').Select(w => w.Trim()).All(w => w.Satisfy(cascade => !cascade.Contains("orphan"))); + Assert.True(hbm.cascade.Split(',').Select(w => w.Trim()).All(w => !w.Contains("orphan"))); } [Test] @@ -57,7 +57,7 @@ public void CanSetAccessor() var mapper = new ManyToOneMapper(member, hbm, hbmMapping); mapper.Access(Accessor.ReadOnly); - hbm.Access.Should().Be("readonly"); + Assert.That(hbm.Access, Is.EqualTo("readonly")); } [Test] @@ -69,8 +69,8 @@ public void WhenSetDifferentColumnNameThenSetTheName() var mapper = new ManyToOneMapper(member, hbm, hbmMapping); mapper.Column(cm => cm.Name("RelationId")); - hbm.Columns.Should().Have.Count.EqualTo(1); - hbm.Columns.Single().name.Should().Be("RelationId"); + Assert.That(hbm.Columns.Count(), Is.EqualTo(1)); + Assert.That(hbm.Columns.Single().name, Is.EqualTo("RelationId")); } [Test] @@ -81,8 +81,8 @@ public void WhenSetDefaultColumnNameThenDoesNotSetTheName() var mapping = new HbmManyToOne(); var mapper = new ManyToOneMapper(member, mapping, hbmMapping); mapper.Column(cm => cm.Name("Relation")); - mapping.column.Should().Be.Null(); - mapping.Columns.Should().Be.Empty(); + Assert.That(mapping.column, Is.Null); + Assert.That(mapping.Columns, Is.Empty); } [Test] @@ -97,10 +97,10 @@ public void WhenSetBasicColumnValuesThenSetPlainValues() cm.UniqueKey("theUnique"); cm.NotNullable(true); }); - mapping.Items.Should().Be.Null(); - mapping.uniquekey.Should().Be("theUnique"); - mapping.notnull.Should().Be(true); - mapping.notnullSpecified.Should().Be(true); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.uniquekey, Is.EqualTo("theUnique")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.notnullSpecified, Is.EqualTo(true)); } [Test] @@ -115,8 +115,8 @@ public void WhenSetColumnValuesThenAddColumnTag() cm.SqlType("BIGINT"); cm.NotNullable(true); }); - mapping.Items.Should().Not.Be.Null(); - mapping.Columns.Should().Have.Count.EqualTo(1); + Assert.That(mapping.Items, Is.Not.Null); + Assert.That(mapping.Columns.Count(), Is.EqualTo(1)); } [Test] @@ -129,10 +129,10 @@ public void WhenSetBasicColumnValuesMoreThanOnesThenMergeColumn() mapper.Column(cm => cm.UniqueKey("theUnique")); mapper.Column(cm => cm.NotNullable(true)); - mapping.Items.Should().Be.Null(); - mapping.uniquekey.Should().Be("theUnique"); - mapping.notnull.Should().Be(true); - mapping.notnullSpecified.Should().Be(true); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.uniquekey, Is.EqualTo("theUnique")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.notnullSpecified, Is.EqualTo(true)); } [Test] @@ -151,7 +151,7 @@ public void WhenSetMultiColumnsValuesThenAddColumns() cm.Name("column2"); cm.SqlType("VARCHAR(10)"); }); - mapping.Columns.Should().Have.Count.EqualTo(2); + Assert.That(mapping.Columns.Count(), Is.EqualTo(2)); } [Test] @@ -162,8 +162,8 @@ public void WhenSetMultiColumnsValuesThenAutoassignColumnNames() var mapping = new HbmManyToOne(); var mapper = new ManyToOneMapper(member, mapping, hbmMapping); mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)")); - mapping.Columns.Should().Have.Count.EqualTo(2); - mapping.Columns.All(cm => cm.name.Satisfy(n => !string.IsNullOrEmpty(n))); + Assert.That(mapping.Columns.Count(), Is.EqualTo(2)); + Assert.That(mapping.Columns.All(cm => !string.IsNullOrEmpty(cm.name)), Is.True); } [Test] @@ -174,7 +174,7 @@ public void AfterSetMultiColumnsCantSetSimpleColumn() var mapping = new HbmManyToOne(); var mapper = new ManyToOneMapper(member, mapping, hbmMapping); mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)")); - Executing.This(() => mapper.Column(cm => cm.Length(50))).Should().Throw(); + Assert.That(() => mapper.Column(cm => cm.Length(50)), Throws.TypeOf()); } [Test] @@ -190,12 +190,12 @@ public void WhenSetBasicColumnValuesThroughShortCutThenMergeColumn() mapper.UniqueKey("AA"); mapper.Index("II"); - mapping.Items.Should().Be.Null(); - mapping.column.Should().Be("pizza"); - mapping.notnull.Should().Be(true); - mapping.unique.Should().Be(true); - mapping.uniquekey.Should().Be("AA"); - mapping.index.Should().Be("II"); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.column, Is.EqualTo("pizza")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.unique, Is.EqualTo(true)); + Assert.That(mapping.uniquekey, Is.EqualTo("AA")); + Assert.That(mapping.index, Is.EqualTo("II")); } [Test(Description = "NH-3618")] @@ -227,8 +227,8 @@ public void WhenSetFetchModeToJoinThenSetFetch() mapper.Fetch(FetchKind.Join); - mapping.fetch.Should().Be(HbmFetchMode.Join); - mapping.fetchSpecified.Should().Be.True(); + Assert.That(mapping.fetch, Is.EqualTo(HbmFetchMode.Join)); + Assert.That(mapping.fetchSpecified, Is.True); } [Test] @@ -241,8 +241,8 @@ public void WhenSetFetchModeToSelectThenResetFetch() mapper.Fetch(FetchKind.Select); - mapping.fetch.Should().Be(HbmFetchMode.Select); - mapping.fetchSpecified.Should().Be.False(); + Assert.That(mapping.fetch, Is.EqualTo(HbmFetchMode.Select)); + Assert.That(mapping.fetchSpecified, Is.False); } [Test] @@ -255,7 +255,7 @@ public void CanForceClassRelation() mapper.Class(typeof(Relation)); - mapping.Class.Should().Contain("Relation").And.Not.Contain("IRelation"); + Assert.That(mapping.Class, Is.StringContaining("Relation").And.Not.Contains("IRelation")); } [Test] @@ -266,7 +266,7 @@ public void WhenForceClassRelationToIncompatibleTypeThenThrows() var mapping = new HbmManyToOne(); var mapper = new ManyToOneMapper(member, mapping, hbmMapping); - Executing.This(() => mapper.Class(typeof(Whatever))).Should().Throw(); + Assert.That(() => mapper.Class(typeof(Whatever)), Throws.TypeOf()); } [Test] @@ -277,8 +277,8 @@ public void CanSetLazyness() var mapping = new HbmManyToOne(); var mapper = new ManyToOneMapper(member, mapping, hbmMapping); mapper.Lazy(LazyRelation.NoProxy); - mapping.Lazy.Should().Have.Value(); - mapping.Lazy.Should().Be(HbmLaziness.NoProxy); + Assert.That(mapping.Lazy, Is.Not.Null); + Assert.That(mapping.Lazy, Is.EqualTo(HbmLaziness.NoProxy)); } [Test] @@ -290,7 +290,7 @@ public void CanSetUpdate() var mapper = new ManyToOneMapper(member, hbm, hbmMapping); mapper.Update(false); - hbm.update.Should().Be.False(); + Assert.That(hbm.update, Is.False); } [Test] @@ -302,7 +302,7 @@ public void CanSetInsert() var mapper = new ManyToOneMapper(member, hbm, hbmMapping); mapper.Insert(false); - hbm.insert.Should().Be.False(); + Assert.That(hbm.insert, Is.False); } [Test] @@ -315,7 +315,7 @@ public void CanSetFk() mapper.ForeignKey("MyFkName"); - hbm.foreignkey.Should().Be("MyFkName"); + Assert.That(hbm.foreignkey, Is.EqualTo("MyFkName")); } [Test] @@ -328,7 +328,7 @@ public void CanSetPropertyRefName() mapper.PropertyRef("PropertyRefName"); - hbm.propertyref.Should().Be("PropertyRefName"); + Assert.That(hbm.propertyref, Is.EqualTo("PropertyRefName")); } [Test] @@ -341,7 +341,7 @@ public void CanSetNotFoundWithExceptionMode() mapper.NotFound(NotFoundMode.Exception); - hbm.notfound.Should().Be(HbmNotFoundMode.Exception); + Assert.That(hbm.notfound, Is.EqualTo(HbmNotFoundMode.Exception)); } [Test] @@ -354,7 +354,7 @@ public void CanSetNotFoundWithIgnoreMode() mapper.NotFound(NotFoundMode.Ignore); - hbm.notfound.Should().Be(HbmNotFoundMode.Ignore); + Assert.That(hbm.notfound, Is.EqualTo(HbmNotFoundMode.Ignore)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/NaturalIdMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/NaturalIdMapperTest.cs index dc326b2135a..20ab0d5ae8b 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/NaturalIdMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/NaturalIdMapperTest.cs @@ -23,7 +23,7 @@ public void CanSetMutable() var hbmNaturalId = hbmClass.naturalid; nid.Mutable(true); - hbmNaturalId.mutable.Should().Be.True(); + Assert.That(hbmNaturalId.mutable, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/OneToOneMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/OneToOneMapperTest.cs index 80707da741f..64b233f0cfc 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/OneToOneMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/OneToOneMapperTest.cs @@ -26,7 +26,7 @@ public void AssignCascadeStyle() var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.Remove); - hbm.cascade.Split(',').Select(w => w.Trim()).Should().Contain("persist").And.Contain("delete"); + Assert.That(hbm.cascade.Split(',').Select(w => w.Trim()), Contains.Item("persist").And.Contains("delete")); } [Test] @@ -35,7 +35,7 @@ public void AutoCleanUnsupportedCascadeStyle() var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.DeleteOrphans | Mapping.ByCode.Cascade.Remove); - hbm.cascade.Split(',').Select(w => w.Trim()).All(w => w.Satisfy(cascade => !cascade.Contains("orphan"))); + Assert.That(hbm.cascade.Split(',').Select(w => w.Trim()).All(cascade => !cascade.Contains("orphan")), Is.True); } [Test] @@ -46,7 +46,7 @@ public void CanSetAccessor() var mapper = new OneToOneMapper(member, hbm); mapper.Access(Accessor.ReadOnly); - hbm.Access.Should().Be("readonly"); + Assert.That(hbm.Access, Is.EqualTo("readonly")); } [Test] @@ -55,8 +55,8 @@ public void CanSetLazyness() var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Lazy(LazyRelation.NoProxy); - hbm.Lazy.Should().Have.Value(); - hbm.Lazy.Should().Be(HbmLaziness.NoProxy); + Assert.That(hbm.Lazy, Is.Not.Null); + Assert.That(hbm.Lazy, Is.EqualTo(HbmLaziness.NoProxy)); } [Test] @@ -65,7 +65,7 @@ public void CanSetConstrained() var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Constrained(true); - hbm.constrained.Should().Be.True(); + Assert.That(hbm.constrained, Is.True); } [Test] @@ -75,7 +75,7 @@ public void CanSetForeignKeyName() var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey("Id"); - hbm.foreignkey.Should().Be("Id"); + Assert.That(hbm.foreignkey, Is.EqualTo("Id")); } [Test] @@ -85,7 +85,7 @@ public void WhenForeignKeyIsNullForeignKeyMappingIsNull() var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey(null); - hbm.foreignkey.Should().Be.Null(); + Assert.That(hbm.foreignkey, Is.Null); } [Test] @@ -95,7 +95,7 @@ public void WhenNoMemberPropertyRefAcceptAnything() var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(typeof(Array).GetProperty("Length")); - hbm.propertyref.Should().Be("Length"); + Assert.That(hbm.propertyref, Is.EqualTo("Length")); } [Test] @@ -105,7 +105,7 @@ public void WhenNullMemberPropertyRefNull() var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(null); - hbm.propertyref.Should().Be.Null(); + Assert.That(hbm.propertyref, Is.Null); } [Test] @@ -115,9 +115,9 @@ public void WhenMemberPropertyRefAcceptOnlyMemberOfExpectedType() var mapper = new OneToOneMapper(typeof(MyClass).GetProperty("Relation"), hbm); mapper.PropertyReference(typeof(Relation).GetProperty("Whatever")); - hbm.propertyref.Should().Be("Whatever"); + Assert.That(hbm.propertyref, Is.EqualTo("Whatever")); - Executing.This(() => mapper.PropertyReference(typeof(Array).GetProperty("Length"))).Should().Throw(); + Assert.That(() => mapper.PropertyReference(typeof(Array).GetProperty("Length")), Throws.TypeOf()); } [Test] @@ -128,7 +128,7 @@ public void CanSetFormula() var mapper = new OneToOneMapper(member, mapping); mapper.Formula("SomeFormula"); - mapping.formula1.Should().Be("SomeFormula"); + Assert.That(mapping.formula1, Is.EqualTo("SomeFormula")); } [Test] @@ -138,8 +138,8 @@ public void WhenSetFormulaWithNullThenSetFormulaWithNull() var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); mapper.Formula(null); - mapping.formula.Should().Be.Null(); - mapping.formula1.Should().Be.Null(); + Assert.That(mapping.formula, Is.Null); + Assert.That(mapping.formula1, Is.Null); } [Test] @@ -151,12 +151,12 @@ public void WhenSetFormulaWithMultipleLinesThenSetFormulaNode() var formula = @"Line1 Line2"; mapper.Formula(formula); - mapping.formula1.Should().Be.Null(); + Assert.That(mapping.formula1, Is.Null); var hbmFormula = mapping.formula.First(); - hbmFormula.Text.Length.Should().Be(2); - hbmFormula.Text[0].Should().Be("Line1"); - hbmFormula.Text[1].Should().Be("Line2"); - mapping.formula1.Should().Be.Null(); + Assert.That(hbmFormula.Text.Length, Is.EqualTo(2)); + Assert.That(hbmFormula.Text[0], Is.EqualTo("Line1")); + Assert.That(hbmFormula.Text[1], Is.EqualTo("Line2")); + Assert.That(mapping.formula1, Is.Null); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs index 21a740e60d2..4674853017b 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs @@ -48,7 +48,7 @@ public void WhenCreateWithGivenAccessorMapperThenUseTheGivenAccessoMapper() var myAccessorMapper = new MyAccessorMapper(); var mapper = new PropertyMapper(member, mapping, myAccessorMapper); mapper.Access(Accessor.Field); - myAccessorMapper.AccessorCalled.Should().Be.True(); + Assert.That(myAccessorMapper.AccessorCalled, Is.True); } [Test] @@ -58,9 +58,9 @@ public void WhenSettingByTypeThenCheckCompatibility() var mapping = new HbmProperty(); var mapper = new PropertyMapper(member, mapping); - Executing.This(() => mapper.Access(typeof(object))).Should().Throw(); - Executing.This(() => mapper.Access(typeof(FieldAccessor))).Should().NotThrow(); - mapping.Access.Should().Be.EqualTo(typeof(FieldAccessor).AssemblyQualifiedName); + Assert.That(() => mapper.Access(typeof(object)), Throws.TypeOf()); + Assert.That(() => mapper.Access(typeof(FieldAccessor)), Throws.Nothing); + Assert.That(mapping.Access, Is.EqualTo(typeof(FieldAccessor).AssemblyQualifiedName)); } [Test] @@ -71,7 +71,7 @@ public void WhenSetTypeByITypeThenSetTypeName() var mapper = new PropertyMapper(member, mapping); mapper.Type(NHibernateUtil.String); - mapping.Type.name.Should().Be.EqualTo("String"); + Assert.That(mapping.Type.name, Is.EqualTo("String")); } [Test] @@ -82,8 +82,8 @@ public void WhenSetTypeByIUserTypeThenSetTypeName() var mapper = new PropertyMapper(member, mapping); mapper.Type(); - mapping.Type.name.Should().Contain("MyType"); - mapping.type.Should().Be.Null(); + Assert.That(mapping.Type.name, Is.StringContaining("MyType")); + Assert.That(mapping.type, Is.Null); } [Test] @@ -94,8 +94,8 @@ public void WhenSetTypeByICompositeUserTypeThenSetTypeName() var mapper = new PropertyMapper(member, mapping); mapper.Type(); - mapping.Type.name.Should().Contain("MyCompoType"); - mapping.type.Should().Be.Null(); + Assert.That(mapping.Type.name, Is.StringContaining("MyCompoType")); + Assert.That(mapping.type, Is.Null); } [Test] @@ -106,11 +106,11 @@ public void WhenSetTypeByIUserTypeWithParamsThenSetType() var mapper = new PropertyMapper(member, mapping); mapper.Type(new { Param1 = "a", Param2 = 12 }); - mapping.type1.Should().Be.Null(); - mapping.Type.name.Should().Contain("MyType"); - mapping.Type.param.Should().Have.Count.EqualTo(2); - mapping.Type.param.Select(p => p.name).Should().Have.SameValuesAs("Param1", "Param2"); - mapping.Type.param.Select(p => p.GetText()).Should().Have.SameValuesAs("a", "12"); + Assert.That(mapping.type1, Is.Null); + Assert.That(mapping.Type.name, Is.StringContaining("MyType")); + Assert.That(mapping.Type.param, Has.Length.EqualTo(2)); + Assert.That(mapping.Type.param.Select(p => p.name), Is.EquivalentTo(new [] {"Param1", "Param2"})); + Assert.That(mapping.Type.param.Select(p => p.GetText()), Is.EquivalentTo(new [] {"a", "12"})); } [Test] @@ -121,8 +121,8 @@ public void WhenSetTypeByIUserTypeWithNullParamsThenSetTypeName() var mapper = new PropertyMapper(member, mapping); mapper.Type(null); - mapping.Type.name.Should().Contain("MyType"); - mapping.type.Should().Be.Null(); + Assert.That(mapping.Type.name, Is.StringContaining("MyType")); + Assert.That(mapping.type, Is.Null); } [Test] @@ -133,8 +133,8 @@ public void WhenSetTypeByITypeTypeThenSetType() var mapper = new PropertyMapper(member, mapping); mapper.Type>(); - mapping.Type.name.Should().Contain(typeof(EnumStringType).FullName); - mapping.type.Should().Be.Null(); + Assert.That(mapping.Type.name, Is.StringContaining(typeof(EnumStringType).FullName)); + Assert.That(mapping.type, Is.Null); } [Test] @@ -143,8 +143,8 @@ public void WhenSetInvalidTypeThenThrow() var member = typeof(MyClass).GetProperty("ReadOnly"); var mapping = new HbmProperty(); var mapper = new PropertyMapper(member, mapping); - Executing.This(() => mapper.Type(typeof(object), null)).Should().Throw(); - Executing.This(() => mapper.Type(null, null)).Should().Throw(); + Assert.That(() => mapper.Type(typeof(object), null), Throws.TypeOf()); + Assert.That(() => mapper.Type(null, null), Throws.TypeOf()); } [Test] @@ -155,8 +155,8 @@ public void WhenSetDifferentColumnNameThenSetTheName() var mapper = new PropertyMapper(member, mapping); mapper.Column(cm => cm.Name("pepe")); - mapping.Columns.Should().Have.Count.EqualTo(1); - mapping.Columns.Single().name.Should().Be("pepe"); + Assert.That(mapping.Columns.Count(), Is.EqualTo(1)); + Assert.That(mapping.Columns.Single().name, Is.EqualTo("pepe")); } [Test] @@ -166,9 +166,9 @@ public void WhenSetDefaultColumnNameThenDoesNotSetTheName() var mapping = new HbmProperty(); var mapper = new PropertyMapper(member, mapping); mapper.Column(cm => { cm.Name("Autoproperty"); cm.Length(50); }); - mapping.column.Should().Be.Null(); - mapping.length.Should().Be("50"); - mapping.Columns.Should().Be.Empty(); + Assert.That(mapping.column, Is.Null); + Assert.That(mapping.length, Is.EqualTo("50")); + Assert.That(mapping.Columns, Is.Empty); } [Test] @@ -182,10 +182,10 @@ public void WhenSetBasicColumnValuesThenSetPlainValues() cm.Length(50); cm.NotNullable(true); }); - mapping.Items.Should().Be.Null(); - mapping.length.Should().Be("50"); - mapping.notnull.Should().Be(true); - mapping.notnullSpecified.Should().Be(true); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.length, Is.EqualTo("50")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.notnullSpecified, Is.EqualTo(true)); } [Test] @@ -199,8 +199,8 @@ public void WhenSetColumnValuesThenAddColumnTag() cm.SqlType("VARCHAR(50)"); cm.NotNullable(true); }); - mapping.Items.Should().Not.Be.Null(); - mapping.Columns.Should().Have.Count.EqualTo(1); + Assert.That(mapping.Items, Is.Not.Null); + Assert.That(mapping.Columns.Count(), Is.EqualTo(1)); } [Test] @@ -212,10 +212,10 @@ public void WhenSetBasicColumnValuesMoreThanOnesThenMergeColumn() mapper.Column(cm => cm.Length(50)); mapper.Column(cm => cm.NotNullable(true)); - mapping.Items.Should().Be.Null(); - mapping.length.Should().Be("50"); - mapping.notnull.Should().Be(true); - mapping.notnullSpecified.Should().Be(true); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.length, Is.EqualTo("50")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.notnullSpecified, Is.EqualTo(true)); } [Test] @@ -234,7 +234,7 @@ public void WhenSetMultiColumnsValuesThenAddColumns() cm.Name("column2"); cm.SqlType("VARCHAR(10)"); }); - mapping.Columns.Should().Have.Count.EqualTo(2); + Assert.That(mapping.Columns.Count(), Is.EqualTo(2)); } [Test] @@ -244,8 +244,8 @@ public void WhenSetMultiColumnsValuesThenAutoassignColumnNames() var mapping = new HbmProperty(); var mapper = new PropertyMapper(member, mapping); mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)")); - mapping.Columns.Should().Have.Count.EqualTo(2); - mapping.Columns.All(cm => cm.name.Satisfy(n => !string.IsNullOrEmpty(n))); + Assert.That(mapping.Columns.Count(), Is.EqualTo(2)); + Assert.True(mapping.Columns.All(cm => !string.IsNullOrEmpty(cm.name))); } [Test] @@ -255,7 +255,7 @@ public void AfterSetMultiColumnsCantSetSimpleColumn() var mapping = new HbmProperty(); var mapper = new PropertyMapper(member, mapping); mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)")); - Executing.This(() => mapper.Column(cm => cm.Length(50))).Should().Throw(); + Assert.That(() => mapper.Column(cm => cm.Length(50)), Throws.TypeOf()); } [Test] @@ -273,15 +273,15 @@ public void WhenSetBasicColumnValuesThroughShortCutThenMergeColumn() mapper.UniqueKey("AA"); mapper.Index("II"); - mapping.Items.Should().Be.Null(); - mapping.column.Should().Be("pizza"); - mapping.length.Should().Be("50"); - mapping.precision.Should().Be("10"); - mapping.scale.Should().Be("2"); - mapping.notnull.Should().Be(true); - mapping.unique.Should().Be(true); - mapping.uniquekey.Should().Be("AA"); - mapping.index.Should().Be("II"); + Assert.That(mapping.Items, Is.Null); + Assert.That(mapping.column, Is.EqualTo("pizza")); + Assert.That(mapping.length, Is.EqualTo("50")); + Assert.That(mapping.precision, Is.EqualTo("10")); + Assert.That(mapping.scale, Is.EqualTo("2")); + Assert.That(mapping.notnull, Is.EqualTo(true)); + Assert.That(mapping.unique, Is.EqualTo(true)); + Assert.That(mapping.uniquekey, Is.EqualTo("AA")); + Assert.That(mapping.index, Is.EqualTo("II")); } [Test] @@ -292,8 +292,8 @@ public void WhenSetUpdateThenSetAttributes() var mapper = new PropertyMapper(member, mapping); mapper.Update(false); - mapping.update.Should().Be.False(); - mapping.updateSpecified.Should().Be.True(); + Assert.That(mapping.update, Is.False); + Assert.That(mapping.updateSpecified, Is.True); } [Test] @@ -304,8 +304,8 @@ public void WhenSetInsertThenSetAttributes() var mapper = new PropertyMapper(member, mapping); mapper.Insert(false); - mapping.insert.Should().Be.False(); - mapping.insertSpecified.Should().Be.True(); + Assert.That(mapping.insert, Is.False); + Assert.That(mapping.insertSpecified, Is.True); } [Test] @@ -316,8 +316,8 @@ public void WhenSetLazyThenSetAttributes() var mapper = new PropertyMapper(member, mapping); mapper.Lazy(true); - mapping.lazy.Should().Be.True(); - mapping.IsLazyProperty.Should().Be.True(); + Assert.That(mapping.lazy, Is.True); + Assert.That(mapping.IsLazyProperty, Is.True); } } diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/SetPersisterTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/SetPersisterTests.cs index 163c1943886..88e603337b0 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/SetPersisterTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/SetPersisterTests.cs @@ -23,7 +23,7 @@ public void CanSetPersister() var mapdoc = new HbmMapping(); var rc = new SubclassMapper(typeof(HineritedSimple), mapdoc); rc.Persister(); - mapdoc.SubClasses[0].Persister.Should().Contain("SingleTableEntityPersister"); + Assert.That(mapdoc.SubClasses[0].Persister, Is.StringContaining("SingleTableEntityPersister")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/TablesSincronizationTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/TablesSincronizationTests.cs index 15acf884884..d62e51728f0 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/TablesSincronizationTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperTests/TablesSincronizationTests.cs @@ -23,7 +23,7 @@ public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new SubclassMapper(typeof(InheritedSimple), mapdoc); - rc.Executing(x => x.Synchronize(null)).NotThrows(); + Assert.That(() => rc.Synchronize(null), Throws.Nothing); } [Test] @@ -32,7 +32,7 @@ public void WhenSetSyncMixedWithNullAndEmptyThenAddOnlyValid() var mapdoc = new HbmMapping(); var rc = new SubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("", " ATable ", " ", null); - mapdoc.SubClasses[0].Synchronize.Single().table.Should().Be("ATable"); + Assert.That(mapdoc.SubClasses[0].Synchronize.Single().table, Is.EqualTo("ATable")); } [Test] @@ -41,7 +41,7 @@ public void WhenSetMoreSyncThenAddAll() var mapdoc = new HbmMapping(); var rc = new SubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2", "T3", null); - mapdoc.SubClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.SubClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -51,7 +51,7 @@ public void WhenSetMoreThenOnceThenAddAll() var rc = new SubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3"); - mapdoc.SubClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.SubClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -61,7 +61,7 @@ public void WhenSetMoreThenOnceThenDoesNotDuplicate() var rc = new SubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3", "T2"); - mapdoc.SubClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.SubClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperWithJoinPropertiesTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperWithJoinPropertiesTest.cs index cd28a71517a..30675953299 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperWithJoinPropertiesTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/SubclassMapperWithJoinPropertiesTest.cs @@ -28,9 +28,9 @@ public void WhenDefineJoinThenAddJoinWithTableNameAndKey() var hbmClass = mapdoc.SubClasses[0]; var hbmJoin = hbmClass.Joins.Single(); - hbmJoin.table.Should().Be("MyTable"); - hbmJoin.key.Should().Not.Be.Null(); - hbmJoin.key.column1.Should().Not.Be.Null(); + Assert.That(hbmJoin.table, Is.EqualTo("MyTable")); + Assert.That(hbmJoin.key, Is.Not.Null); + Assert.That(hbmJoin.key.column1, Is.Not.Null); } [Test] @@ -41,11 +41,11 @@ public void WhenDefineJoinThenCallJoinMapper() var called = false; mapper.Join("MyTable", x => { - x.Should().Not.Be.Null(); + Assert.That(x, Is.Not.Null); called = true; }); - called.Should().Be.True(); + Assert.That(called, Is.True); } [Test] @@ -58,8 +58,8 @@ public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() mapper.Join("T2", x => { }); var hbmClass = mapdoc.SubClasses[0]; - hbmClass.Joins.Should().Have.Count.EqualTo(2); - hbmClass.Joins.Select(x => x.table).Should().Have.UniqueValues(); + Assert.That(hbmClass.Joins.Count(), Is.EqualTo(2)); + Assert.That(hbmClass.Joins.Select(x => x.table), Is.Unique); } [Test] @@ -73,9 +73,9 @@ public void WhenDefineMoreJoinsWithSameIdThenUseSameJoinMapperInstance() mapper.Join("T1", x => firstCallInstance = x); mapper.Join("T1", x => secondCallInstance = x); - firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance); + Assert.That(firstCallInstance, Is.SameAs(secondCallInstance)); var hbmClass = mapdoc.SubClasses[0]; - hbmClass.Joins.Should().Have.Count.EqualTo(1); + Assert.That(hbmClass.Joins.Count(), Is.EqualTo(1)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/SetPersisterTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/SetPersisterTests.cs index 44cbd9029ed..8bde8d3d335 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/SetPersisterTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/SetPersisterTests.cs @@ -23,7 +23,7 @@ public void CanSetPersister() var mapdoc = new HbmMapping(); var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Persister(); - mapdoc.UnionSubclasses[0].Persister.Should().Contain("UnionSubclassEntityPersister"); + Assert.That(mapdoc.UnionSubclasses[0].Persister, Is.StringContaining("UnionSubclassEntityPersister")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/TablesSincronizationTests.cs b/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/TablesSincronizationTests.cs index 1cb7ef881d3..32c2b91a9b7 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/TablesSincronizationTests.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/UnionSubclassMapperTests/TablesSincronizationTests.cs @@ -23,7 +23,7 @@ public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); - rc.Executing(x => x.Synchronize(null)).NotThrows(); + Assert.That(() => rc.Synchronize(null), Throws.Nothing); } [Test] @@ -32,7 +32,7 @@ public void WhenSetSyncMixedWithNullAndEmptyThenAddOnlyValid() var mapdoc = new HbmMapping(); var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("", " ATable ", " ", null); - mapdoc.UnionSubclasses[0].Synchronize.Single().table.Should().Be("ATable"); + Assert.That(mapdoc.UnionSubclasses[0].Synchronize.Single().table, Is.EqualTo("ATable")); } [Test] @@ -41,7 +41,7 @@ public void WhenSetMoreSyncThenAddAll() var mapdoc = new HbmMapping(); var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2", "T3", null); - mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -51,7 +51,7 @@ public void WhenSetMoreThenOnceThenAddAll() var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3"); - mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } [Test] @@ -61,7 +61,7 @@ public void WhenSetMoreThenOnceThenDoesNotDuplicate() var rc = new UnionSubclassMapper(typeof(InheritedSimple), mapdoc); rc.Synchronize("T1", "T2"); rc.Synchronize("T3", "T2"); - mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); + Assert.That(mapdoc.UnionSubclasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/ArrayCollectionTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/ArrayCollectionTests.cs index 0430cb6c94b..77c72bfe56d 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/ArrayCollectionTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/ArrayCollectionTests.cs @@ -38,7 +38,7 @@ public void MatchWithArrayProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.True(); + Assert.That(inspector.IsArray(mi), Is.True); } [Test] @@ -48,7 +48,7 @@ public void MatchWithArrayField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.True(); + Assert.That(inspector.IsArray(mi), Is.True); } [Test] @@ -58,7 +58,7 @@ public void MatchWithCollectionPropertyAndArrayField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.True(); + Assert.That(inspector.IsArray(mi), Is.True); } [Test] @@ -68,7 +68,7 @@ public void NotMatchWithCollectionField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.False(); + Assert.That(inspector.IsArray(mi), Is.False); } [Test] @@ -78,7 +78,7 @@ public void NotMatchWithCollectionProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.False(); + Assert.That(inspector.IsArray(mi), Is.False); } [Test] @@ -88,7 +88,7 @@ public void NotMatchWithNoArrayCollectionProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.False(); + Assert.That(inspector.IsArray(mi), Is.False); } [Test] @@ -98,7 +98,7 @@ public void NotMatchWithStringProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.False(); + Assert.That(inspector.IsArray(mi), Is.False); } [Test] @@ -108,7 +108,7 @@ public void NotMatchWithByteArrayProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsArray(mi).Should().Be.False(); + Assert.That(inspector.IsArray(mi), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs index a204bfd1ea1..6d61c6d5c64 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs @@ -42,7 +42,7 @@ public void MatchWithEnumerableProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsBag(mi).Should().Be.True(); + Assert.That(inspector.IsBag(mi), Is.True); } [Test] @@ -52,7 +52,7 @@ public void MatchWithEnumerableField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsBag(mi).Should().Be.True(); + Assert.That(inspector.IsBag(mi), Is.True); } [Test] @@ -62,7 +62,7 @@ public void MatchWithObjectPropertyAndEnumerableField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsBag(mi).Should().Be.True(); + Assert.That(inspector.IsBag(mi), Is.True); } [Test] @@ -72,7 +72,7 @@ public void NotMatchWithStringProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsBag(mi).Should().Be.False(); + Assert.That(inspector.IsBag(mi), Is.False); } [Test] @@ -82,7 +82,7 @@ public void NotMatchWithByteArrayProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsBag(mi).Should().Be.False(); + Assert.That(inspector.IsBag(mi), Is.False); } [Test] @@ -94,7 +94,7 @@ public void WhenSetKeyThroughEventThenUseEvent() var hbmMapping = mapper.CompileMappingFor(new[] {typeof(Parent)}); var hbmBag = hbmMapping.RootClasses[0].Properties.OfType().Single(); - hbmBag.Key.Columns.Single().name.Should().Be("ParentId"); + Assert.That(hbmBag.Key.Columns.Single().name, Is.EqualTo("ParentId")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/CallCustomConditions.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/CallCustomConditions.cs index 12443e4c020..b7bae336173 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/CallCustomConditions.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/CallCustomConditions.cs @@ -62,7 +62,7 @@ public void WhenCustomizeConditionsThenUseCustomConditionsToRecognizeRootEntitie }); mapper.Subclass(map => map.DiscriminatorValue(1)); - mapper.Executing(m=> m.CompileMappingFor(new[] { typeof(Activity), typeof(FormActivity) })).NotThrows(); + Assert.That(() => mapper.CompileMappingFor(new[] { typeof(Activity), typeof(FormActivity) }), Throws.Nothing); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/ComponentsTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/ComponentsTests.cs index 32f88991c8c..64b52a9d194 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/ComponentsTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/ComponentsTests.cs @@ -33,7 +33,7 @@ public void WhenAClassIsExplicitlyDeclaredAsComponentThenIsComponent() mapper.Component(map => { }); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(AEntity)).Should().Be.True(); + Assert.That(inspector.IsComponent(typeof(AEntity)), Is.True); } [Test] @@ -41,7 +41,7 @@ public void ClassWithoutPoidIsComponent() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(AComponent)).Should().Be.True(); + Assert.That(inspector.IsComponent(typeof(AComponent)), Is.True); } [Test] @@ -49,7 +49,7 @@ public void ClassWithPoidIsNotComponent() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(AEntity)).Should().Be.False(); + Assert.That(inspector.IsComponent(typeof(AEntity)), Is.False); } [Test] @@ -57,7 +57,7 @@ public void ClassWithPoidFieldIsNotComponent() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(Entity)).Should().Be.False(); + Assert.That(inspector.IsComponent(typeof(Entity)), Is.False); } [Test] @@ -65,7 +65,7 @@ public void EnumIsNotComponent() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(Something)).Should().Be.False(); + Assert.That(inspector.IsComponent(typeof(Something)), Is.False); } [Test] @@ -73,7 +73,7 @@ public void StringIsNotComponent() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsComponent(typeof(string)).Should().Be.False(); + Assert.That(inspector.IsComponent(typeof(string)), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/DefaultClassHierarchyRepresentationTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/DefaultClassHierarchyRepresentationTests.cs index 805b4e69384..911fc48cd15 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/DefaultClassHierarchyRepresentationTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/DefaultClassHierarchyRepresentationTests.cs @@ -23,8 +23,8 @@ public void WhenNotExplicitlyDeclaredThenIsTablePerClass() mapper.Class(x => { }); var inspector = (IModelInspector)autoinspector; - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True(); - inspector.IsTablePerClass(typeof(Inherited)).Should().Be.True(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.True); + Assert.That(inspector.IsTablePerClass(typeof(Inherited)), Is.True); } [Test] @@ -37,8 +37,8 @@ public void WhenExplicitlyDeclaredAsSubclassThenIsNotTablePerClass() var inspector = (IModelInspector)autoinspector; - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClass(typeof(Inherited)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClass(typeof(Inherited)), Is.False); } [Test] @@ -51,8 +51,8 @@ public void WhenExplicitlyDeclaredAsUnionSubclassThenIsNotTablePerClass() var inspector = (IModelInspector)autoinspector; - inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False(); - inspector.IsTablePerClass(typeof(Inherited)).Should().Be.False(); + Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.False); + Assert.That(inspector.IsTablePerClass(typeof(Inherited)), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/DictionaryCollectionTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/DictionaryCollectionTests.cs index 064ea0ba317..16d9766b798 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/DictionaryCollectionTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/DictionaryCollectionTests.cs @@ -32,7 +32,7 @@ public void MatchWithDictionaryProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsDictionary(mi).Should().Be.True(); + Assert.That(inspector.IsDictionary(mi), Is.True); } [Test] @@ -42,7 +42,7 @@ public void MatchWithDictionaryField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsDictionary(mi).Should().Be.True(); + Assert.That(inspector.IsDictionary(mi), Is.True); } [Test] @@ -52,7 +52,7 @@ public void MatchWithCollectionPropertyAndDictionaryField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsDictionary(mi).Should().Be.True(); + Assert.That(inspector.IsDictionary(mi), Is.True); } [Test] @@ -62,7 +62,7 @@ public void NotMatchWithCollectionField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsDictionary(mi).Should().Be.False(); + Assert.That(inspector.IsDictionary(mi), Is.False); } [Test] @@ -72,7 +72,7 @@ public void NotMatchWithCollectionProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsDictionary(mi).Should().Be.False(); + Assert.That(inspector.IsDictionary(mi), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/EntityTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/EntityTests.cs index ec326833170..80586b9e905 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/EntityTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/EntityTests.cs @@ -32,7 +32,7 @@ public void WhenAClassIsExplicitlyDeclaredAsEntityThenIsEntity() mapper.Class(map => { }); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(AComponent)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(AComponent)), Is.True); } [Test] @@ -40,7 +40,7 @@ public void ClassWithPoidIsEntity() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(AEntity)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(AEntity)), Is.True); } [Test] @@ -48,7 +48,7 @@ public void ClassWithoutPoidIsNotEntity() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(AComponent)).Should().Be.False(); + Assert.That(inspector.IsEntity(typeof(AComponent)), Is.False); } [Test] @@ -56,7 +56,7 @@ public void ClassWithPoidFieldIsEntity() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(Entity)).Should().Be.True(); + Assert.That(inspector.IsEntity(typeof(Entity)), Is.True); } [Test] @@ -64,7 +64,7 @@ public void EnumIsNotEntity() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(Something)).Should().Be.False(); + Assert.That(inspector.IsEntity(typeof(Something)), Is.False); } [Test] @@ -72,7 +72,7 @@ public void StringIsNotEntity() { var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsEntity(typeof(string)).Should().Be.False(); + Assert.That(inspector.IsEntity(typeof(string)), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/InheritedVersionTest.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/InheritedVersionTest.cs index 87876d0341a..6e9ca46303c 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/InheritedVersionTest.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/InheritedVersionTest.cs @@ -28,7 +28,7 @@ public void WhenPropertyVersionFromBaseEntityThenFindItAsVersion() map.Version(x => x.Version, vm => { }); }); - inspector.IsVersion(For.Property(x => x.Version)).Should().Be.True(); + Assert.That(inspector.IsVersion(For.Property(x => x.Version)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/ManyToOneTest.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/ManyToOneTest.cs index faa04e4da3e..49482789b3a 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/ManyToOneTest.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/ManyToOneTest.cs @@ -25,7 +25,7 @@ public void WhenRelationWithTwoEntityThenIsManyToOne() autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t)); var inspector = (IModelInspector)autoinspector; - inspector.IsManyToOne(typeof(AEntity).GetProperty("B")).Should().Be.True(); + Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.True); } [Test] @@ -35,7 +35,7 @@ public void WhenSimplePropertyThenIsNotManyToOne() autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t)); var inspector = (IModelInspector)autoinspector; - inspector.IsManyToOne(typeof(AEntity).GetProperty("Name")).Should().Be.False(); + Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("Name")), Is.False); } [Test] @@ -46,7 +46,7 @@ public void WhenRelatedMatchComponentThenIsNotManyToOne() autoinspector.IsComponent((t, declared) => typeof(BEntity).Equals(t)); var inspector = (IModelInspector)autoinspector; - inspector.IsManyToOne(typeof(AEntity).GetProperty("B")).Should().Be.False(); + Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.False); } [Test] @@ -57,7 +57,7 @@ public void WhenRelatedDeclaredAsOneToOneThenIsNotManyToOne() mapper.Class(map => map.OneToOne(a => a.B, x => { })); mapper.Class(x=> { }); var inspector = (IModelInspector)autoinspector; - inspector.IsManyToOne(typeof(AEntity).GetProperty("B")).Should().Be.False(); + Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/OneToManyTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/OneToManyTests.cs index 5a9277a1358..640a7381e88 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/OneToManyTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/OneToManyTests.cs @@ -48,7 +48,7 @@ public void WhenNoCollectionPropertyThenNoMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Something); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.False(); + Assert.That(inspector.IsOneToMany(pi), Is.False); } [Test] @@ -57,7 +57,7 @@ public void WhenCollectionOfComponentsThenNoMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Components); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.False(); + Assert.That(inspector.IsOneToMany(pi), Is.False); } [Test] @@ -66,7 +66,7 @@ public void WhenCollectionBidirectionalThenMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Children); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.True(); + Assert.That(inspector.IsOneToMany(pi), Is.True); } [Test] @@ -75,7 +75,7 @@ public void WhenCollectionOfElementsThenNoMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Elements); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.False(); + Assert.That(inspector.IsOneToMany(pi), Is.False); } [Test] @@ -84,7 +84,7 @@ public void WhenCollectionUnidirectionalThenMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Relateds); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.True(); + Assert.That(inspector.IsOneToMany(pi), Is.True); } [Test] @@ -93,7 +93,7 @@ public void WhenDictionaryBidirectionalThenMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.DicChildren); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.True(); + Assert.That(inspector.IsOneToMany(pi), Is.True); } [Test] @@ -102,7 +102,7 @@ public void WhenDictionaryUnidirectionalThenMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.DicRelateds); var inspector = GetConfiguredInspector(); - inspector.IsOneToMany(pi).Should().Be.True(); + Assert.That(inspector.IsOneToMany(pi), Is.True); } [Test] @@ -117,7 +117,7 @@ public void WhenCollectionUnidirectionalDeclaredManyToManyThenNoMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.Relateds); - inspector.IsOneToMany(pi).Should().Be.False(); + Assert.That(inspector.IsOneToMany(pi), Is.False); } [Test] @@ -132,7 +132,7 @@ public void WhenDictionaryUnidirectionalDeclaredManyToManyThenNoMatch() var pi = Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(x => x.DicRelateds); - inspector.IsOneToMany(pi).Should().Be.False(); + Assert.That(inspector.IsOneToMany(pi), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/PoidTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/PoidTests.cs index b4433bb4659..ccbaecc5612 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/PoidTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/PoidTests.cs @@ -30,7 +30,7 @@ public void WhenExplicitDeclaredThenMatch() mapper.Class(map => map.Id(x => x.EntityIdentificator)); var inspector = (IModelInspector)autoinspector; - inspector.IsPersistentId(typeof(MyClass).GetProperty("EntityIdentificator")).Should().Be.True(); + Assert.That(inspector.IsPersistentId(typeof(MyClass).GetProperty("EntityIdentificator")), Is.True); } [Test] @@ -39,12 +39,12 @@ public void WhenNotExplicitlyDeclaredMatchDefaultDelegate() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsPersistentId(typeof(TestEntity).GetProperty("Id")).Should().Be.True(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("id")).Should().Be.True(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("PoId")).Should().Be.True(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("POID")).Should().Be.True(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("OId")).Should().Be.True(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("TestEntityId")).Should().Be.True(); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("Id")), Is.True); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("id")), Is.True); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("PoId")), Is.True); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("POID")), Is.True); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("OId")), Is.True); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("TestEntityId")), Is.True); } [Test] @@ -53,8 +53,8 @@ public void WhenNotExplicitlyDeclaredThenNoMatchPropertiesOutOfDefaultDelegate() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsPersistentId(typeof(TestEntity).GetProperty("testEntityId")).Should().Be.False(); - inspector.IsPersistentId(typeof(TestEntity).GetProperty("Something")).Should().Be.False(); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("testEntityId")), Is.False); + Assert.That(inspector.IsPersistentId(typeof(TestEntity).GetProperty("Something")), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/PolymorphicPropertiesMapping.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/PolymorphicPropertiesMapping.cs index b248f8567d8..26ff5186f32 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/PolymorphicPropertiesMapping.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/PolymorphicPropertiesMapping.cs @@ -49,7 +49,7 @@ public void WhenMapIdThroughBaseInterfaceThenFindIt() { map.Id(x => x.Id, idmap => { }); }); - inspector.IsPersistentId(typeof(Product).GetProperty("Id", RootClassPropertiesBindingFlags)).Should().Be.True(); + Assert.That(inspector.IsPersistentId(typeof(Product).GetProperty("Id", RootClassPropertiesBindingFlags)), Is.True); } [Test] @@ -60,7 +60,7 @@ public void WhenMapPropertyThroughBaseConcreteClassThenFindIt() mapper.Class(map => map.Property(x => x.LastChange)); - inspector.IsPersistentProperty(typeof(Product).GetProperty("LastChange", RootClassPropertiesBindingFlags)).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(typeof(Product).GetProperty("LastChange", RootClassPropertiesBindingFlags)), Is.True); } [Test] @@ -71,7 +71,7 @@ public void WhenMapPropertyThroughBaseInterfaceThenFindIt() mapper.Class(map => map.Property(x => x.Description)); - inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)), Is.True); } [Test] @@ -82,7 +82,7 @@ public void WhenMapPropertyThroughBaseAbstractClassThenFindIt() mapper.Class(map => map.Property(x => x.Description)); - inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)), Is.True); } [Test] @@ -93,7 +93,7 @@ public void WhenMapPropertyThroughClassThenFindIt() mapper.Class(map => map.Property(x => x.Description)); - inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(typeof(Product).GetProperty("Description", RootClassPropertiesBindingFlags)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/PropertiesExclusionTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/PropertiesExclusionTests.cs index f6ec01e7929..8a54933f06a 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/PropertiesExclusionTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/PropertiesExclusionTests.cs @@ -46,7 +46,7 @@ public void WhenReadonlyDeclaredThenIsPersistentProperty() mapper.Class(map => map.Property(x => x.ReadOnly)); var inspector = (IModelInspector)autoinspector; - inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")), Is.True); } [Test] @@ -55,7 +55,7 @@ public void WhenReadonlyNotDeclaredThenIsNotPersistentProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")).Should().Be.False(); + Assert.That(inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")), Is.False); } [Test] @@ -65,7 +65,7 @@ public void IncludesReadOnlyWithField() var inspector = (IModelInspector)autoinspector; PropertyInfo pi = typeof(MyEntity).GetProperty("NoReadOnlyWithField"); - inspector.IsPersistentProperty(pi).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(pi), Is.True); } [Test] @@ -75,10 +75,10 @@ public void IncludesNoReadOnly() var inspector = (IModelInspector)autoinspector; PropertyInfo pi = typeof(MyEntity).GetProperty("NoReadOnly"); - inspector.IsPersistentProperty(pi).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(pi), Is.True); pi = typeof(MyEntity).GetProperty("WriteOnly"); - inspector.IsPersistentProperty(pi).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(pi), Is.True); } [Test] @@ -90,7 +90,7 @@ public void IncludesFieldsWhenExplicitDeclared() var inspector = (IModelInspector)autoinspector; var pi = typeof(MyEntity).GetField("pizza", BindingFlags.Instance | BindingFlags.NonPublic); - inspector.IsPersistentProperty(pi).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(pi), Is.True); } [Test] @@ -100,7 +100,7 @@ public void DoesNotIncludesFieldsByDefault() var inspector = (IModelInspector)autoinspector; var pi = typeof(MyEntity).GetField("pizza", BindingFlags.Instance | BindingFlags.NonPublic); - inspector.IsPersistentProperty(pi).Should().Be.False(); + Assert.That(inspector.IsPersistentProperty(pi), Is.False); } [Test] @@ -110,7 +110,7 @@ public void IncludesAutoprop() var inspector = (IModelInspector)autoinspector; var pi = typeof(MyEntity).GetProperty("AutoPropWithPrivateSet"); - inspector.IsPersistentProperty(pi).Should().Be.True(); + Assert.That(inspector.IsPersistentProperty(pi), Is.True); } } diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/RootEntityTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/RootEntityTests.cs index fe0ac1efe58..0a7265ab6ba 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/RootEntityTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/RootEntityTests.cs @@ -26,8 +26,8 @@ public void ByDefaultInheritedFromObject() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsRootEntity(typeof(Person)).Should().Be.True(); - inspector.IsRootEntity(typeof(Product)).Should().Be.False(); + Assert.That(inspector.IsRootEntity(typeof(Person)), Is.True); + Assert.That(inspector.IsRootEntity(typeof(Product)), Is.False); } [Test] @@ -38,8 +38,8 @@ public void WhenCustomizedThenUseCustomizedPredicate() var inspector = (IModelInspector)autoinspector; - inspector.IsRootEntity(typeof(Person)).Should().Be.False(); - inspector.IsRootEntity(typeof(Product)).Should().Be.True(); + Assert.That(inspector.IsRootEntity(typeof(Person)), Is.False); + Assert.That(inspector.IsRootEntity(typeof(Product)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/MixAutomapping/SetCollectionTests.cs b/src/NHibernate.Test/MappingByCode/MixAutomapping/SetCollectionTests.cs index 3d5017a64a6..51a5f80ac55 100644 --- a/src/NHibernate.Test/MappingByCode/MixAutomapping/SetCollectionTests.cs +++ b/src/NHibernate.Test/MappingByCode/MixAutomapping/SetCollectionTests.cs @@ -32,7 +32,7 @@ public void MatchWithSetProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.True(); + Assert.That(inspector.IsSet(mi), Is.True); } [Test] @@ -42,7 +42,7 @@ public void MatchWithSetField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.True(); + Assert.That(inspector.IsSet(mi), Is.True); } [Test] @@ -52,7 +52,7 @@ public void MatchWithCollectionPropertyAndSetField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.True(); + Assert.That(inspector.IsSet(mi), Is.True); } [Test] @@ -62,7 +62,7 @@ public void NotMatchWithCollectionField() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.False(); + Assert.That(inspector.IsSet(mi), Is.False); } [Test] @@ -72,7 +72,7 @@ public void NotMatchWithCollectionProperty() var autoinspector = new SimpleModelInspector(); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.False(); + Assert.That(inspector.IsSet(mi), Is.False); } [Test] @@ -84,7 +84,7 @@ public void WhenExplicitDeclaredThenMatchWithCollectionProperty() mapper.Class(map => map.Set(x => x.Others, x => { }, y=> {})); var inspector = (IModelInspector)autoinspector; - inspector.IsSet(mi).Should().Be.True(); + Assert.That(inspector.IsSet(mi), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/ModelExplicitDeclarationsHolderMergeTest.cs b/src/NHibernate.Test/MappingByCode/ModelExplicitDeclarationsHolderMergeTest.cs index a10cdc35675..797981cfaff 100644 --- a/src/NHibernate.Test/MappingByCode/ModelExplicitDeclarationsHolderMergeTest.cs +++ b/src/NHibernate.Test/MappingByCode/ModelExplicitDeclarationsHolderMergeTest.cs @@ -320,8 +320,8 @@ public void AddAsDynamicComponent(MemberInfo member, System.Type componentTempla [Test] public void WhenMergeNullsThenNotThrows() { - Executing.This(() => ((ExplicitDeclarationsHolder) null).Merge(new ExplicitDeclarationsHolder())).Should().NotThrow(); - Executing.This(() => (new ExplicitDeclarationsHolder()).Merge(null)).Should().NotThrow(); + Assert.That(() => ((ExplicitDeclarationsHolder) null).Merge(new ExplicitDeclarationsHolder()), Throws.Nothing); + Assert.That(() => (new ExplicitDeclarationsHolder()).Merge(null), Throws.Nothing); } [Test] @@ -332,7 +332,7 @@ public void MergeSplitDefinitions() source.AddAsPropertySplit(new SplitDefinition(typeof (MyClass), "foo", property)); destination.Merge(source); - destination.SplitDefinitions.Should().Have.Count.EqualTo(1); + Assert.That(destination.SplitDefinitions, Has.Count.EqualTo(1)); } [Test] @@ -343,7 +343,7 @@ public void MergePersistentMembers() source.AddAsPersistentMember(property); destination.Merge(source); - destination.PersistentMembers.Should().Have.Count.EqualTo(1); + Assert.That(destination.PersistentMembers, Has.Count.EqualTo(1)); } [Test] @@ -354,7 +354,7 @@ public void MergeProperties() source.AddAsProperty(property); destination.Merge(source); - destination.Properties.Should().Have.Count.EqualTo(1); + Assert.That(destination.Properties, Has.Count.EqualTo(1)); } [Test] @@ -365,7 +365,7 @@ public void MergeDictionaries() source.AddAsMap(property); destination.Merge(source); - destination.Dictionaries.Should().Have.Count.EqualTo(1); + Assert.That(destination.Dictionaries, Has.Count.EqualTo(1)); } [Test] @@ -376,7 +376,7 @@ public void MergeArrays() source.AddAsArray(property); destination.Merge(source); - destination.Arrays.Should().Have.Count.EqualTo(1); + Assert.That(destination.Arrays, Has.Count.EqualTo(1)); } [Test] @@ -387,7 +387,7 @@ public void MergeLists() source.AddAsList(property); destination.Merge(source); - destination.Lists.Should().Have.Count.EqualTo(1); + Assert.That(destination.Lists, Has.Count.EqualTo(1)); } [Test] @@ -398,7 +398,7 @@ public void MergeIdBags() source.AddAsIdBag(property); destination.Merge(source); - destination.IdBags.Should().Have.Count.EqualTo(1); + Assert.That(destination.IdBags, Has.Count.EqualTo(1)); } [Test] @@ -409,7 +409,7 @@ public void MergeBags() source.AddAsBag(property); destination.Merge(source); - destination.Bags.Should().Have.Count.EqualTo(1); + Assert.That(destination.Bags, Has.Count.EqualTo(1)); } [Test] @@ -420,7 +420,7 @@ public void MergeSets() source.AddAsSet(property); destination.Merge(source); - destination.Sets.Should().Have.Count.EqualTo(1); + Assert.That(destination.Sets, Has.Count.EqualTo(1)); } [Test] @@ -431,7 +431,7 @@ public void MergeNaturalIds() source.AddAsNaturalId(property); destination.Merge(source); - destination.NaturalIds.Should().Have.Count.EqualTo(1); + Assert.That(destination.NaturalIds, Has.Count.EqualTo(1)); } [Test] @@ -442,7 +442,7 @@ public void MergeVersionProperties() source.AddAsVersionProperty(property); destination.Merge(source); - destination.VersionProperties.Should().Have.Count.EqualTo(1); + Assert.That(destination.VersionProperties, Has.Count.EqualTo(1)); } [Test] @@ -453,7 +453,7 @@ public void MergePoids() source.AddAsPoid(property); destination.Merge(source); - destination.Poids.Should().Have.Count.EqualTo(1); + Assert.That(destination.Poids, Has.Count.EqualTo(1)); } [Test] @@ -464,7 +464,7 @@ public void MergeAny() source.AddAsAny(property); destination.Merge(source); - destination.Any.Should().Have.Count.EqualTo(1); + Assert.That(destination.Any, Has.Count.EqualTo(1)); } [Test] @@ -475,7 +475,7 @@ public void MergeOneToManyRelations() source.AddAsOneToManyRelation(property); destination.Merge(source); - destination.OneToManyRelations.Should().Have.Count.EqualTo(1); + Assert.That(destination.OneToManyRelations, Has.Count.EqualTo(1)); } [Test] @@ -486,7 +486,7 @@ public void MergeManyToAnyRelations() source.AddAsManyToAnyRelation(property); destination.Merge(source); - destination.ManyToAnyRelations.Should().Have.Count.EqualTo(1); + Assert.That(destination.ManyToAnyRelations, Has.Count.EqualTo(1)); } [Test] @@ -497,7 +497,7 @@ public void MergeManyToManyRelations() source.AddAsManyToManyRelation(property); destination.Merge(source); - destination.ManyToManyRelations.Should().Have.Count.EqualTo(1); + Assert.That(destination.ManyToManyRelations, Has.Count.EqualTo(1)); } [Test] @@ -508,7 +508,7 @@ public void MergeManyToOneRelations() source.AddAsManyToOneRelation(property); destination.Merge(source); - destination.ManyToOneRelations.Should().Have.Count.EqualTo(1); + Assert.That(destination.ManyToOneRelations, Has.Count.EqualTo(1)); } [Test] @@ -519,7 +519,7 @@ public void MergeOneToOneRelations() source.AddAsOneToOneRelation(property); destination.Merge(source); - destination.OneToOneRelations.Should().Have.Count.EqualTo(1); + Assert.That(destination.OneToOneRelations, Has.Count.EqualTo(1)); } [Test] @@ -530,7 +530,7 @@ public void MergeTablePerConcreteClassEntities() source.AddAsTablePerConcreteClassEntity(typeof (MyClass)); destination.Merge(source); - destination.TablePerConcreteClassEntities.Should().Have.Count.EqualTo(1); + Assert.That(destination.TablePerConcreteClassEntities, Has.Count.EqualTo(1)); } [Test] @@ -541,7 +541,7 @@ public void MergeTablePerClassHierarchyEntities() source.AddAsTablePerClassHierarchyEntity(typeof (MyClass)); destination.Merge(source); - destination.TablePerClassHierarchyEntities.Should().Have.Count.EqualTo(1); + Assert.That(destination.TablePerClassHierarchyEntities, Has.Count.EqualTo(1)); } [Test] @@ -552,7 +552,7 @@ public void MergeTablePerClassEntities() source.AddAsTablePerClassEntity(typeof (MyClass)); destination.Merge(source); - destination.TablePerClassEntities.Should().Have.Count.EqualTo(1); + Assert.That(destination.TablePerClassEntities, Has.Count.EqualTo(1)); } [Test] @@ -563,7 +563,7 @@ public void MergeComponents() source.AddAsComponent(typeof (MyClass)); destination.Merge(source); - destination.Components.Should().Have.Count.EqualTo(1); + Assert.That(destination.Components, Has.Count.EqualTo(1)); } [Test] @@ -574,7 +574,7 @@ public void MergeRootEntities() source.AddAsRootEntity(typeof (MyClass)); destination.Merge(source); - destination.RootEntities.Should().Have.Count.EqualTo(1); + Assert.That(destination.RootEntities, Has.Count.EqualTo(1)); } [Test] @@ -585,8 +585,8 @@ public void MergeDynamicComponents() source.AddAsDynamicComponent(property, typeof(MyClass)); destination.Merge(source); - destination.DynamicComponents.Should().Have.Count.EqualTo(1); - destination.GetDynamicComponentTemplate(property).Should().Be(typeof(MyClass)); + Assert.That(destination.DynamicComponents, Has.Count.EqualTo(1)); + Assert.That(destination.GetDynamicComponentTemplate(property), Is.EqualTo(typeof(MyClass))); } [Test] @@ -597,7 +597,7 @@ public void MergeComposedId() source.AddAsPartOfComposedId(property); destination.Merge(source); - destination.ComposedIds.Should().Have.Count.EqualTo(1); + Assert.That(destination.ComposedIds, Has.Count.EqualTo(1)); } [Test] @@ -612,7 +612,7 @@ public void MergeShouldGetAllPropertiesOfPatternsAppliersHolderOfBothSide() first.Merge(second); - second.PropertiesGettersUsed.Should().Have.SameValuesAs(propertiesOfIPatternsAppliersHolder); + Assert.That(second.PropertiesGettersUsed, Is.EquivalentTo(propertiesOfIPatternsAppliersHolder)); } #region Nested type: MyClass diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/CompatibilityWithCandidatePersistentMembers.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/CompatibilityWithCandidatePersistentMembers.cs index baeab1b5418..01cbf7f018e 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/CompatibilityWithCandidatePersistentMembers.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/CompatibilityWithCandidatePersistentMembers.cs @@ -23,7 +23,7 @@ public void GetFirstPropertyOfTypeShouldUseSameConceptsOfCandidatePersistentMemb var properties = memberProvider.GetRootEntityMembers(typeof(Geo)); if(properties.Select(p => p.Name).Contains("Parent")) { - typeof(Geo).GetFirstPropertyOfType(typeof(Geo)).Should().Not.Be.Null(); + Assert.That(typeof(Geo).GetFirstPropertyOfType(typeof(Geo)), Is.Not.Null); } } } diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorConcreteClassesTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorConcreteClassesTest.cs index 0b6dd458932..1f2a2bd6c19 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorConcreteClassesTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorConcreteClassesTest.cs @@ -26,28 +26,28 @@ private class MyClass4 : MyClass3 [Test] public void WhenImplIsAtSameLevelThenReturnImplementor() { - typeof(MyClass1).GetFirstImplementorOf(typeof(MyClass1)).Should().Be(typeof(MyClass1)); - typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass2)).Should().Be(typeof(MyClass2)); - typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass3)).Should().Be(typeof(MyClass3)); - typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass4)).Should().Be(typeof(MyClass4)); + Assert.That(typeof(MyClass1).GetFirstImplementorOf(typeof(MyClass1)), Is.EqualTo(typeof(MyClass1))); + Assert.That(typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass2)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass3)), Is.EqualTo(typeof(MyClass3))); + Assert.That(typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass4)), Is.EqualTo(typeof(MyClass4))); } [Test] public void WhenImplIsAtDifferentLevelThenReturnImplementor() { - typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass1)).Should().Be(typeof(MyClass2)); - typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass1)).Should().Be(typeof(MyClass2)); - typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass2)).Should().Be(typeof(MyClass3)); - typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass1)).Should().Be(typeof(MyClass2)); - typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass2)).Should().Be(typeof(MyClass3)); - typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass3)).Should().Be(typeof(MyClass4)); + Assert.That(typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass1)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass1)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass2)), Is.EqualTo(typeof(MyClass3))); + Assert.That(typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass1)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass2)), Is.EqualTo(typeof(MyClass3))); + Assert.That(typeof(MyClass4).GetFirstImplementorOf(typeof(MyClass3)), Is.EqualTo(typeof(MyClass4))); } [Test] public void WhenImplIsAtUpLevelThenReturnNull() { - typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass3)).Should().Be.Null(); - typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass4)).Should().Be.Null(); + Assert.That(typeof(MyClass2).GetFirstImplementorOf(typeof(MyClass3)), Is.Null); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(MyClass4)), Is.Null); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorTest.cs index c01912ae649..4bcb3c1d246 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetFirstImplementorTest.cs @@ -43,36 +43,36 @@ private class MyClass3 : MyClass2, IInterface3 [Test] public void WhenInvalidThenThrows() { - Executing.This(()=>((System.Type) null).GetFirstImplementorOf(typeof(IInterfaceNoImpl))).Should().Throw(); - Executing.This(() => typeof(IInterfaceNoImpl).GetFirstImplementorOf(null)).Should().Throw(); + Assert.That(() => ((System.Type) null).GetFirstImplementorOf(typeof(IInterfaceNoImpl)), Throws.TypeOf()); + Assert.That(() => typeof(IInterfaceNoImpl).GetFirstImplementorOf(null), Throws.TypeOf()); } [Test] public void WhenIsInterfaceThenNoImplementor() { - typeof(IInterfaceNoImpl).GetFirstImplementorOf(typeof(IInterfaceNoImpl)).Should().Be.Null(); + Assert.That(typeof(IInterfaceNoImpl).GetFirstImplementorOf(typeof(IInterfaceNoImpl)), Is.Null); } [Test] public void WhenImplAsNoInterfaceThenNoImplementor() { - typeof(MyClassNoInterface).GetFirstImplementorOf(typeof(IInterfaceNoImpl)).Should().Be.Null(); + Assert.That(typeof(MyClassNoInterface).GetFirstImplementorOf(typeof(IInterfaceNoImpl)), Is.Null); } [Test] public void WhenImplIsAtSameLevelThenReturnImplementor() { - typeof(MyClass1).GetFirstImplementorOf(typeof(IInterface1)).Should().Be(typeof(MyClass1)); - typeof(MyClass2).GetFirstImplementorOf(typeof(IInterface2)).Should().Be(typeof(MyClass2)); - typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface3)).Should().Be(typeof(MyClass3)); + Assert.That(typeof(MyClass1).GetFirstImplementorOf(typeof(IInterface1)), Is.EqualTo(typeof(MyClass1))); + Assert.That(typeof(MyClass2).GetFirstImplementorOf(typeof(IInterface2)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface3)), Is.EqualTo(typeof(MyClass3))); } [Test] public void WhenImplIsAtDifferentLevelThenReturnImplementor() { - typeof(MyClass2).GetFirstImplementorOf(typeof(IInterface1)).Should().Be(typeof(MyClass1)); - typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface2)).Should().Be(typeof(MyClass2)); - typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface1)).Should().Be(typeof(MyClass1)); + Assert.That(typeof(MyClass2).GetFirstImplementorOf(typeof(IInterface1)), Is.EqualTo(typeof(MyClass1))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface2)), Is.EqualTo(typeof(MyClass2))); + Assert.That(typeof(MyClass3).GetFirstImplementorOf(typeof(IInterface1)), Is.EqualTo(typeof(MyClass1))); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromInterfacesTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromInterfacesTest.cs index 179e2e58c5d..60998546d6c 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromInterfacesTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromInterfacesTest.cs @@ -42,41 +42,41 @@ private interface IInheritedHasSomething : IHasSomething [Test] public void WhenNullArgumentThenThrows() { - Executing.This(() => ((MemberInfo)null).GetPropertyFromInterfaces().ToList()).Should().Throw(); + Assert.That(() => ((MemberInfo)null).GetPropertyFromInterfaces().ToList(), Throws.TypeOf()); } [Test] public void WhenNoInterfaceThenEmptyList() { - For.Property(x=> x.Id).GetPropertyFromInterfaces().Should().Be.Empty(); + Assert.That(For.Property(x=> x.Id).GetPropertyFromInterfaces(), Is.Empty); } [Test] public void WhenFieldThenEmptyList() { - ForClass.Field("someField").GetPropertyFromInterfaces().Should().Be.Empty(); + Assert.That(ForClass.Field("someField").GetPropertyFromInterfaces(), Is.Empty); } [Test] public void WhenOneInterfaceThenReturnMemberInfoOfInterface() { var members = For.Property(x => x.IsValid).GetPropertyFromInterfaces(); - members.Single().Should().Be(For.Property(x=> x.IsValid)); + Assert.That(members.Single(), Is.EqualTo(For.Property(x=> x.IsValid))); } [Test] public void WhenTwoInterfacesThenReturnMemberInfoOfEachInterface() { var members = For.Property(x => x.Something).GetPropertyFromInterfaces(); - members.Should().Contain(For.Property(x => x.Something)); - members.Should().Contain(For.Property(x => x.Something)); + Assert.That(members, Contains.Item(For.Property(x => x.Something))); + Assert.That(members, Contains.Item(For.Property(x => x.Something))); } [Test] public void WhenPropertyOfInterfaceThenNotThrows() { var member = For.Property(x => x.Blah); - member.Executing(x=> x.GetPropertyFromInterfaces().Any()).NotThrows(); + Assert.That(() => member.GetPropertyFromInterfaces().Any(), Throws.Nothing); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromReflectedTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromReflectedTest.cs index d527087d04a..27164c31a71 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromReflectedTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetMemberFromReflectedTest.cs @@ -55,34 +55,34 @@ public int SomethingElse [Test] public void WhenNullMemberThenThrows() { - Executing.This(() => ((MemberInfo)null).GetMemberFromReflectedType(typeof(MyClass))).Should().Throw(); + Assert.That(() => ((MemberInfo)null).GetMemberFromReflectedType(typeof(MyClass)), Throws.TypeOf()); } [Test] public void WhenNullTypeThenThrows() { - Executing.This(() => typeof(MyClassWithExplicitImpl).GetProperty("SomethingElse").GetMemberFromReflectedType(null)).Should().Throw(); + Assert.That(() => typeof(MyClassWithExplicitImpl).GetProperty("SomethingElse").GetMemberFromReflectedType(null), Throws.TypeOf()); } [Test] public void WhenNotExistentThenOriginal() { var propertyInfo = typeof(MyClassWithExplicitImpl).GetProperty("SomethingElse"); - propertyInfo.GetMemberFromReflectedType(typeof(object)).Should().Be(propertyInfo); + Assert.That(propertyInfo.GetMemberFromReflectedType(typeof(object)), Is.EqualTo(propertyInfo)); } [Test] public void WhenNotAccessibleFieldThenOriginal() { var memberInfo = typeof(MyClass).GetField("pField", PrivateMembersFlags); - memberInfo.GetMemberFromReflectedType(typeof(Inherited)).Should().Be(memberInfo); + Assert.That(memberInfo.GetMemberFromReflectedType(typeof(Inherited)), Is.EqualTo(memberInfo)); } [Test] public void WhenNotAccessiblePropertyThenOriginal() { var memberInfo = typeof(MyClass).GetProperty("PrivateProperty", PrivateMembersFlags); - memberInfo.GetMemberFromReflectedType(typeof(Inherited)).Should().Be(memberInfo); + Assert.That(memberInfo.GetMemberFromReflectedType(typeof(Inherited)), Is.EqualTo(memberInfo)); } [Test] @@ -90,8 +90,8 @@ public void WhenAccessiblePropertyThenReflected() { var memberInfo = typeof(MyClass).GetProperty("ProtectedProperty", PrivateMembersFlags); var result = memberInfo.GetMemberFromReflectedType(typeof(Inherited)); - result.ReflectedType.Should().Be(typeof(Inherited)); - result.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(result.ReflectedType, Is.EqualTo(typeof(Inherited))); + Assert.That(result.DeclaringType, Is.EqualTo(typeof(MyClass))); } [Test] @@ -99,8 +99,8 @@ public void WhenPrivateFieldOnInheritedThenFindItOnInherited() { var memberInfo = typeof(Inherited).GetField("pField", PrivateMembersFlags); var result = memberInfo.GetMemberFromReflectedType(typeof(MyClass)); - result.ReflectedType.Should().Be(typeof(Inherited)); - result.DeclaringType.Should().Be(typeof(Inherited)); + Assert.That(result.ReflectedType, Is.EqualTo(typeof(Inherited))); + Assert.That(result.DeclaringType, Is.EqualTo(typeof(Inherited))); } [Test] @@ -108,8 +108,8 @@ public void WhenPublicPropertyOfBaseOnInheritedThenFindItOnInherited() { var memberInfo = typeof(MyClass).GetProperty("AnotherProperty"); var result = memberInfo.GetMemberFromReflectedType(typeof(Inherited)); - result.ReflectedType.Should().Be(typeof(Inherited)); - result.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(result.ReflectedType, Is.EqualTo(typeof(Inherited))); + Assert.That(result.DeclaringType, Is.EqualTo(typeof(MyClass))); } [Test] @@ -117,8 +117,8 @@ public void WhenPropertyOfInterfaceThenFindItOnClass() { var memberInfo = typeof(IInterface).GetProperty("SomethingElse"); var result = memberInfo.GetMemberFromReflectedType(typeof(MyClassWithExplicitImpl)); - result.DeclaringType.Should().Be(typeof(MyClassWithExplicitImpl)); - result.ReflectedType.Should().Be(typeof(MyClassWithExplicitImpl)); + Assert.That(result.DeclaringType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); + Assert.That(result.ReflectedType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); } [Test] @@ -126,8 +126,8 @@ public void WhenPropertyOfExplicitInterfaceThenFindItOnClass() { var memberInfo = typeof(IInterface).GetProperty("Something"); var result = memberInfo.GetMemberFromReflectedType(typeof(MyClassWithExplicitImpl)); - result.DeclaringType.Should().Be(typeof(MyClassWithExplicitImpl)); - result.ReflectedType.Should().Be(typeof(MyClassWithExplicitImpl)); + Assert.That(result.DeclaringType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); + Assert.That(result.ReflectedType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetPropertyOrFieldMatchingNameTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetPropertyOrFieldMatchingNameTest.cs index f7cf0830dba..c99be655998 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetPropertyOrFieldMatchingNameTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/GetPropertyOrFieldMatchingNameTest.cs @@ -52,127 +52,126 @@ public int SomethingElse [Test] public void WhenNullTypeThenThrows() { - Executing.This(() => ((System.Type)null).GetPropertyOrFieldMatchingName("A")).Should().Throw(); + Assert.That(() => ((System.Type)null).GetPropertyOrFieldMatchingName("A"), Throws.TypeOf()); } [Test] public void WhenAskNullThenNull() { - typeof(MyClass).GetPropertyOrFieldMatchingName(null).Should().Be.Null(); + Assert.That(typeof(MyClass).GetPropertyOrFieldMatchingName(null), Is.Null); } [Test] public void WhenAskNotExistentThenNull() { - typeof(MyClass).GetPropertyOrFieldMatchingName("NotExistent").Should().Be.Null(); + Assert.That(typeof(MyClass).GetPropertyOrFieldMatchingName("NotExistent"), Is.Null); } [Test] public void WhenAskPrivateFieldThenFindIt() { var memberInfo = typeof(MyClass).GetPropertyOrFieldMatchingName("pField"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("pField"); - memberInfo.Should().Be.InstanceOf().And.ValueOf.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(memberInfo, Is.Not.Null.And.InstanceOf()); + Assert.That(memberInfo.Name, Is.EqualTo("pField")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof (MyClass))); } [Test] public void WhenAskPrivateFieldWithBlanksThenFindIt() { var memberInfo = typeof(MyClass).GetPropertyOrFieldMatchingName(" pField "); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("pField"); - memberInfo.Should().Be.InstanceOf().And.ValueOf.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(memberInfo, Is.Not.Null.And.InstanceOf()); + Assert.That(memberInfo.Name, Is.EqualTo("pField")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(MyClass))); } [Test] public void WhenAskPrivatePropertyThenFindIt() { var memberInfo = typeof(MyClass).GetPropertyOrFieldMatchingName("PrivateProperty"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("PrivateProperty"); - memberInfo.Should().Be.InstanceOf().And.ValueOf.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(memberInfo, Is.Not.Null.And.InstanceOf()); + Assert.That(memberInfo.Name, Is.EqualTo("PrivateProperty")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof (MyClass))); } [Test] public void WhenAskProtectedPropertyThenFindIt() { var memberInfo = typeof(MyClass).GetPropertyOrFieldMatchingName("ProtectedProperty"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("ProtectedProperty"); - memberInfo.Should().Be.InstanceOf().And.ValueOf.DeclaringType.Should().Be(typeof(MyClass)); + Assert.That(memberInfo, Is.Not.Null.And.InstanceOf()); + Assert.That(memberInfo.Name, Is.EqualTo("ProtectedProperty")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(MyClass))); } [Test] public void WhenAskMethodThenNull() { - typeof(MyClass).GetPropertyOrFieldMatchingName("Method").Should().Be.Null(); + Assert.That(typeof(MyClass).GetPropertyOrFieldMatchingName("Method"), Is.Null); } [Test] public void WhenAskPrivateFieldOnInheritedThenFindItOnInherited() { var memberInfo = typeof(Inherited).GetPropertyOrFieldMatchingName("pField"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("pField"); - memberInfo.DeclaringType.Should().Be(typeof(Inherited)); - memberInfo.ReflectedType.Should().Be(typeof(Inherited)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null.And.InstanceOf()); + Assert.That(memberInfo.Name, Is.EqualTo("pField")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(Inherited))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(Inherited))); } [Test] public void WhenAskPrivatePropertyOnInheritedThenFindItOnInherited() { var memberInfo = typeof(Inherited).GetPropertyOrFieldMatchingName("PrivateProperty"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("PrivateProperty"); - memberInfo.DeclaringType.Should().Be(typeof(Inherited)); - memberInfo.ReflectedType.Should().Be(typeof(Inherited)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null); + Assert.That(memberInfo.Name, Is.EqualTo("PrivateProperty")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(Inherited))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(Inherited))); + Assert.That(memberInfo, Is.InstanceOf()); } [Test] public void WhenAskPrivatePropertyOfBaseOnInheritedThenFindItOnBase() { var memberInfo = typeof(Inherited).GetPropertyOrFieldMatchingName("AnotherPrivateProperty"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("AnotherPrivateProperty"); - memberInfo.DeclaringType.Should().Be(typeof(MyClass)); - memberInfo.ReflectedType.Should().Be(typeof(MyClass)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null); + Assert.That(memberInfo.Name, Is.EqualTo("AnotherPrivateProperty")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(MyClass))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(MyClass))); + Assert.That(memberInfo, Is.InstanceOf()); } [Test] public void WhenAskPropertyOfInterfaceThenFindIt() { var memberInfo = typeof(IInterface).GetPropertyOrFieldMatchingName("Something"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("Something"); - memberInfo.DeclaringType.Should().Be(typeof(IInterface)); - memberInfo.ReflectedType.Should().Be(typeof(IInterface)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null); + Assert.That(memberInfo.Name, Is.EqualTo("Something")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(IInterface))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(IInterface))); + Assert.That(memberInfo, Is.InstanceOf()); } [Test] public void WhenAskPropertyOfExplicitInterfaceThenFindItOnInterface() { var memberInfo = typeof(MyClassWithExplicitImpl).GetPropertyOrFieldMatchingName("Something"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("Something"); - memberInfo.DeclaringType.Should().Be(typeof(IInterface)); - memberInfo.ReflectedType.Should().Be(typeof(IInterface)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null); + Assert.That(memberInfo.Name, Is.EqualTo("Something")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(IInterface))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(IInterface))); + Assert.That(memberInfo, Is.InstanceOf()); } [Test] public void WhenAskPropertyOfImplementedInterfaceThenFindItOnType() { var memberInfo = typeof(MyClassWithExplicitImpl).GetPropertyOrFieldMatchingName("SomethingElse"); - memberInfo.Should().Not.Be.Null(); - memberInfo.Name.Should().Be("SomethingElse"); - memberInfo.DeclaringType.Should().Be(typeof(MyClassWithExplicitImpl)); - memberInfo.ReflectedType.Should().Be(typeof(MyClassWithExplicitImpl)); - memberInfo.Should().Be.InstanceOf(); + Assert.That(memberInfo, Is.Not.Null); + Assert.That(memberInfo.Name, Is.EqualTo("SomethingElse")); + Assert.That(memberInfo.DeclaringType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); + Assert.That(memberInfo.ReflectedType, Is.EqualTo(typeof(MyClassWithExplicitImpl))); + Assert.That(memberInfo, Is.InstanceOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/TypeExtensionsTest.cs b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/TypeExtensionsTest.cs index 1401756f285..758d11b4e97 100644 --- a/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/TypeExtensionsTest.cs +++ b/src/NHibernate.Test/MappingByCode/TypeExtensionsTests/TypeExtensionsTest.cs @@ -6,7 +6,6 @@ using System.Reflection; using NHibernate.Mapping.ByCode; using NUnit.Framework; -using SharpTestsEx; namespace NHibernate.Test.MappingByCode.TypeExtensionsTests { @@ -17,25 +16,25 @@ public class TypeExtensionsTest [Test] public void CanDetermineDictionaryKeyType() { - typeof (IDictionary).DetermineDictionaryKeyType().Should().Be.EqualTo(); + Assert.That(typeof (IDictionary).DetermineDictionaryKeyType(), Is.EqualTo(typeof(string))); } [Test] public void WhenNoGenericDictionaryThenDetermineNullDictionaryKeyType() { - typeof(IEnumerable).DetermineDictionaryKeyType().Should().Be.Null(); + Assert.That(typeof(IEnumerable).DetermineDictionaryKeyType(), Is.Null); } [Test] public void CanDetermineDictionaryValueType() { - typeof(IDictionary).DetermineDictionaryValueType().Should().Be.EqualTo(); + Assert.That(typeof(IDictionary).DetermineDictionaryValueType(), Is.EqualTo(typeof(int))); } [Test] public void WhenNoGenericDictionaryThenDetermineNullDictionaryValueType() { - typeof(IEnumerable).DetermineDictionaryValueType().Should().Be.Null(); + Assert.That(typeof(IEnumerable).DetermineDictionaryValueType(), Is.Null); } private class MyBaseClass @@ -44,6 +43,7 @@ private class MyBaseClass public bool BaseBool { get; set; } private double SomethingPrivate { get; set; } } + private class MyClass : MyBaseClass { @@ -52,43 +52,55 @@ private class MyClass : MyBaseClass [Test] public void DecodeMemberAccessExpressionShouldReturnMemberOfDeclaringClass() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseProperty).Satisfy( - mi => mi.ReflectedType == typeof(MyBaseClass) && mi.DeclaringType == typeof(MyBaseClass)); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseBool).Satisfy( - mi => mi.ReflectedType == typeof(MyBaseClass) && mi.DeclaringType == typeof(MyBaseClass)); + var mi1 = TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseProperty); + Assert.That(mi1.DeclaringType, Is.EqualTo(typeof (MyBaseClass))); + Assert.That(mi1.ReflectedType, Is.EqualTo(typeof (MyBaseClass))); + + var mi2 = TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseBool); + Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyBaseClass))); } [Test] public void GenericDecodeMemberAccessExpressionShouldReturnMemberOfDeclaringClass() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseProperty).Satisfy( - mi => mi.ReflectedType == typeof(MyBaseClass) && mi.DeclaringType == typeof(MyBaseClass)); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseBool).Satisfy( - mi => mi.ReflectedType == typeof(MyBaseClass) && mi.DeclaringType == typeof(MyBaseClass)); + var mi1 = TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseProperty); + Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyBaseClass))); + + var mi2 = TypeExtensions.DecodeMemberAccessExpression(mc => mc.BaseBool); + Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyBaseClass))); } [Test] public void DecodeMemberAccessExpressionOfShouldReturnMemberOfRequiredClass() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseProperty).Satisfy( - mi => mi.ReflectedType == typeof (MyClass) && mi.DeclaringType == typeof (MyBaseClass)); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool).Satisfy( - mi => mi.ReflectedType == typeof(MyClass) && mi.DeclaringType == typeof(MyBaseClass)); + var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseProperty); + Assert.That(mi1.DeclaringType, Is.EqualTo(typeof (MyBaseClass))); + Assert.That(mi1.ReflectedType, Is.EqualTo(typeof (MyClass))); + + var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool); + Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyClass))); } [Test] public void GenericDecodeMemberAccessExpressionOfShouldReturnMemberOfRequiredClass() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseProperty).Satisfy( - mi => mi.ReflectedType == typeof(MyClass) && mi.DeclaringType == typeof(MyBaseClass)); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool).Satisfy( - mi => mi.ReflectedType == typeof(MyClass) && mi.DeclaringType == typeof(MyBaseClass)); + var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseProperty); + Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyClass))); + + var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool); + Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass))); + Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyClass))); } [Test] public void GetBaseTypesIncludesInterfaces() { - typeof (Collection<>).GetBaseTypes().Should().Contain(typeof (IEnumerable)); + Assert.That(typeof (Collection<>).GetBaseTypes(), Contains.Item(typeof (IEnumerable))); } private interface IEntity @@ -114,10 +126,13 @@ private class MyEntity: BaseEntity [Test] public void DecodeMemberAccessExpressionOfWithGenericShouldReturnMemberOfRequiredClass() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.Id).Satisfy( - mi => mi.ReflectedType == typeof(MyEntity) && mi.DeclaringType == typeof(BaseEntity)); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool).Satisfy( - mi => mi.ReflectedType == typeof(MyEntity) && mi.DeclaringType == typeof(BaseEntity)); + var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.Id); + Assert.That(mi1.DeclaringType, Is.EqualTo(typeof (BaseEntity))); + Assert.That(mi1.ReflectedType, Is.EqualTo(typeof (MyEntity))); + + var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf(mc => mc.BaseBool); + Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(BaseEntity))); + Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyEntity))); } [Test] @@ -125,8 +140,8 @@ public void WhenBaseIsAbstractGenericGetMemberFromDeclaringType() { var mi = typeof(MyEntity).GetProperty("Id", typeof(int)); var declaringMi = mi.GetMemberFromDeclaringType(); - declaringMi.DeclaringType.Should().Be(); - declaringMi.ReflectedType.Should().Be(); + Assert.That(declaringMi.DeclaringType, Is.EqualTo(typeof(BaseEntity))); + Assert.That(declaringMi.ReflectedType, Is.EqualTo(typeof(BaseEntity))); } [Test] @@ -134,34 +149,32 @@ public void WhenBaseIsAbstractGetMemberFromDeclaringType() { var mi = typeof(MyEntity).GetProperty("BaseBool", typeof(bool)); var declaringMi = mi.GetMemberFromDeclaringType(); - declaringMi.DeclaringType.Should().Be(); - declaringMi.ReflectedType.Should().Be(); + Assert.That(declaringMi.DeclaringType, Is.EqualTo(typeof(BaseEntity))); + Assert.That(declaringMi.ReflectedType, Is.EqualTo(typeof(BaseEntity))); } [Test] public void GetFirstPropertyOfTypeWithNulls() { System.Type myType = null; - myType.GetFirstPropertyOfType(typeof (int), BindingFlagsIncludePrivate).Should().Be.Null(); + Assert.That(myType.GetFirstPropertyOfType(typeof (int), BindingFlagsIncludePrivate), Is.Null); myType = typeof (Array); - myType.GetFirstPropertyOfType(null, BindingFlagsIncludePrivate).Should().Be.Null(); + Assert.That(myType.GetFirstPropertyOfType(null, BindingFlagsIncludePrivate), Is.Null); } [Test] public void GetFirstPropertyOfType_WhenPropertyExistThenFindProperty() { - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string)).Should().Be( - typeof (MyBaseClass).GetProperty("BaseProperty")); - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (bool)).Should().Be(typeof (MyBaseClass).GetProperty("BaseBool")); - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (double), BindingFlagsIncludePrivate).Should().Be( - typeof (MyBaseClass).GetProperty("SomethingPrivate", BindingFlagsIncludePrivate)); + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string)), Is.EqualTo(typeof (MyBaseClass).GetProperty("BaseProperty"))); + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (bool)), Is.EqualTo(typeof (MyBaseClass).GetProperty("BaseBool"))); + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (double), BindingFlagsIncludePrivate), Is.EqualTo(typeof (MyBaseClass).GetProperty("SomethingPrivate", BindingFlagsIncludePrivate))); } [Test] public void GetFirstPropertyOfType_WhenPropertyNotExistThenNull() { - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (float)).Should().Be.Null(); - // typeof (MyBaseClass).GetFirstPropertyOfType(typeof (double)).Should().Be.Null(); <= by default check private prop. + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (float)), Is.Null); + //Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (double)), Is.Null); <= by default check private prop. } private interface IMyEntity : IEntity @@ -172,37 +185,37 @@ private interface IMyEntity : IEntity [Test] public void WhenDecodeMemberAccessExpressionOfOnInheritedEntityInterfaceThenDecodeMember() { - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(m => m.Id).Should().Not.Be.Null(); - Mapping.ByCode.TypeExtensions.DecodeMemberAccessExpressionOf(m => m.Id).Should().Not.Be.Null(); + Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf(m => m.Id), Is.Not.Null); + Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf(m => m.Id), Is.Not.Null); } [Test] public void TheSequenceOfGetHierarchyFromBaseShouldStartFromBaseClassUpToGivenClass() { // excluding System.Object - typeof(MyEntity).GetHierarchyFromBase().Should().Have.SameSequenceAs(typeof(AbstractEntity), typeof(BaseEntity), typeof(MyEntity)); + var expected = new[] {typeof (AbstractEntity), typeof (BaseEntity), typeof (MyEntity)}; + Assert.That(typeof (MyEntity).GetHierarchyFromBase(), Is.EquivalentTo(expected)); } [Test] public void GetFirstPropertyOfType_WhenDelegateIsNullThenThrow() { var myType = typeof(Array); - Executing.This(()=> myType.GetFirstPropertyOfType(typeof(int), BindingFlagsIncludePrivate, null)).Should().Throw(); + Assert.That(() => myType.GetFirstPropertyOfType(typeof(int), BindingFlagsIncludePrivate, null), Throws.TypeOf()); } [Test] public void GetFirstPropertyOfType_WhenAsDelegateThenUseDelegateToFilterProperties() { - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string), BindingFlags.Public | BindingFlags.Instance, x => false).Should().Be.Null(); - typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string), BindingFlags.Public | BindingFlags.Instance, x => true).Should().Be( - typeof (MyBaseClass).GetProperty("BaseProperty")); + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string), BindingFlags.Public | BindingFlags.Instance, x => false), Is.Null); + Assert.That(typeof (MyBaseClass).GetFirstPropertyOfType(typeof (string), BindingFlags.Public | BindingFlags.Instance, x => true), Is.EqualTo(typeof (MyBaseClass).GetProperty("BaseProperty"))); } [Test] public void HasPublicPropertyOf_WhenAsDelegateThenUseDelegateToFilterProperties() { - typeof(MyBaseClass).HasPublicPropertyOf(typeof(string), x => false).Should().Be.False(); - typeof(MyBaseClass).HasPublicPropertyOf(typeof(string), x => true).Should().Be.True(); + Assert.That(typeof(MyBaseClass).HasPublicPropertyOf(typeof(string), x => false), Is.False); + Assert.That(typeof(MyBaseClass).HasPublicPropertyOf(typeof(string), x => true), Is.True); } private abstract class MyAbstract @@ -224,10 +237,10 @@ public void GetMemberFromDeclaringClasses_WhenPropertyThenFindAbstract() { var member = typeof(MyConcrete).GetProperty("Description", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); var found = member.GetMemberFromDeclaringClasses().ToList(); - found.Count.Should().Be(2); + Assert.That(found.Count, Is.EqualTo(2)); var concreteMember = For.Property(x => x.Description).GetMemberFromReflectedType(typeof(MyConcrete)); var abstractMember = For.Property(x => x.Description); - found.Should().Have.SameValuesAs(concreteMember, abstractMember); + Assert.That(found, Is.EquivalentTo(new [] {concreteMember, abstractMember})); } [Test] @@ -235,10 +248,10 @@ public void GetMemberFromDeclaringClasses_WhenFieldThenFindAbstract() { var member = typeof(MyConcrete).GetField("aField", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); var found = member.GetMemberFromDeclaringClasses().ToList(); - found.Count.Should().Be(1); + Assert.That(found.Count, Is.EqualTo(1)); var foundMember = found.Single(); - foundMember.DeclaringType.Should().Be(typeof(MyAbstract)); - foundMember.ReflectedType.Should().Be(typeof(MyAbstract)); + Assert.That(foundMember.DeclaringType, Is.EqualTo(typeof(MyAbstract))); + Assert.That(foundMember.ReflectedType, Is.EqualTo(typeof(MyAbstract))); } private class MyCustomCollection : List @@ -249,21 +262,21 @@ private class MyCustomCollection : List public void DetermineCollectionElementTypeShouldDetermineElementTypeWhenCollectionTypeIsGeneric() { var elementType = typeof(List).DetermineCollectionElementType(); - elementType.Should().Be(typeof(MyEntity)); + Assert.That(elementType, Is.EqualTo(typeof(MyEntity))); } [Test(Description = "NH-3054")] public void DetermineCollectionElementTypeShouldDetermineElementTypeWhenCollectionTypeIsNonGeneric() { var elementType = typeof(MyCustomCollection).DetermineCollectionElementType(); - elementType.Should().Be(typeof(MyEntity)); + Assert.That(elementType, Is.EqualTo(typeof(MyEntity))); } [Test] public void DetermineCollectionElementTypeShouldNotDetermineElementTypeWhenTypeIsNotACollection() { var elementType = typeof(MyEntity).DetermineCollectionElementType(); - elementType.Should().Be.Null(); + Assert.That(elementType, Is.Null); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/MappingByCode/TypeNameUtilTests.cs b/src/NHibernate.Test/MappingByCode/TypeNameUtilTests.cs index d775a3e8704..1ccb5305df8 100644 --- a/src/NHibernate.Test/MappingByCode/TypeNameUtilTests.cs +++ b/src/NHibernate.Test/MappingByCode/TypeNameUtilTests.cs @@ -21,20 +21,20 @@ public class TypeNameUtilTests public void WhenTypeNullThenNull() { System.Type variableType = null; - variableType.GetShortClassName(new HbmMapping()).Should().Be.Null(); + Assert.That(variableType.GetShortClassName(new HbmMapping()), Is.Null); } [Test] public void WhenMapDocNullThenAssemblyQualifiedName() { - typeof(MyEntity).GetShortClassName(null).Should().Be.EqualTo(typeof(MyEntity).AssemblyQualifiedName); + Assert.That(typeof(MyEntity).GetShortClassName(null), Is.EqualTo(typeof(MyEntity).AssemblyQualifiedName)); } [Test] public void WhenMapDocDoesNotHaveDefaultsThenAssemblyQualifiedName() { var mapDoc = new HbmMapping(); - typeof(MyEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyEntity).AssemblyQualifiedName); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyEntity).AssemblyQualifiedName)); } [Test] @@ -42,7 +42,7 @@ public void WhenMapDocHaveDefaultAssemblyThenFullName() { var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyEntity).Assembly.FullName; - typeof(MyEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyEntity).FullName); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyEntity).FullName)); } [Test] @@ -50,7 +50,7 @@ public void WhenMapDocHaveDefaultAssemblyNameThenFullName() { var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyEntity).Assembly.GetName().Name; - typeof(MyEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyEntity).FullName); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyEntity).FullName)); } [Test] @@ -59,7 +59,7 @@ public void WhenMapDocHaveDefaultsThenName() var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyEntity).Assembly.FullName; mapDoc.@namespace = typeof(MyEntity).Namespace; - typeof(MyEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyEntity).Name); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyEntity).Name)); } [Test] @@ -68,7 +68,7 @@ public void WhenMapDocDefaultsDoesNotMatchsThenAssemblyQualifiedName() var mapDoc = new HbmMapping(); mapDoc.assembly = "whatever"; mapDoc.@namespace = "whatever"; - typeof(MyEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyEntity).AssemblyQualifiedName); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyEntity).AssemblyQualifiedName)); } [Test] @@ -78,20 +78,20 @@ public void WhenMatchNamespaceButNotAssemblyThenOnlyNameAndAssembly() var mapDoc = new HbmMapping(); mapDoc.assembly = "whatever"; mapDoc.@namespace = typeof(MyEntity).Namespace; - typeof(MyEntity).GetShortClassName(mapDoc).Should().StartWith(typeof(MyEntity).Name).And.EndWith(", " + typeof(MyEntity).Assembly.GetName().Name); + Assert.That(typeof(MyEntity).GetShortClassName(mapDoc), Is.StringStarting(typeof(MyEntity).Name).And.EndsWith(", " + typeof(MyEntity).Assembly.GetName().Name)); } [Test] public void WithGenericWhenMapDocNullThenAssemblyQualifiedName() { - typeof(MyGenericEntity).GetShortClassName(null).Should().Be.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(null), Is.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName)); } [Test] public void WithGenericWhenMapDocDoesNotHaveDefaultsThenAssemblyQualifiedName() { var mapDoc = new HbmMapping(); - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName)); } [Test] @@ -99,7 +99,7 @@ public void WithGenericWhenMapDocHaveDefaultAssemblyThenFullName() { var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyGenericEntity<>).Assembly.FullName; - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyGenericEntity).FullName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyGenericEntity).FullName)); } [Test] @@ -107,7 +107,7 @@ public void WithGenericWhenMapDocHaveDefaultAssemblyNameThenFullName() { var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyGenericEntity<>).Assembly.GetName().Name; - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyGenericEntity).FullName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyGenericEntity).FullName)); } [Test] @@ -116,7 +116,7 @@ public void WithGenericWhenMapDocHaveDefaultsThenName() var mapDoc = new HbmMapping(); mapDoc.assembly = typeof(MyGenericEntity<>).Assembly.FullName; mapDoc.@namespace = typeof(MyGenericEntity<>).Namespace; - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyGenericEntity).FullName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyGenericEntity).FullName)); } [Test] @@ -125,7 +125,7 @@ public void WithGenericWhenMapDocDefaultsDoesNotMatchsThenAssemblyQualifiedName( var mapDoc = new HbmMapping(); mapDoc.assembly = "whatever"; mapDoc.@namespace = "whatever"; - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().Be.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.EqualTo(typeof(MyGenericEntity).AssemblyQualifiedName)); } [Test] @@ -135,7 +135,7 @@ public void WithGenericWhenMatchNamespaceButNotAssemblyThenOnlyNameAndAssembly() var mapDoc = new HbmMapping(); mapDoc.assembly = "whatever"; mapDoc.@namespace = typeof(MyGenericEntity<>).Namespace; - typeof(MyGenericEntity).GetShortClassName(mapDoc).Should().StartWith(typeof(MyGenericEntity).FullName).And.EndWith(", " + typeof(MyGenericEntity).Assembly.GetName().Name); + Assert.That(typeof(MyGenericEntity).GetShortClassName(mapDoc), Is.StringStarting(typeof(MyGenericEntity).FullName).And.EndsWith(", " + typeof(MyGenericEntity).Assembly.GetName().Name)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/Fixture.cs index d3cc5bcb1e6..fbe9820527f 100644 --- a/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/Fixture.cs @@ -45,8 +45,7 @@ public void CanUseDatareadersGetValue() var multi = s.CreateMultiCriteria(); multi.Add(crit); var res = (IList) multi.List()[0]; - res.Count - .Should().Be.EqualTo(1); + Assert.That(res.Count, Is.EqualTo(1)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs b/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs index d839c5d1567..fe521c486ac 100644 --- a/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs @@ -48,7 +48,7 @@ public void SavingAndRetrievingTest() using (ITransaction tx = s.BeginTransaction()) { var datesRecovered = s.CreateQuery("from AllDates").UniqueResult(); - datesRecovered.Sql_datetimeoffset.Should().Be(NowOS); + Assert.That(datesRecovered.Sql_datetimeoffset, Is.EqualTo(NowOS)); } using (ISession s = OpenSession()) @@ -65,7 +65,7 @@ public void WhenEqualTicksThenShouldMatchIsEqual() { var type = new DateTimeOffsetType(); var now = DateTimeOffset.Now; - type.IsEqual(new DateTimeOffset(now.Ticks, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)).Should().Be.True(); + Assert.That(type.IsEqual(new DateTimeOffset(now.Ticks, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)), Is.True); } [Test] @@ -73,7 +73,7 @@ public void WhenNotEqualTicksThenShouldNotMatchIsEqual() { var type = new DateTimeOffsetType(); var now = DateTimeOffset.Now; - type.IsEqual(new DateTimeOffset(now.Ticks - 1, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)).Should().Be.False(); + Assert.That(type.IsEqual(new DateTimeOffset(now.Ticks - 1, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)), Is.False); } [Test] @@ -82,24 +82,24 @@ public void HashCodeShouldHaveSameBehaviorOfNetType() var type = new DateTimeOffsetType(); var now = DateTimeOffset.Now; var exactClone = new DateTimeOffset(now.Ticks, now.Offset); - (now.GetHashCode() == exactClone.GetHashCode()).Should().Be.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco)); + Assert.That((now.GetHashCode() == exactClone.GetHashCode()), Is.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco))); } [Test] public void Next() { - var type = (DateTimeOffsetType)NHibernateUtil.DateTimeOffset; + var type = NHibernateUtil.DateTimeOffset; var current = DateTimeOffset.Now.AddTicks(-1); object next = type.Next(current, null); - next.Should().Be.OfType().And.ValueOf.Ticks.Should().Be.GreaterThan(current.Ticks); + Assert.That(next, Is.TypeOf().And.Property("Ticks").GreaterThan(current.Ticks)); } [Test] public void Seed() { - var type = (DateTimeOffsetType)NHibernateUtil.DateTimeOffset; - type.Seed(null).Should().Be.OfType(); + var type = NHibernateUtil.DateTimeOffset; + Assert.That(type.Seed(null), Is.TypeOf()); } } diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs index 1375cbce0a6..7101a592f37 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs @@ -5,11 +5,11 @@ namespace NHibernate.Test.NHSpecificTest.Futures { - using System.Collections; + using System.Collections; - [TestFixture] - public class FutureQueryFixture : FutureFixture - { + [TestFixture] + public class FutureQueryFixture : FutureFixture + { [Test] public void DefaultReadOnlyTest() { @@ -24,124 +24,123 @@ public void DefaultReadOnlyTest() } } - [Test] - public void CanUseFutureQuery() - { - using (var s = sessions.OpenSession()) - { + [Test] + public void CanUseFutureQuery() + { + using (var s = sessions.OpenSession()) + { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - var persons10 = s.CreateQuery("from Person") - .SetMaxResults(10) - .Future(); - var persons5 = s.CreateQuery("from Person") - .SetMaxResults(5) - .Future(); + var persons10 = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future(); + var persons5 = s.CreateQuery("from Person") + .SetMaxResults(5) + .Future(); + + using (var logSpy = new SqlLogSpy()) + { + foreach (var person in persons5) + { + + } + + foreach (var person in persons10) + { + + } + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + } + } + } + + [Test] + public void TwoFuturesRunInTwoRoundTrips() + { + using (var s = sessions.OpenSession()) + { + IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var logSpy = new SqlLogSpy()) - { - foreach (var person in persons5) - { + using (var logSpy = new SqlLogSpy()) + { + var persons10 = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future(); - } + foreach (var person in persons10) { } // fire first future round-trip - foreach (var person in persons10) - { + var persons5 = s.CreateQuery("from Person") + .SetMaxResults(5) + .Future(); - } + foreach (var person in persons5) { } // fire second future round-trip - var events = logSpy.Appender.GetEvents(); - Assert.AreEqual(1, events.Length); - } - } - } + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(2, events.Length); + } + } + } - [Test] - public void TwoFuturesRunInTwoRoundTrips() - { - using (var s = sessions.OpenSession()) - { + [Test] + public void CanCombineSingleFutureValueWithEnumerableFutures() + { + using (var s = sessions.OpenSession()) + { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var logSpy = new SqlLogSpy()) - { - var persons10 = s.CreateQuery("from Person") - .SetMaxResults(10) - .Future(); + var persons = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future(); - foreach (var person in persons10) { } // fire first future round-trip + var personCount = s.CreateQuery("select count(*) from Person") + .FutureValue(); - var persons5 = s.CreateQuery("from Person") - .SetMaxResults(5) - .Future(); + using (var logSpy = new SqlLogSpy()) + { + long count = personCount.Value; - foreach (var person in persons5) { } // fire second future round-trip + foreach (var person in persons) + { + } - var events = logSpy.Appender.GetEvents(); - Assert.AreEqual(2, events.Length); - } - } - } + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + } + } + } - [Test] - public void CanCombineSingleFutureValueWithEnumerableFutures() - { - using (var s = sessions.OpenSession()) - { + [Test] + public void CanExecuteMultipleQueryWithSameParameterName() + { + using (var s = sessions.OpenSession()) + { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); + + var meContainer = s.CreateQuery("from Person p where p.Id = :personId") + .SetParameter("personId", 1) + .FutureValue(); + + var possiblefriends = s.CreateQuery("from Person p where p.Id != :personId") + .SetParameter("personId", 2) + .Future(); - var persons = s.CreateQuery("from Person") - .SetMaxResults(10) - .Future(); - - var personCount = s.CreateQuery("select count(*) from Person") - .FutureValue(); - - using (var logSpy = new SqlLogSpy()) - { - long count = personCount.Value; - - foreach (var person in persons) - { - } - - var events = logSpy.Appender.GetEvents(); - Assert.AreEqual(1, events.Length); - } - } - } - - [Test] - public void CanExecuteMultipleQueryWithSameParameterName() - { - using (var s = sessions.OpenSession()) - { - IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - - var meContainer = s.CreateQuery("from Person p where p.Id = :personId") - .SetParameter("personId", 1) - .FutureValue(); - - var possiblefriends = s.CreateQuery("from Person p where p.Id != :personId") - .SetParameter("personId", 2) - .Future(); - - using (var logSpy = new SqlLogSpy()) - { - var me = meContainer.Value; + using (var logSpy = new SqlLogSpy()) + { + var me = meContainer.Value; + + foreach (var person in possiblefriends) + { + } - foreach (var person in possiblefriends) - { - } - - var events = logSpy.Appender.GetEvents(); - Assert.AreEqual(1, events.Length); - var wholeLog = logSpy.GetWholeLog(); - string paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix; - Assert.True(wholeLog.Contains(paramPrefix + "p0 = 1 [Type: Int32 (0)], " + paramPrefix + "p1 = 2 [Type: Int32 (0)]")); - } - } - - } - } + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + var wholeLog = logSpy.GetWholeLog(); + string paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix; + Assert.That(wholeLog.Contains(paramPrefix + "p0 = 1 [Type: Int32 (0)], " + paramPrefix + "p1 = 2 [Type: Int32 (0)]"), Is.True); + } + } + } + } } diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs index 7ac1123ead9..ca8762bd4a4 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs @@ -353,11 +353,9 @@ public void CanExecuteMultipleQueriesOnSameExpression() Assert.AreEqual(1, events.Length); var wholeLog = logSpy.GetWholeLog(); string paramPrefix = ((DriverBase)Sfi.ConnectionProvider.Driver).NamedPrefix; - Assert.True(wholeLog.Contains(paramPrefix + "p0 = 1 [Type: Int32 (0)], " + paramPrefix + "p1 = 2 [Type: Int32 (0)]")); + Assert.That(wholeLog.Contains(paramPrefix + "p0 = 1 [Type: Int32 (0)], " + paramPrefix + "p1 = 2 [Type: Int32 (0)]"), Is.True); } } - } - } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs b/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs index fd616ee071c..3bc10acc717 100644 --- a/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs @@ -41,7 +41,7 @@ public void WillGetSessionIdFromSessionLogs() s.Get(1);//will execute some sql var loggingEvent = spy.Events[0]; - Assert.True(loggingEvent.Contains(sessionId.ToString())); + Assert.That(loggingEvent.Contains(sessionId.ToString()), Is.True); } } @@ -66,7 +66,7 @@ public TextLogSpy(string loggerName, string pattern) { Layout = new PatternLayout(pattern), Threshold = Level.All, - Writer = new StringWriter(stringBuilder) + Writer = new StringWriter(stringBuilder) }; loggerImpl = (Logger)LogManager.GetLogger(loggerName).Logger; loggerImpl.AddAppender(appender); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1270/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1270/Fixture.cs index abe5197d240..48a868ea828 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1270/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1270/Fixture.cs @@ -14,34 +14,34 @@ private HbmMapping GetMappings() { var mapper = new ModelMapper(); mapper.Class(rt => - { - rt.Id(x => x.Id, map => map.Generator(Generators.Guid)); - rt.Property(x => x.Name); + { + rt.Id(x => x.Id, map => map.Generator(Generators.Guid)); + rt.Property(x => x.Name); rt.Set(x => x.Roles, map => { map.Table("UsersToRoles"); map.Inverse(true); map.Key(km => km.Column("UserId")); }, rel => rel.ManyToMany(mm => - { + { mm.Column("RoleId"); - mm.ForeignKey("FK_RoleInUser"); - })); - }); + mm.ForeignKey("FK_RoleInUser"); + })); + }); mapper.Class(rt => - { - rt.Id(x => x.Id, map => map.Generator(Generators.Guid)); - rt.Property(x => x.Name); - rt.Set(x => x.Users, map => - { - map.Table("UsersToRoles"); + { + rt.Id(x => x.Id, map => map.Generator(Generators.Guid)); + rt.Property(x => x.Name); + rt.Set(x => x.Users, map => + { + map.Table("UsersToRoles"); map.Key(km => km.Column("RoleId")); }, rel => rel.ManyToMany(mm => - { + { mm.Column("UserId"); - mm.ForeignKey("FK_UserInRole"); - })); - }); + mm.ForeignKey("FK_UserInRole"); + })); + }); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); return mappings; } @@ -55,7 +55,7 @@ public void WhenMapCustomFkNamesThenUseIt() var sb = new StringBuilder(); (new SchemaExport(conf)).Create(s => sb.AppendLine(s), true); - sb.ToString().Should().Contain("FK_RoleInUser").And.Contain("FK_UserInRole"); + Assert.That(sb.ToString(), Is.StringContaining("FK_RoleInUser").And.StringContaining("FK_UserInRole")); (new SchemaExport(conf)).Drop(false, true); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1323/CheckViability.cs b/src/NHibernate.Test/NHSpecificTest/NH1323/CheckViability.cs index acb76057612..dc94ed1835a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1323/CheckViability.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1323/CheckViability.cs @@ -68,9 +68,9 @@ public void WhenReassociateCollectionUsingMergeThenReassingOwner() using (session.BeginTransaction()) { var merged = (MyClass)session.Merge(scenario.Entity); - ((IPersistentCollection)merged.Children).Owner.Should().Not.Be.Null(); - ((IPersistentCollection)merged.Components).Owner.Should().Not.Be.Null(); - ((IPersistentCollection)merged.Elements).Owner.Should().Not.Be.Null(); + Assert.That(((IPersistentCollection)merged.Children).Owner, Is.Not.Null); + Assert.That(((IPersistentCollection)merged.Components).Owner, Is.Not.Null); + Assert.That(((IPersistentCollection)merged.Elements).Owner, Is.Not.Null); session.Transaction.Commit(); } } @@ -101,9 +101,9 @@ public void WhenReassociateCollectionUsingLockThenTheCommitNotThrows() using (session.BeginTransaction()) { var fresh = session.Get(scenario.Entity.Id); - fresh.Children.Should().Have.Count.EqualTo(2); - fresh.Components.Should().Have.Count.EqualTo(2); - fresh.Elements.Should().Have.Count.EqualTo(2); + Assert.That(fresh.Children, Has.Count.EqualTo(2)); + Assert.That(fresh.Components, Has.Count.EqualTo(2)); + Assert.That(fresh.Elements, Has.Count.EqualTo(2)); session.Transaction.Commit(); } } @@ -133,9 +133,9 @@ public void WhenReassociateCollectionUsingUpdateThenTheCommitNotThrows() using (session.BeginTransaction()) { var fresh = session.Get(scenario.Entity.Id); - fresh.Children.Should().Have.Count.EqualTo(2); - fresh.Components.Should().Have.Count.EqualTo(2); - fresh.Elements.Should().Have.Count.EqualTo(2); + Assert.That(fresh.Children, Has.Count.EqualTo(2)); + Assert.That(fresh.Components, Has.Count.EqualTo(2)); + Assert.That(fresh.Elements, Has.Count.EqualTo(2)); session.Transaction.Commit(); } } @@ -165,9 +165,9 @@ public void WhenReassociateCollectionUsingSaveOrUpdateThenTheCommitNotThrows() using (session.BeginTransaction()) { var fresh = session.Get(scenario.Entity.Id); - fresh.Children.Should().Have.Count.EqualTo(2); - fresh.Components.Should().Have.Count.EqualTo(2); - fresh.Elements.Should().Have.Count.EqualTo(2); + Assert.That(fresh.Children, Has.Count.EqualTo(2)); + Assert.That(fresh.Components, Has.Count.EqualTo(2)); + Assert.That(fresh.Elements, Has.Count.EqualTo(2)); session.Transaction.Commit(); } } @@ -193,7 +193,7 @@ public void WhenReassociateCollectionUsingDeleteThenTheCommitNotThrows() using (session.BeginTransaction()) { var fresh = session.Get(scenario.Entity.Id); - fresh.Should().Be.Null(); + Assert.That(fresh, Is.Null); session.Transaction.Commit(); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1399/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1399/Fixture.cs index 68479cba554..f4c78eef01b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1399/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1399/Fixture.cs @@ -39,8 +39,8 @@ public void UsingTwoInstancesWithSameValuesTheFkNameIsTheSame() string t1Fk_ = table1_.UniqueColumnString(new object[] { table1ITestManyA_ }, "BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyA"); string t2Fk_ = table1_.UniqueColumnString(new object[] { table1ITestManyB_ }, "BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyB"); - t1Fk_.Should().Be.EqualTo(t1Fk); - t2Fk_.Should().Be.EqualTo(t2Fk); + Assert.That(t1Fk_, Is.EqualTo(t1Fk)); + Assert.That(t2Fk_, Is.EqualTo(t2Fk)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH1421/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1421/Fixture.cs index 6b901d83abb..e5c20a2a8ea 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1421/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1421/Fixture.cs @@ -15,7 +15,7 @@ public void WhenParameterListIsEmptyArrayUsingQueryThenDoesNotTrowsNullReference using (var s = OpenSession()) { var query = s.CreateQuery("from AnEntity a where a.id in (:myList)"); - query.Executing(x => x.SetParameterList("myList", new long[0])).Throws().And.Exception.Should().Not.Be.InstanceOf(); + Assert.That(() => query.SetParameterList("myList", new long[0]), Throws.Exception.Not.InstanceOf()); } } @@ -25,7 +25,7 @@ public void WhenParameterListIsEmptyGenericCollectionUsingQueryThenDoesNotTrowsN using (var s = OpenSession()) { var query = s.CreateQuery("from AnEntity a where a.id in (:myList)"); - query.Executing(x => x.SetParameterList("myList", new Collection())).Throws().And.Exception.Should().Not.Be.InstanceOf(); + Assert.That(() => query.SetParameterList("myList", new Collection()), Throws.Exception.Not.InstanceOf()); } } @@ -47,7 +47,7 @@ public void WhenParameterListIsNullUsingQueryThenTrowsArgumentException() using (var s = OpenSession()) { var query = s.CreateQuery("from AnEntity a where a.id in (:myList)"); - query.Executing(x => x.SetParameterList("myList", null)).Throws().And.Exception.Should().Be.InstanceOf(); + Assert.That(() => query.SetParameterList("myList", null), Throws.Exception.InstanceOf()); } } @@ -57,9 +57,8 @@ public void WhenParameterListIsEmptyUsingQueryThenDoesNotTrowsNullReferenceExcep using (var s = OpenSession()) { var query = s.CreateQuery("from AnEntity a where a.id in (:myList)"); - query.Executing(x => x.SetParameterList("myList", new long[0]).List()).Throws().And.Exception.Should().Not.Be.InstanceOf(); + Assert.That(() => query.SetParameterList("myList", new long[0]).List(), Throws.Exception.Not.InstanceOf()); } } - } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs index b295b155b14..52ebe163f49 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs @@ -1,6 +1,11 @@ using NUnit.Framework; using SharpTestsEx; +namespace SharpTestsEx +{ + + +} namespace NHibernate.Test.NHSpecificTest.NH1508 { [TestFixture] @@ -66,7 +71,7 @@ public void DoesntThrowsExceptionWhenSqlQueryIsGiven() { var sqlQuery = session.CreateSQLQuery("select * from Document"); var multiquery = session.CreateMultiQuery(); - multiquery.Executing(x => x.Add(sqlQuery)).NotThrows(); + Assert.That(() => multiquery.Add(sqlQuery), Throws.Nothing); } } @@ -78,7 +83,7 @@ public void DoesntThrowsExceptionWhenNamedSqlQueryIsGiven() { var multiquery = session.CreateMultiQuery(); - multiquery.Executing(x => x.AddNamedQuery("SampleSqlQuery")).NotThrows(); + Assert.That(() => multiquery.AddNamedQuery("SampleSqlQuery"), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1836/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1836/Fixture.cs index 0f237084ccf..0d95f43fdd8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1836/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1836/Fixture.cs @@ -37,9 +37,9 @@ public void AliasToBeanTransformerShouldApplyCorrectlyToMultiQuery() ); IList results = null; - Executing.This(() => results = multiQuery.List()).Should().NotThrow(); + Assert.That(() => results = multiQuery.List(), Throws.Nothing); var elementOfFirstResult = ((IList)results[0])[0]; - elementOfFirstResult.Should().Be.OfType().And.ValueOf.EntityId.Should().Be(1); + Assert.That(elementOfFirstResult, Is.TypeOf().And.Property("EntityId").EqualTo(1)); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs index 91f94ae97e5..061b58fd972 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs @@ -14,10 +14,10 @@ protected override void Configure(NHibernate.Cfg.Configuration configuration) configuration.SetProperty(Environment.BatchSize, "1"); } - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return dialect.SupportsSqlBatches; - } + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect.SupportsSqlBatches; + } [Test] public void CanGetQueryDurationForDelete() @@ -29,9 +29,7 @@ public void CanGetQueryDurationForDelete() session.CreateQuery("delete Customer").ExecuteUpdate(); var wholeLog = spy.GetWholeLog(); - Assert.True( - wholeLog.Contains("ExecuteNonQuery took") - ); + Assert.That(wholeLog.Contains("ExecuteNonQuery took"), Is.True); tx.Rollback(); } @@ -79,12 +77,8 @@ public void CanGetQueryDurationForSelect() session.CreateQuery("from Customer").List(); var wholeLog = spy.GetWholeLog(); - Assert.True( - wholeLog.Contains("ExecuteReader took") - ); - Assert.True( - wholeLog.Contains("DataReader was closed after") - ); + Assert.That(wholeLog.Contains("ExecuteReader took"), Is.True); + Assert.That(wholeLog.Contains("DataReader was closed after"), Is.True); tx.Rollback(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1882/TestCollectionInitializingDuringFlush.cs b/src/NHibernate.Test/NHSpecificTest/NH1882/TestCollectionInitializingDuringFlush.cs index 5bed4ed93e2..6338488b743 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1882/TestCollectionInitializingDuringFlush.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1882/TestCollectionInitializingDuringFlush.cs @@ -112,8 +112,8 @@ public void TestInitializationDuringFlush() s.Transaction.Commit(); s.Clear(); s.Close(); - Assert.True(listener.Executed); - Assert.True(listener.FoundAny); + Assert.That(listener.Executed, Is.True); + Assert.That(listener.FoundAny, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH1965/ReattachWithCollectionTest.cs b/src/NHibernate.Test/NHSpecificTest/NH1965/ReattachWithCollectionTest.cs index 8aa9cef39d8..e32bc31c3d6 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1965/ReattachWithCollectionTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1965/ReattachWithCollectionTest.cs @@ -24,10 +24,10 @@ protected override HbmMapping GetMappings() var mapper = new ModelMapper(); // Note: DeleteOrphans has no sense, only added to match the case reported. mapper.Class(cm => - { - cm.Id(x => x.Id, map => map.Generator(Generators.Identity)); + { + cm.Id(x => x.Id, map => map.Generator(Generators.Identity)); cm.Bag(x => x.Children, map => map.Cascade(Mapping.ByCode.Cascade.All.Include(Mapping.ByCode.Cascade.DeleteOrphans)), rel => rel.OneToMany()); - }); + }); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); return mappings; } @@ -45,7 +45,7 @@ public void WhenReattachThenNotThrows() using (var session = OpenSession()) { - session.Executing(x => x.Lock(cat, LockMode.None)).NotThrows(); + Assert.That(() => session.Lock(cat, LockMode.None), Throws.Nothing); } using (var session = OpenSession()) diff --git a/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs index 38a09a56956..ac00cde5990 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs @@ -57,7 +57,7 @@ public void ISQLExceptionConverter_gets_called_if_batch_size_enabled() { var one = s.Load(oneId); s.Delete(one); - tx.Executing(transaction => transaction.Commit()).Throws(); + Assert.That(() => tx.Commit(), Throws.TypeOf()); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs b/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs index 27f4074c5b9..41ba313a042 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs @@ -22,7 +22,7 @@ public void TheModuleOperationShouldAddParenthesisToAvoidWrongSentence() { // The expected value should be "(5+1)%(1+1)" instead "5+ 1%1 +1" var sqlQuery = GetSql("select mod(5+1,1+1) from MyClass"); - sqlQuery.Should().Contain("(5+1)").And.Contain("(1+1)"); + Assert.That(sqlQuery, Is.StringContaining("(5+1)").And.StringContaining("(1+1)")); } public string GetSql(string query) diff --git a/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs index 8b0ef82bef3..9e0753ceb3a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs @@ -14,8 +14,8 @@ public void WhenJoinTableContainComponentsThenColumnsShouldBeInJoinedTable() cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2041.Mappings.hbm.xml", GetType().Assembly); var mappings = cfg.CreateMappings(Dialect.Dialect.GetDialect(cfg.Properties)); var table = mappings.GetTable(null, null, "Locations"); - table.Should().Not.Be.Null(); - table.ColumnIterator.Select(c => c.Name).Should().Have.SameValuesAs("myclassId", "latitudecol", "longitudecol"); + Assert.That(table, Is.Not.Null); + Assert.That(table.ColumnIterator.Select(c => c.Name), Is.EquivalentTo(new [] {"myclassId", "latitudecol", "longitudecol"})); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs index e1f71e44da8..8b761764711 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs @@ -51,10 +51,10 @@ public void CanUpdateInheritedClass() using (var t = session.BeginTransaction()) { var updated = (IDictionary) session.Get("Address", savedId); - updated["BaseF1"].Should().Be("base1"); - updated["BaseF2"].Should().Be("base2"); - updated["AddressF1"].Should().Be("foo"); - updated["AddressF2"].Should().Be("bar"); + Assert.That(updated["BaseF1"], Is.EqualTo("base1")); + Assert.That(updated["BaseF2"], Is.EqualTo("base2")); + Assert.That(updated["AddressF1"], Is.EqualTo("foo")); + Assert.That(updated["AddressF2"], Is.EqualTo("bar")); t.Commit(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs index 1bad6767f3f..9339f28a508 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs @@ -26,8 +26,7 @@ public void WillCloseWhenUsingDTC() Assert.False(s.IsClosed); tx.Complete(); } - Assert.True(s.IsClosed); + Assert.That(s.IsClosed, Is.True); } - } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs index c6921aff1c8..6871ca6e2dd 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs @@ -25,11 +25,11 @@ public void ConstrainedLazyLoadedOneToOneUsingCastleProxy() { var employee = s.Get(1); - Assert.False(NHibernateUtil.IsInitialized(employee.Person)); + Assert.That(NHibernateUtil.IsInitialized(employee.Person), Is.False); - Assert.AreEqual(employee.Person.Name, "Person1"); + Assert.That("Person1", Is.EqualTo(employee.Person.Name)); - Assert.True(NHibernateUtil.IsInitialized(employee.Person)); + Assert.That(NHibernateUtil.IsInitialized(employee.Person), Is.True); } } finally diff --git a/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs index 55f201751ed..f2bd6664cf3 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs @@ -6,43 +6,43 @@ namespace NHibernate.Test.NHSpecificTest.NH2094 [TestFixture] public class Fixture : BugTestCase { - [Test] - public void CanAccessInitializedPropertiesOutsideOfSession() - { - try - { - using (var s = OpenSession()) - { - var p = new Person { Id = 1, Name = "Person1", LazyField = "Long field"}; + [Test] + public void CanAccessInitializedPropertiesOutsideOfSession() + { + try + { + using (var s = OpenSession()) + { + var p = new Person { Id = 1, Name = "Person1", LazyField = "Long field"}; - s.Save(p); + s.Save(p); - s.Flush(); - } + s.Flush(); + } - Person person; + Person person; - using (var s = OpenSession()) - { - person = s.Get(1); + using (var s = OpenSession()) + { + person = s.Get(1); - Assert.AreEqual("Person1", person.Name); - Assert.AreEqual("Long field", person.LazyField); - } + Assert.AreEqual("Person1", person.Name); + Assert.AreEqual("Long field", person.LazyField); + } - Assert.AreEqual("Person1", person.Name); - Assert.AreEqual("Long field", person.LazyField); - } - finally - { - using (var s = OpenSession()) - { - s.Delete("from Person"); + Assert.AreEqual("Person1", person.Name); + Assert.AreEqual("Long field", person.LazyField); + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Person"); - s.Flush(); - } - } - } + s.Flush(); + } + } + } [Test] public void WhenAccessNoLazyPropertiesOutsideOfSessionThenNotThrows() @@ -65,7 +65,7 @@ public void WhenAccessNoLazyPropertiesOutsideOfSessionThenNotThrows() person = s.Get(1); } string personName; - Executing.This(()=> personName = person.Name).Should().NotThrow(); + Assert.That(() => personName = person.Name, Throws.Nothing); } finally { @@ -99,9 +99,9 @@ public void WhenAccessLazyPropertiesOutsideOfSessionThenThrows() person = s.Get(1); } string lazyField; - var lazyException = Executing.This(() => lazyField = person.LazyField).Should().Throw().Exception; - lazyException.EntityName.Should().Not.Be.Null(); - lazyException.Message.Should().Contain("LazyField"); + var lazyException = Assert.Throws(() => lazyField = person.LazyField); + Assert.That(lazyException.EntityName, Is.Not.Null); + Assert.That(lazyException.Message, Is.StringContaining("LazyField")); } finally { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2100/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2100/Fixture.cs index 5a0040de250..790cac7f89b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2100/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2100/Fixture.cs @@ -80,17 +80,17 @@ public void WhenTwoTransactionInSameSessionThenNotChangeVersion() tx.Commit(); } // After close the second transaction the version was not changed - c1_1.EntityVersion.Should().Be(originalVersionC1_1); - c1_2.EntityVersion.Should().Be(originalVersionC1_2); - c2_1.EntityVersion.Should().Be(originalVersionC2_1); - c2_2.EntityVersion.Should().Be(originalVersionC2_2); + Assert.That(c1_1.EntityVersion, Is.EqualTo(originalVersionC1_1)); + Assert.That(c1_2.EntityVersion, Is.EqualTo(originalVersionC1_2)); + Assert.That(c2_1.EntityVersion, Is.EqualTo(originalVersionC2_1)); + Assert.That(c2_2.EntityVersion, Is.EqualTo(originalVersionC2_2)); } // After close the session the version was not changed - c1_1.EntityVersion.Should().Be(originalVersionC1_1); - c1_2.EntityVersion.Should().Be(originalVersionC1_2); - c2_1.EntityVersion.Should().Be(originalVersionC2_1); - c2_2.EntityVersion.Should().Be(originalVersionC2_2); + Assert.That(c1_1.EntityVersion, Is.EqualTo(originalVersionC1_1)); + Assert.That(c1_2.EntityVersion, Is.EqualTo(originalVersionC1_2)); + Assert.That(c2_1.EntityVersion, Is.EqualTo(originalVersionC2_1)); + Assert.That(c2_2.EntityVersion, Is.EqualTo(originalVersionC2_2)); using (ISession s = OpenSession()) { @@ -102,10 +102,10 @@ public void WhenTwoTransactionInSameSessionThenNotChangeVersion() c1_2 = s.Get(c1_2.ID); // to be 100% sure the version was not changed in DB - c1_1.EntityVersion.Should().Be(originalVersionC1_1); - c1_2.EntityVersion.Should().Be(originalVersionC1_2); - c2_1.EntityVersion.Should().Be(originalVersionC2_1); - c2_2.EntityVersion.Should().Be(originalVersionC2_2); + Assert.That(c1_1.EntityVersion, Is.EqualTo(originalVersionC1_1)); + Assert.That(c1_2.EntityVersion, Is.EqualTo(originalVersionC1_2)); + Assert.That(c2_1.EntityVersion, Is.EqualTo(originalVersionC2_1)); + Assert.That(c2_2.EntityVersion, Is.EqualTo(originalVersionC2_2)); s.Delete(c2_1); s.Delete(c1_1); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs index 6ac1e398b4f..6f4277fcff2 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs @@ -26,7 +26,7 @@ public void EntityWithConstrainedLazyLoadedOneToOneShouldNotGenerateFieldInterce { var employee = s.Get(1); - employee.Should().Be.OfType(); + Assert.That(employee, Is.TypeOf()); } } finally diff --git a/src/NHibernate.Test/NHSpecificTest/NH2138/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2138/Fixture.cs index e92c991eddb..cd97e7fd73d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2138/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2138/Fixture.cs @@ -12,10 +12,10 @@ public void AfterAddAppingShouldHaveAResultsetWithEntityName() { var cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2138.Mappings.hbm.xml", GetType().Assembly); - cfg.Executing(c => c.BuildMappings()).NotThrows(); + Assert.That(() => cfg.BuildMappings(), Throws.Nothing); var sqlQuery = cfg.NamedSQLQueries["AllCoders"]; var rootReturn = (NativeSQLQueryRootReturn)sqlQuery.QueryReturns[0]; - rootReturn.ReturnEntityName.Should().Be("Coder"); + Assert.That(rootReturn.ReturnEntityName, Is.EqualTo("Coder")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2147/DefaultBatchSize.cs b/src/NHibernate.Test/NHSpecificTest/NH2147/DefaultBatchSize.cs index 95aaca21b6d..ad399d24797 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2147/DefaultBatchSize.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2147/DefaultBatchSize.cs @@ -21,10 +21,10 @@ public void WhenNoDefaultAndNoSpecificThenUse1() cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2147.Mappings.hbm.xml", GetType().Assembly); var sf = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); var persister = sf.GetEntityPersister("MyClassWithoutBatchSize"); - persister.IsBatchLoadable.Should().Be.False(); + Assert.That(persister.IsBatchLoadable, Is.False); // hack - fieldInfo.GetValue(persister).Should().Be(1); + Assert.That(fieldInfo.GetValue(persister), Is.EqualTo(1)); } [Test] @@ -37,10 +37,10 @@ public void WhenDefaultAndNoSpecificThenUseDefault() var sf = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); var persister = sf.GetEntityPersister("MyClassWithoutBatchSize"); - persister.IsBatchLoadable.Should().Be.True(); + Assert.That(persister.IsBatchLoadable, Is.True); // hack - fieldInfo.GetValue(persister).Should().Be(20); + Assert.That(fieldInfo.GetValue(persister), Is.EqualTo(20)); } [Test] @@ -53,10 +53,10 @@ public void WhenDefaultAndSpecificThenUseSpecific() var sf = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); var persister = sf.GetEntityPersister("MyClassWithBatchSize"); - persister.IsBatchLoadable.Should().Be.True(); + Assert.That(persister.IsBatchLoadable, Is.True); // hack - fieldInfo.GetValue(persister).Should().Be(10); + Assert.That(fieldInfo.GetValue(persister), Is.EqualTo(10)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2166/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2166/Fixture.cs index 42f5395760d..ad388e35277 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2166/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2166/Fixture.cs @@ -18,7 +18,7 @@ public void WhenUniqueResultShouldCallConverter() { using (var s = OpenSession()) { - Executing.This(()=> s.CreateSQLQuery("select make from ItFunky").UniqueResult()).Should().Throw(); + Assert.That(() => s.CreateSQLQuery("select make from ItFunky").UniqueResult(), Throws.TypeOf()); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2188/AppDomainWithMultipleSearchPath.cs b/src/NHibernate.Test/NHSpecificTest/NH2188/AppDomainWithMultipleSearchPath.cs index 199480f3efd..2973d6ff32d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2188/AppDomainWithMultipleSearchPath.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2188/AppDomainWithMultipleSearchPath.cs @@ -26,7 +26,7 @@ public void WhenSerchInMultiplePathsThenNotThrows() AppDomain.CurrentDomain.AppendPrivatePath("bin"); AppDomain.CurrentDomain.AppendPrivatePath("DbScripts"); var configuration = new MyNhConfiguration(); - configuration.DefaultConfigurationFilePath().Should().Be(expected); + Assert.That(configuration.DefaultConfigurationFilePath(), Is.EqualTo(expected)); } finally { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs index 1479a2846f8..a87cb581010 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs @@ -1,4 +1,5 @@ using System.Linq; +using NHibernate.DomainModel; using NHibernate.Linq; using NUnit.Framework; using SharpTestsEx; @@ -33,7 +34,8 @@ public void QueryShouldWork() .Where(a => a.Name.StartsWith("F")) .ToArray(); - actual.Select(a => a.Name).Should().Have.SameSequenceAs("Fez", "Foo"); + var expected = new[] {"Fez", "Foo"}; + Assert.That(actual.Select(a => a.Name), Is.EquivalentTo(expected)); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs b/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs index 52bba5c2927..9d7d0a2b040 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs @@ -80,7 +80,7 @@ public void Dates_Before_1753_Should_Not_Insert_Null() using (var tx = session.BeginTransaction()) { var savedObj = session.Get(savedId); - savedObj.Date.Should().Be(expectedStoredValue); + Assert.That(savedObj.Date, Is.EqualTo(expectedStoredValue)); session.Delete(savedObj); tx.Commit(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2228/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2228/Fixture.cs index 315dfa6ad4a..2d02a154f9b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2228/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2228/Fixture.cs @@ -52,22 +52,22 @@ public void WhenStaleObjectStateThenMessageContainsEntity() { using (var scenario = new ParentWithTwoChildrenScenario(Sfi)) { - using (var client1 = OpenSession()) - { - var parentFromClient1 = client1.Get(scenario.ParentId); - NHibernateUtil.Initialize(parentFromClient1.Children); - var firstChildId = parentFromClient1.Children[0].Id; + using (var client1 = OpenSession()) + { + var parentFromClient1 = client1.Get(scenario.ParentId); + NHibernateUtil.Initialize(parentFromClient1.Children); + var firstChildId = parentFromClient1.Children[0].Id; - DeleteChildUsingAnotherSession(firstChildId); + DeleteChildUsingAnotherSession(firstChildId); - using (var tx1 = client1.BeginTransaction()) - { - parentFromClient1.Children[0].Description = "Modified info"; - var expectedException = tx1.Executing(x => x.Commit()).Throws().Exception; - expectedException.EntityName.Should().Be(typeof (Child).FullName); - expectedException.Identifier.Should().Be(firstChildId); - } - } + using (var tx1 = client1.BeginTransaction()) + { + parentFromClient1.Children[0].Description = "Modified info"; + var expectedException = Assert.Throws(() => tx1.Commit()); + Assert.That(expectedException.EntityName, Is.EqualTo(typeof (Child).FullName)); + Assert.That(expectedException.Identifier, Is.EqualTo(firstChildId)); + } + } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2230/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2230/Fixture.cs index e5a905fcd78..ad5f847cfda 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2230/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2230/Fixture.cs @@ -15,10 +15,10 @@ public void CanCreacteRetrieveDeleteComponentsWithPrivateReferenceSetterToParent var component = new MyComponentWithParent(entity){Something = "A"}; entity.Component = component; entity.Children = new List - { - new MyComponentWithParent(entity){Something = "B"}, + { + new MyComponentWithParent(entity){Something = "B"}, new MyComponentWithParent(entity){Something = "C"} - }; + }; object poid; using (var s = OpenSession()) using (var tx = s.BeginTransaction()) @@ -32,12 +32,12 @@ public void CanCreacteRetrieveDeleteComponentsWithPrivateReferenceSetterToParent { var savedEntity = s.Get(poid); var myComponentWithParent = savedEntity.Component; - myComponentWithParent.Should().Not.Be.Null(); - myComponentWithParent.Parent.Should().Be.SameInstanceAs(savedEntity); - myComponentWithParent.Something.Should().Be("A"); + Assert.That(myComponentWithParent, Is.Not.Null); + Assert.That(myComponentWithParent.Parent, Is.SameAs(savedEntity)); + Assert.That(myComponentWithParent.Something, Is.EqualTo("A")); - savedEntity.Children.Select(c => c.Something).Should().Have.SameValuesAs("B", "C"); - savedEntity.Children.Select(child=> child.Parent).All(parent => parent.Satisfy(myEntity => ReferenceEquals(myEntity, savedEntity))); + Assert.That(savedEntity.Children.Select(c => c.Something), Is.EquivalentTo(new [] {"B", "C"})); + Assert.That(savedEntity.Children.All(c => ReferenceEquals(c.Parent, savedEntity)), Is.True); s.Delete(savedEntity); tx.Commit(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs index 77a96df426d..57f5b878ddd 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs @@ -17,13 +17,13 @@ public class Fixture: BugTestCase [Test] public void CanQueryViaLinq() { - using (var s = OpenSession()) - { - var qry = from item in s.Query() where item.Relation == MyUserTypes.Value1 select item; + using (var s = OpenSession()) + { + var qry = from item in s.Query() where item.Relation == MyUserTypes.Value1 select item; - qry.ToList(); - qry.Executing(q => q.ToList()).NotThrows(); - } + qry.ToList(); + Assert.That(() => qry.ToList(), Throws.Nothing); + } } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs index 53e76669bd4..b41310e555e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs @@ -21,7 +21,7 @@ public void ShouldCreateSchemaWithDefaultClause() cfg.AddInputStream(stream); new SchemaExport(cfg).Execute(s => script.AppendLine(s), false, false); - script.ToString().Should().Contain("MyNameForFK"); + Assert.That(script.ToString(), Is.StringContaining("MyNameForFK")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2245/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2245/Fixture.cs index 0656d37c19e..911d5b8c797 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2245/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2245/Fixture.cs @@ -47,7 +47,7 @@ public void TestDelete_OptimisticLockNone() // Now delete from second session using (ITransaction trans2 = session2.BeginTransaction()) { - session2.Executing(s=> s.Delete(f2)).NotThrows(); + Assert.That(() => session2.Delete(f2), Throws.Nothing); trans2.Commit(); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2251/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2251/Fixture.cs index 4dda6c88a32..d9d5ff59c18 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2251/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2251/Fixture.cs @@ -19,12 +19,11 @@ public void WhenUseFutureSkipTakeThenNotThrow() int rowcount; Foo[] items; - Executing.This(() => - { - rowcount = rowcountQuery.Value; - items = resultsQuery.ToArray(); - } - ).Should().NotThrow(); + Assert.That(() => + { + rowcount = rowcountQuery.Value; + items = resultsQuery.ToArray(); + }, Throws.Nothing); } } @@ -40,12 +39,11 @@ public void EnlistingFirstThePaginationAndThenTheRowCountDoesNotThrows() int rowcount; Foo[] items; - Executing.This(() => + Assert.That(() => { rowcount = rowcountQuery.Value; items = resultsQuery.ToArray(); - } - ).Should().NotThrow(); + }, Throws.Nothing); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2266/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2266/Fixture.cs index 942bbce5ea8..9ce05da7618 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2266/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2266/Fixture.cs @@ -12,8 +12,9 @@ public void WhenBuildSessionFactoryThenThrows() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2266.Mappings.hbm.xml", GetType().Assembly); - cfg.Executing(c => c.BuildSessionFactory()).Throws() - .And.ValueOf.Message.Should().Contain("does not have mapped subclasses").And.Contain(typeof(TemporaryToken).FullName); + Assert.That(() => cfg.BuildSessionFactory(), Throws.TypeOf() + .And.Message.ContainsSubstring("does not have mapped subclasses") + .And.Message.ContainsSubstring(typeof (TemporaryToken).FullName)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2287/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2287/Fixture.cs index 89f1ccff655..a7044bd7c23 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2287/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2287/Fixture.cs @@ -13,7 +13,7 @@ public void DotInStringLiteralsConstant() using (ISession session = OpenSession()) { var query = string.Format("from Foo f {0}where f.", Environment.NewLine); - session.Executing(s => s.CreateQuery(query).List()).Throws(); + Assert.That(() => session.CreateQuery(query).List(), Throws.TypeOf()); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2288/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2288/Fixture.cs index ab6bfcea46f..e5a5b98c4ae 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2288/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2288/Fixture.cs @@ -22,8 +22,7 @@ private static void AssertThatCheckOnTableExistenceIsCorrect(Configuration confi var sb = new StringBuilder(500); su.Execute(x => sb.AppendLine(x), false, false); string script = sb.ToString(); - script.Should().Contain( - "if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'dbo.[Aclasses_Id_FK]') AND parent_object_id = OBJECT_ID('dbo.Aclass'))"); + Assert.That(script, Is.StringContaining("if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'dbo.[Aclasses_Id_FK]') AND parent_object_id = OBJECT_ID('dbo.Aclass'))")); } [Test] diff --git a/src/NHibernate.Test/NHSpecificTest/NH2293/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2293/Fixture.cs index 3d30964406b..11d3ffee251 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2293/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2293/Fixture.cs @@ -20,7 +20,7 @@ public void WhenQueryHasJustAfromThenThrowQuerySyntaxException() { using (ISession session = OpenSession()) { - session.Executing(s => s.CreateQuery("from").List()).Throws(); + Assert.That(() => session.CreateQuery("from").List(), Throws.TypeOf()); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2294/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2294/Fixture.cs index 479a22f7ed4..ae194107d23 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2294/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2294/Fixture.cs @@ -20,7 +20,7 @@ public void WhenQueryHasJustAWhereThenThrowQuerySyntaxException() { using (ISession session = OpenSession()) { - session.Executing(s => s.CreateQuery("where").List()).Throws(); + Assert.That(() => session.CreateQuery("where").List(), Throws.TypeOf()); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs index 1e081c20e64..a527bfcdf65 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs @@ -66,7 +66,7 @@ public void Test() // count of entities we want: int ourEntities = orders.Count + orders.Sum(o => o.Products.Count); - s.Statistics.EntityCount.Should().Be(ourEntities); + Assert.That(s.Statistics.EntityCount, Is.EqualTo(ourEntities)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2303/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2303/Fixture.cs index ea1751a8185..39c8240e7a1 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2303/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2303/Fixture.cs @@ -10,10 +10,9 @@ public class Fixture public void IndependentSubclassElementCanExtendSubclass() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); - cfg.Executing(c => c.AddResource("NHibernate.Test.NHSpecificTest.NH2303.Mappings.hbm.xml", GetType().Assembly)). - NotThrows(); + Assert.That(() => cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2303.Mappings.hbm.xml", GetType().Assembly), Throws.Nothing); cfg.BuildSessionFactory(); - cfg.Executing(c => c.BuildSessionFactory()).NotThrows(); + Assert.That(() => cfg.BuildSessionFactory(), Throws.Nothing); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2313/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2313/Fixture.cs index 93762b489be..6e990d1201c 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2313/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2313/Fixture.cs @@ -11,7 +11,8 @@ public void WhenLoadWorngMappingThenMessageShouldContaingWrongClassName() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2313.Mappings.hbm.xml", GetType().Assembly); - cfg.Executing(c=> c.BuildSessionFactory()).Throws().And.ValueOf.Message.Should().Contain("TheOther"); + Assert.That(() => cfg.BuildSessionFactory(), Throws.TypeOf() + .And.Message.ContainsSubstring("TheOther")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs index 404c487c4dc..a90c6f97330 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs @@ -35,7 +35,7 @@ public void QueryShouldWork() var expected = session.CreateQuery("select a.id from Artist a take 3").List(); var actual = session.Query().Take(3).Select(a => a.Id).ToArray(); - actual.Should().Have.SameValuesAs(expected); + Assert.That(actual, Is.EquivalentTo(expected)); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2324/BulkUpdateWithCustomCompositeType.cs b/src/NHibernate.Test/NHSpecificTest/NH2324/BulkUpdateWithCustomCompositeType.cs index 4b617dd35a7..5bee039f7cb 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2324/BulkUpdateWithCustomCompositeType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2324/BulkUpdateWithCustomCompositeType.cs @@ -17,9 +17,9 @@ public Scenario(ISessionFactory factory) using (ITransaction t = s.BeginTransaction()) { var e = new Entity - { - Data = new CompositeData {DataA = new DateTime(2010, 1, 1), DataB = new DateTime(2010, 2, 2)} - }; + { + Data = new CompositeData {DataA = new DateTime(2010, 1, 1), DataB = new DateTime(2010, 2, 2)} + }; s.Save(e); t.Commit(); } @@ -50,7 +50,7 @@ public void ShouldAllowBulkupdateWithCompositeUserType() .SetDateTime("dataA", new DateTime(2010, 3, 3)) .SetDateTime("dataB", new DateTime(2010, 4, 4)); - query.Executing(q => q.ExecuteUpdate()).NotThrows(); + Assert.That(() => query.ExecuteUpdate(), Throws.Nothing); t.Commit(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2331/Nh2331Test.cs b/src/NHibernate.Test/NHSpecificTest/NH2331/Nh2331Test.cs index 2068ab341cd..9e6779344c7 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2331/Nh2331Test.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2331/Nh2331Test.cs @@ -24,54 +24,54 @@ protected override void OnSetUp() base.OnSetUp(); var person0 = new Person - { - Name = "Schorsch", - }; + { + Name = "Schorsch", + }; var person1 = new Person - { - Name = "Sepp", - }; + { + Name = "Sepp", + }; var person2 = new Person - { - Name = "Detlef", - }; + { + Name = "Detlef", + }; var forum0 = new Forum - { - Name = "Oof", - Dollars = 1887.00, - }; + { + Name = "Oof", + Dollars = 1887.00, + }; var forum1 = new Forum - { - Name = "Rab", - Dollars = 33.00, - }; + { + Name = "Rab", + Dollars = 33.00, + }; var forum2 = new Forum - { - Name = "Main", - Dollars = 42.42, - }; + { + Name = "Main", + Dollars = 42.42, + }; var group0 = new MemberGroup - { - Name = "Gruppe Bla", - Members = new List(), - Forums = new List(), - }; + { + Name = "Gruppe Bla", + Members = new List(), + Forums = new List(), + }; group0.Members.Add(person0); group0.Forums.Add(forum0); group0.Forums.Add(forum1); var group1 = new MemberGroup - { - Name = "Gruppe Blub", - Members = new List(), - Forums = new List(), - }; + { + Name = "Gruppe Blub", + Members = new List(), + Forums = new List(), + }; group1.Members.Add(person1); group1.Members.Add(person2); group1.Forums.Add(forum2); @@ -106,46 +106,46 @@ public void DetachedCriteriaCorrelatedQueryExplodes() { using (ISession session = OpenSession()) { - DetachedCriteria memberGroupCriteria - = DetachedCriteria - .For() - .CreateAlias("Members", "m") - .CreateAlias("Forums", "f") - .Add(Restrictions.EqProperty("m.Id", "p.Id")) - .SetProjection(Projections.Property("f.Id")) - ; - - var ids = new List(); - ids.Add(person0Id); - ids.Add(person1Id); - - DetachedCriteria forumCriteria - = DetachedCriteria - .For("fff") - .Add(Restrictions.NotEqProperty("Id", "p.Id")) - .Add(Subqueries.PropertyIn("Id", memberGroupCriteria)) - .SetProjection - ( - Projections.Sum("Dollars") - ) - ; - - DetachedCriteria personCriteria - = DetachedCriteria - .For("p") - .Add(Restrictions.InG("Id", ids)) - .SetProjection - ( - Projections - .ProjectionList() - .Add(Projections.Property("Name"), "Name") - .Add(Projections.SubQuery(forumCriteria), "Sum") - ) - .SetResultTransformer(Transformers.AliasToBean(typeof (Bar))) - ; - - ICriteria criteria = personCriteria.GetExecutableCriteria(session); - criteria.Executing(c => c.List()).NotThrows(); + DetachedCriteria memberGroupCriteria + = DetachedCriteria + .For() + .CreateAlias("Members", "m") + .CreateAlias("Forums", "f") + .Add(Restrictions.EqProperty("m.Id", "p.Id")) + .SetProjection(Projections.Property("f.Id")) + ; + + var ids = new List(); + ids.Add(person0Id); + ids.Add(person1Id); + + DetachedCriteria forumCriteria + = DetachedCriteria + .For("fff") + .Add(Restrictions.NotEqProperty("Id", "p.Id")) + .Add(Subqueries.PropertyIn("Id", memberGroupCriteria)) + .SetProjection + ( + Projections.Sum("Dollars") + ) + ; + + DetachedCriteria personCriteria + = DetachedCriteria + .For("p") + .Add(Restrictions.InG("Id", ids)) + .SetProjection + ( + Projections + .ProjectionList() + .Add(Projections.Property("Name"), "Name") + .Add(Projections.SubQuery(forumCriteria), "Sum") + ) + .SetResultTransformer(Transformers.AliasToBean(typeof (Bar))) + ; + + ICriteria criteria = personCriteria.GetExecutableCriteria(session); + Assert.That(() => criteria.List(), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2341/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2341/Fixture.cs index c0413962f8e..b6b62de860a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2341/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2341/Fixture.cs @@ -22,7 +22,7 @@ public void WhenSaveInstanceOfConcreteInheritedThenNotThrows() using (var tx = session.BeginTransaction()) { var entity = new ConcreteB(); - session.Executing(s => s.Save(entity)).NotThrows(); + Assert.That(() => session.Save(entity), Throws.Nothing); tx.Commit(); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2366/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2366/Fixture.cs index 7f1554bb4fc..5b111094ea5 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2366/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2366/Fixture.cs @@ -47,7 +47,7 @@ public void Test() { using (ISession session = OpenSession()) { - session.Executing(s=> s.CreateQuery("from One").List()).NotThrows(); + Assert.That(() => session.CreateQuery("from One").List(), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs index ae52d3f154f..ac9b8850f3c 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs @@ -64,7 +64,7 @@ public void WhenTakeBeforeCountShouldApplyTake() // This is another case where we have to work with subqueries and we have to write a specific query rewriter for Skip/Take instead flat the query in QueryReferenceExpressionFlattener //var actual = session.CreateQuery("select count(s) from Something s where s in (from Something take 3)").UniqueResult(); var actual = session.Query().Take(3).Count(); - actual.Should().Be(3); + Assert.That(actual, Is.EqualTo(3)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2488/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2488/Fixture.cs index 17cb3e94b33..d6097150066 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2488/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2488/Fixture.cs @@ -21,10 +21,10 @@ public FetchSelectScenario(ISessionFactory factory) using (ITransaction t = s.BeginTransaction()) { var entity = new Derived1 - { - ShortContent = "Short", - LongContent = "LongLongLongLongLong", - }; + { + ShortContent = "Short", + LongContent = "LongLongLongLongLong", + }; s.Save(entity); t.Commit(); } @@ -55,10 +55,10 @@ public FetchJoinScenario(ISessionFactory factory) using (ITransaction t = s.BeginTransaction()) { var entity = new Derived2 - { - ShortContent = "Short", - LongContent = "LongLongLongLongLong", - }; + { + ShortContent = "Short", + LongContent = "LongLongLongLongLong", + }; s.Save(entity); t.Commit(); } @@ -127,13 +127,13 @@ public void ShouldNotQueryLazyProperties_FetchJoin() using (var ls = new SqlLogSpy()) { items = s.CreateQuery("from Base2").List(); - ls.GetWholeLog().Should().Not.Contain("LongContent"); + Assert.That(ls.GetWholeLog(), Is.Not.StringContaining("LongContent")); } var item = (Derived2) items[0]; - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.False(); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.False); string lc = item.LongContent; - lc.Should().Not.Be.NullOrEmpty(); - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.True(); + Assert.That(lc, Is.Not.Null.And.Not.Empty); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.True); } } } @@ -152,13 +152,13 @@ public void ShouldNotQueryLazyProperties_FetchSelect() using(var ls = new SqlLogSpy()) { items = s.CreateQuery("from Base1").List(); - ls.GetWholeLog().Should().Not.Contain("LongContent"); + Assert.That(ls.GetWholeLog(), Is.Not.StringContaining("LongContent")); } var item = (Derived1) items[0]; - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.False(); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.False); string lc = item.LongContent; - lc.Should().Not.Be.NullOrEmpty(); - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.True(); + Assert.That(lc, Is.Not.Null.And.Not.Empty); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.True); } } } @@ -177,13 +177,13 @@ public void ShouldNotQueryLazyProperties_Joinedsubclass() using (var ls = new SqlLogSpy()) { items = s.CreateQuery("from Base3").List(); - ls.GetWholeLog().Should().Not.Contain("LongContent"); + Assert.That(ls.GetWholeLog(), Is.Not.StringContaining("LongContent")); } var item = (Derived3)items[0]; - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.False(); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.False); string lc = item.LongContent; - lc.Should().Not.Be.NullOrEmpty(); - NHibernateUtil.IsPropertyInitialized(item, "LongContent").Should().Be.True(); + Assert.That(lc, Is.Not.Null.And.Not.Empty); + Assert.That(NHibernateUtil.IsPropertyInitialized(item, "LongContent"), Is.True); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2489/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2489/Fixture.cs index 9c8565b8efd..0d075ec4f0d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2489/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2489/Fixture.cs @@ -58,22 +58,22 @@ public MapScenario(ISessionFactory factory) { var entity = new Base(); entity.NamedChildren = new Dictionary - { - {"Child1", new Child()}, - {"NullChild", null}, - }; + { + {"Child1", new Child()}, + {"NullChild", null}, + }; - var child1 = new AnotherChild { Name = "AnotherChild1" }; - var child2 = new AnotherChild { Name = "AnotherChild2" }; + var child1 = new AnotherChild { Name = "AnotherChild1" }; + var child2 = new AnotherChild { Name = "AnotherChild2" }; - s.Save(child1); - s.Save(child2); + s.Save(child1); + s.Save(child2); - entity.OneToManyNamedChildren = new Dictionary - { - {"AnotherChild1" , child1}, - {"AnotherChild2" , child2} - }; + entity.OneToManyNamedChildren = new Dictionary + { + {"AnotherChild1" , child1}, + {"AnotherChild2" , child2} + }; s.Save(entity); t.Commit(); @@ -109,9 +109,9 @@ public void List_InvalidIndex() // accessing an invalid index should throw an exception var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.Children.Count.Should().Be.EqualTo(2); - NHibernateUtil.IsInitialized(entity.Children).Should().Be.False(); - Executing.This(() => { Child ignored = entity.Children[2]; }).Should().Throw(); + Assert.That(entity.Children.Count, Is.EqualTo(2)); + Assert.That(NHibernateUtil.IsInitialized(entity.Children), Is.False); + Assert.That(() => { Child ignored = entity.Children[2]; }, Throws.TypeOf()); } } } @@ -130,14 +130,14 @@ public void List_NullChild() // accessing an invalid index should throw an exception var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.Children.Count.Should().Not.Be.EqualTo(0); + Assert.That(entity.Children.Count, Is.Not.EqualTo(0)); //entity.Children.Count.Should().Be.EqualTo(2); - NHibernateUtil.IsInitialized(entity.Children).Should().Be.False(); + Assert.That(NHibernateUtil.IsInitialized(entity.Children), Is.False); var sigil = new Child(); Child child = sigil; - Executing.This(() => { child = entity.Children[0]; }).Should().NotThrow(); - child.Should().Not.Be.EqualTo(sigil); - child.Should().Be.Null(); + Assert.That(() => { child = entity.Children[0]; }, Throws.Nothing); + Assert.That(child, Is.Not.EqualTo(sigil)); + Assert.That(child, Is.Null); } } } @@ -155,12 +155,12 @@ public void Map_Item() // accessing an invalid key should fail or throw an exception, depending on method var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.NamedChildren.Count.Should().Be.EqualTo(2); - entity.OneToManyNamedChildren.Count.Should().Be.EqualTo(2); - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); - Executing.This(() => { Child ignored = entity.NamedChildren["InvalidKey"]; }).Should().Throw(); - Executing.This(() => { AnotherChild ignored = entity.OneToManyNamedChildren["InvalidKey"]; }).Should().Throw(); - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); + Assert.That(entity.NamedChildren.Count, Is.EqualTo(2)); + Assert.That(entity.OneToManyNamedChildren.Count, Is.EqualTo(2)); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); + Assert.That(() => { Child ignored = entity.NamedChildren["InvalidKey"]; }, Throws.TypeOf()); + Assert.That(() => { AnotherChild ignored = entity.OneToManyNamedChildren["InvalidKey"]; }, Throws.TypeOf()); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); } } } @@ -178,15 +178,15 @@ public void Map_TryGetValue_Invalid() // accessing an invalid key should fail or throw an exception, depending on method var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.NamedChildren.Count.Should().Be.EqualTo(2); - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); + Assert.That(entity.NamedChildren.Count, Is.EqualTo(2)); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); Child child; - entity.NamedChildren.TryGetValue("InvalidKey", out child).Should().Be.False(); - child.Should().Be.Null(); - AnotherChild anotherChild; - entity.OneToManyNamedChildren.TryGetValue("InvalidKey", out anotherChild).Should().Be.False(); - child.Should().Be.Null(); - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); + Assert.That(entity.NamedChildren.TryGetValue("InvalidKey", out child), Is.False); + Assert.That(child, Is.Null); + AnotherChild anotherChild; + Assert.That(entity.OneToManyNamedChildren.TryGetValue("InvalidKey", out anotherChild), Is.False); + Assert.That(child, Is.Null); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); } } } @@ -203,15 +203,15 @@ public void Map_NullChild() { var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.NamedChildren.Count.Should().Not.Be.EqualTo(0); + Assert.That(entity.NamedChildren.Count, Is.Not.EqualTo(0)); //entity.NamedChildren.Count.Should().Be.EqualTo(2); - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); // null valued child shouldn't cause errors var sigil = new Child(); Child child = sigil; Assert.DoesNotThrow(() => { child = entity.NamedChildren["NullChild"]; }); - child.Should().Not.Be.EqualTo(sigil); - child.Should().Be.Null(); + Assert.That(child, Is.Not.EqualTo(sigil)); + Assert.That(child, Is.Null); } } } @@ -228,14 +228,13 @@ public void Map_NullChild_TryGetValue() { var entity = s.CreateQuery("from Base").UniqueResult(); // null collection members don't seem to work, at least for lazy="extra" collections - entity.NamedChildren.Count.Should().Not.Be.EqualTo(0); + Assert.That(entity.NamedChildren.Count, Is.Not.EqualTo(0)); //entity.NamedChildren.Count.Should().Be.EqualTo(2); // null valued child shouldn't cause errors - NHibernateUtil.IsInitialized(entity.NamedChildren).Should().Be.False(); + Assert.That(NHibernateUtil.IsInitialized(entity.NamedChildren), Is.False); Child child; - entity.NamedChildren.TryGetValue("NullChild", out child) - .Should().Be.True(); - child.Should().Be.Null(); + Assert.That(entity.NamedChildren.TryGetValue("NullChild", out child), Is.True); + Assert.That(child, Is.Null); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2490/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2490/Fixture.cs index 7316e3ba316..8879292bd17 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2490/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2490/Fixture.cs @@ -32,7 +32,7 @@ public void BadSqlFromJoinLogicError() using (ITransaction t = s.BeginTransaction()) { var q = s.CreateQuery("from Base"); - q.Executing(query => query.List()).NotThrows(); + Assert.That(() => q.List(), Throws.Nothing); } } finally diff --git a/src/NHibernate.Test/NHSpecificTest/NH2491/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2491/Fixture.cs index ad80c15d9a3..34a805042a6 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2491/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2491/Fixture.cs @@ -57,7 +57,7 @@ public void InheritanceSameColumnName() // this line crashes because it tries to find the base class by // the wrong column name. BaseClass another; - Executing.This(() => another = referencing.SubClass.Another).Should().NotThrow(); + Assert.That(() => another = referencing.SubClass.Another, Throws.Nothing); transaction.Commit(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2505/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2505/Fixture.cs index 886a71fd2a8..9d16829d2af 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2505/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2505/Fixture.cs @@ -60,13 +60,15 @@ public void WhenQueryConstantEqualToMemberThenDoesNotUseTheCaseConstructor() { using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => x.Alive == false).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0); + var list = session.Query().Where(x => x.Alive == false).ToList(); + Assert.That(list, Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0)); } using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => true == x.Alive).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0); + var list = session.Query().Where(x => true == x.Alive).ToList(); + Assert.That(list, Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0)); } } } @@ -81,13 +83,13 @@ public void WhenQueryConstantNotEqualToMemberThenDoesNotUseTheCaseConstructor() { using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => x.Alive != false).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0); + Assert.That(session.Query().Where(x => x.Alive != false).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0)); } using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => true != x.Alive).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0); + Assert.That(session.Query().Where(x => true != x.Alive).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0)); } } } @@ -103,7 +105,7 @@ public void WhenQueryComplexEqualToComplexThentUseTheCaseConstructorForBoth() using (var sqls = new SqlLogSpy()) { session.Query().Where(x => (5 > x.Something) == (x.Something < 10)).ToList(); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(2); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(2)); } } } @@ -118,13 +120,13 @@ public void WhenQueryConstantEqualToNullableMemberThenUseTheCaseConstructorForMe { using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => x.MayBeAlive == false).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(session.Query().Where(x => x.MayBeAlive == false).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => true == x.MayBeAlive).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(session.Query().Where(x => true == x.MayBeAlive).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } } } @@ -140,12 +142,12 @@ public void WhenQueryConstantEqualToNullableMemberValueThenDoesNotUseTheCaseCons using (var sqls = new SqlLogSpy()) { session.Query().Where(x => x.MayBeAlive.Value == false).ToList(); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } using (var sqls = new SqlLogSpy()) { session.Query().Where(x => true == x.MayBeAlive.Value).ToList(); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } } } @@ -160,13 +162,13 @@ public void WhenQueryConstantNotEqualToNullableMemberThenUseTheCaseConstructorFo { using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => x.MayBeAlive != false).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(session.Query().Where(x => x.MayBeAlive != false).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } using (var sqls = new SqlLogSpy()) { - session.Query().Where(x => true != x.MayBeAlive).Should().Have.Count.EqualTo(1); - caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(1); + Assert.That(session.Query().Where(x => true != x.MayBeAlive).ToList(), Has.Count.EqualTo(1)); + Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(1)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2530/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2530/Fixture.cs index d1ec4222242..6bcab8805c9 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2530/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2530/Fixture.cs @@ -47,7 +47,7 @@ public void WhenTryToGetHighThenExceptionShouldContainWhereClause() using (var tx = session.BeginTransaction()) { var customer = new Customer { Name = "Mengano" }; - session.Executing(s => s.Persist(customer)).Throws().And.ValueOf.Message.Should().Contain("Entity = 'Customer'"); + Assert.That(() => session.Persist(customer), Throws.Exception.Message.ContainsSubstring("Entity = 'Customer'")); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2565/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2565/Fixture.cs index 82c001e308e..9c940c517d8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2565/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2565/Fixture.cs @@ -52,7 +52,7 @@ public void WhenUseLoadThenCanUsePersistToModify() var task = s.Load(scenario.TaskId); task.Description = "Could be something nice"; s.Persist(task); - s.Executing(session => session.Persist(task)).NotThrows(); + Assert.That(() => s.Persist(task), Throws.Nothing); tx.Commit(); } } @@ -68,7 +68,7 @@ public void WhenUseGetThenCanUsePersistToModify() { var task = s.Get(scenario.TaskId); task.Description = "Could be something nice"; - s.Executing(session => session.Persist(task)).NotThrows(); + Assert.That(() => s.Persist(task), Throws.Nothing); tx.Commit(); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs b/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs index f393eb36bc0..55ddbb5c80d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs @@ -28,10 +28,10 @@ private HbmMapping GetMappings() var mapper = new ModelMapper(); mapper.Class(rm=> rm.Id(x=> x.Id)); mapper.Class(rm => - { - rm.Id(x => x.Id); - rm.Bag(x => x.Relateds, am => am.Persister(), rel=> rel.OneToMany()); - }); + { + rm.Id(x => x.Id); + rm.Bag(x => x.Relateds, am => am.Persister(), rel => rel.OneToMany()); + }); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); return mappings; } @@ -41,7 +41,7 @@ public void BuildingSessionFactoryShouldNotThrows() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddMapping(GetMappings()); - cfg.Executing(c=>c.BuildSessionFactory()).NotThrows(); + Assert.That(() => cfg.BuildSessionFactory(), Throws.Nothing); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2569/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2569/Fixture.cs index ef41f6ae8c2..ca58c17d961 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2569/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2569/Fixture.cs @@ -18,21 +18,21 @@ public void WhenMapHiloToDifferentSchemaThanClassThenIdHasTheMappedSchema() { var mapper = new ModelMapper(); mapper.Class(cm => - { + { cm.Schema("aSchema"); cm.Id(x => x.Id, idm => idm.Generator(Generators.HighLow, gm => gm.Params(new - { - table = "hilosequences", - schema="gSchema" - }))); - }); + { + table = "hilosequences", + schema="gSchema" + }))); + }); var conf = new Configuration(); conf.DataBaseIntegration(x=> x.Dialect()); conf.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), "wholeDomain"); var mappings = conf.CreateMappings(Dialect.Dialect.GetDialect()); var pc = mappings.GetClass(typeof(MyClass).FullName); - ((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"].Should().Be("gSchema"); + Assert.That(((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"], Is.EqualTo("gSchema")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2580/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2580/Fixture.cs index ad5495298b0..61db6840e98 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2580/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2580/Fixture.cs @@ -15,8 +15,8 @@ public void WhenPersisterNotFoundShouldThrowAMoreExplicitException() { using (var s = OpenSession()) { - var exeption = s.Executing(x=> x.Get(1)).Throws().Exception; - exeption.Message.ToLowerInvariant().Should().Contain("possible cause"); + var exeption = Assert.Throws(() => s.Get(1)); + Assert.That(exeption.Message.ToLowerInvariant(), Is.StringContaining("possible cause")); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2603/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2603/Fixture.cs index 4fd1fb3a59e..c339af0c314 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2603/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2603/Fixture.cs @@ -17,28 +17,24 @@ public ListScenario(ISessionFactory factory) { this.factory = factory; using (ISession s = factory.OpenSession()) + using (ITransaction t = s.BeginTransaction()) { - using (ITransaction t = s.BeginTransaction()) - { - var entity = new Parent(); - var child = new Child(); - entity.ListChildren = new List {null, child, null}; - s.Save(entity); - t.Commit(); - } + var entity = new Parent(); + var child = new Child(); + entity.ListChildren = new List {null, child, null}; + s.Save(entity); + t.Commit(); } } public void Dispose() { using (ISession s = factory.OpenSession()) + using (ITransaction t = s.BeginTransaction()) { - using (ITransaction t = s.BeginTransaction()) - { - s.Delete("from Parent"); - s.Delete("from Child"); - t.Commit(); - } + s.Delete("from Parent"); + s.Delete("from Child"); + t.Commit(); } } } @@ -51,32 +47,28 @@ public MapScenario(ISessionFactory factory) { this.factory = factory; using (ISession s = factory.OpenSession()) + using (ITransaction t = s.BeginTransaction()) { - using (ITransaction t = s.BeginTransaction()) + var entity = new Parent(); + entity.MapChildren = new Dictionary { - var entity = new Parent(); - entity.MapChildren = new Dictionary - { - {0, null}, - {1, new Child()}, - {2, null}, - }; - s.Save(entity); - t.Commit(); - } + {0, null}, + {1, new Child()}, + {2, null}, + }; + s.Save(entity); + t.Commit(); } } public void Dispose() { using (ISession s = factory.OpenSession()) + using (ITransaction t = s.BeginTransaction()) { - using (ITransaction t = s.BeginTransaction()) - { - s.Delete("from Parent"); - s.Delete("from Child"); - t.Commit(); - } + s.Delete("from Parent"); + s.Delete("from Child"); + t.Commit(); } } } @@ -92,20 +84,18 @@ public void List() // the effective ammount store will be 1(one) because ther is only one valid element but whem we initialize the collection // it will have 2 elements (the first with null) using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { - using (ITransaction t = s.BeginTransaction()) - { - var entity = s.CreateQuery("from Parent").UniqueResult(); - IList members = s.GetNamedQuery("ListMemberSpy") - .SetParameter("parentid", entity.Id) - .List(); - int lazyCount = entity.ListChildren.Count; - NHibernateUtil.IsInitialized(entity.ListChildren).Should().Be.False(); - NHibernateUtil.Initialize(entity.ListChildren); - int initCount = entity.ListChildren.Count; - initCount.Should().Be.EqualTo(lazyCount); - members.Count.Should("because only the valid element should be persisted.").Be(1); - } + var entity = s.CreateQuery("from Parent").UniqueResult(); + IList members = s.GetNamedQuery("ListMemberSpy") + .SetParameter("parentid", entity.Id) + .List(); + int lazyCount = entity.ListChildren.Count; + Assert.That(NHibernateUtil.IsInitialized(entity.ListChildren), Is.False); + NHibernateUtil.Initialize(entity.ListChildren); + int initCount = entity.ListChildren.Count; + Assert.That(initCount, Is.EqualTo(lazyCount)); + Assert.That(members, Has.Count.EqualTo(1), "because only the valid element should be persisted."); } } } @@ -114,23 +104,21 @@ public void List() public void Map() { using (new MapScenario(Sfi)) + using (ISession s = OpenSession()) { - using (ISession s = OpenSession()) + // for the case of what really matter is the key, then NH should count the KEY and not the elements. + using (ITransaction t = s.BeginTransaction()) { - // for the case of what really matter is the key, then NH should count the KEY and not the elements. - using (ITransaction t = s.BeginTransaction()) - { - var entity = s.CreateQuery("from Parent").UniqueResult(); - IList members = s.GetNamedQuery("MapMemberSpy") - .SetParameter("parentid", entity.Id) - .List(); - int lazyCount = entity.MapChildren.Count; - NHibernateUtil.IsInitialized(entity.MapChildren).Should().Be.False(); - NHibernateUtil.Initialize(entity.MapChildren); - int initCount = entity.MapChildren.Count; - initCount.Should().Be.EqualTo(lazyCount); - members.Count.Should("because all elements with a valid key should be persisted.").Be(3); - } + var entity = s.CreateQuery("from Parent").UniqueResult(); + IList members = s.GetNamedQuery("MapMemberSpy") + .SetParameter("parentid", entity.Id) + .List(); + int lazyCount = entity.MapChildren.Count; + Assert.That(NHibernateUtil.IsInitialized(entity.MapChildren), Is.False); + NHibernateUtil.Initialize(entity.MapChildren); + int initCount = entity.MapChildren.Count; + Assert.That(initCount, Is.EqualTo(lazyCount)); + Assert.That(members, Has.Count.EqualTo(3), "because all elements with a valid key should be persisted."); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs index 371f642a39b..c881b651cf1 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs @@ -33,11 +33,11 @@ protected override HbmMapping GetMappings() }, c => c.OneToMany()); }); mapper.Class(cm => - { + { cm.Id(x => x.Id, m => { }); cm.Property(x => x.Date); cm.ManyToOne(x => x.Customer, map => map.Column("CUSTOMERID")); - }); + }); return mapper.CompileMappingForAllExplicitlyAddedEntities(); } @@ -94,10 +94,10 @@ public void GettingCustomerDoesNotThrow() using (var session = OpenSession()) { Customer customer = null; - Executing.This(()=> customer = session.Get(scenario.CustomerId)).Should().NotThrow(); + Assert.That(() => customer = session.Get(scenario.CustomerId), Throws.Nothing); // An entity defined with lazy=false can't have lazy properties (as reported by the WARNING; see EntityMetamodel class) - NHibernateUtil.IsInitialized(customer.Address).Should().Be.True(); - customer.Address.Should().Be("Bah?!??"); + Assert.That(NHibernateUtil.IsInitialized(customer.Address), Is.True); + Assert.That(customer.Address, Is.EqualTo("Bah?!??")); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2660And2661/Test.cs b/src/NHibernate.Test/NHSpecificTest/NH2660And2661/Test.cs index 99b70371ebb..f6617a943fa 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2660And2661/Test.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2660And2661/Test.cs @@ -7,34 +7,34 @@ namespace NHibernate.Test.NHSpecificTest.NH2660And2661 { - [TestFixture] - public class Test : BugTestCase - { - protected override void OnSetUp() - { - base.OnSetUp(); - using (ISession session = OpenSession()) - { - DomainClass entity = new DomainClass { Id = 1, Data = DateTime.Parse("10:00") }; - session.Save(entity); - session.Flush(); - } - } + [TestFixture] + public class Test : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + DomainClass entity = new DomainClass { Id = 1, Data = DateTime.Parse("10:00") }; + session.Save(entity); + session.Flush(); + } + } - protected override void OnTearDown() - { - base.OnTearDown(); - using (ISession session = OpenSession()) - { + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { session.CreateQuery("delete from DomainClass").ExecuteUpdate(); - session.Flush(); - } - } + session.Flush(); + } + } - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return dialect is MsSql2008Dialect; - } + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2008Dialect; + } protected override void Configure(Configuration configuration) { @@ -43,17 +43,17 @@ protected override void Configure(Configuration configuration) configuration.DataBaseIntegration(x=> x.Driver()); } - [Test] - public void ShouldBeAbleToQueryEntity() - { - using (ISession session = OpenSession()) - { - var query = - session.CreateQuery( - @"from DomainClass entity where Data = :data"); - query.SetParameter("data", DateTime.Parse("10:00"), NHibernateUtil.Time); - query.Executing(x=> x.List()).NotThrows(); - } - } - } + [Test] + public void ShouldBeAbleToQueryEntity() + { + using (ISession session = OpenSession()) + { + var query = + session.CreateQuery( + @"from DomainClass entity where Data = :data"); + query.SetParameter("data", DateTime.Parse("10:00"), NHibernateUtil.Time); + Assert.That(() => query.List(), Throws.Nothing); + } + } + } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2662/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2662/Fixture.cs index 4432a8e2e25..b115446742f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2662/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2662/Fixture.cs @@ -8,60 +8,57 @@ namespace NHibernate.Test.NHSpecificTest.NH2662 { - public class Fixture : BugTestCase - { - [Test] - public void WhenCastAliasInQueryOverThenDoNotThrow() - { - using (var session = OpenSession()) + public class Fixture : BugTestCase + { + [Test] + public void WhenCastAliasInQueryOverThenDoNotThrow() + { + using (var session = OpenSession()) using (var tx = session.BeginTransaction()) - { - var customer = new Customer - { - Order = new PizzaOrder { OrderDate = DateTime.Now, PizzaName = "Margarita" } - }; + { + var customer = new Customer + { + Order = new PizzaOrder { OrderDate = DateTime.Now, PizzaName = "Margarita" } + }; - var customer2 = new Customer - { - Order = new Order { OrderDate = DateTime.Now.AddDays(1) } - }; + var customer2 = new Customer + { + Order = new Order { OrderDate = DateTime.Now.AddDays(1) } + }; - session.Save(customer); - session.Save(customer2); - session.Flush(); + session.Save(customer); + session.Save(customer2); + session.Flush(); - Executing.This( - () => - { - var temp = session.Query().Select( - c => new {c.Id, c.Order.OrderDate, ((PizzaOrder)c.Order).PizzaName }) - .ToArray(); + Assert.That(() => + { + var temp = session.Query().Select( + c => new {c.Id, c.Order.OrderDate, ((PizzaOrder)c.Order).PizzaName }) + .ToArray(); - foreach (var item in temp) { Trace.WriteLine(item.PizzaName);} - }) - .Should().NotThrow(); + foreach (var item in temp) { Trace.WriteLine(item.PizzaName);} + }, Throws.Nothing); - Executing.This( - () => - { - Order orderAlias = null; + Assert.That(() => + { + Order orderAlias = null; - var results = - session.QueryOver() - .Left.JoinAlias(o => o.Order, () => orderAlias) - .OrderBy(() => orderAlias.OrderDate).Asc - .SelectList(list => - list - .Select(o => o.Id) - .Select(() => orderAlias.OrderDate) - .Select(() => ((PizzaOrder) orderAlias).PizzaName)) - .List(); + var results = + session.QueryOver() + .Left.JoinAlias(o => o.Order, () => orderAlias) + .OrderBy(() => orderAlias.OrderDate).Asc + .SelectList(list => + list + .Select(o => o.Id) + .Select(() => orderAlias.OrderDate) + .Select(() => ((PizzaOrder) orderAlias).PizzaName)) + .List(); - Assert.That(results.Count, Is.EqualTo(2)); - Assert.That(results[0][2], Is.EqualTo("Margarita")); + Assert.That(results.Count, Is.EqualTo(2)); + Assert.That(results[0][2], Is.EqualTo("Margarita")); - }).Should().NotThrow(); - } - } - } + }, Throws.Nothing); + } + } + } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2691/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2691/Fixture.cs index 5e92311db1c..42d6b1ee641 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2691/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2691/Fixture.cs @@ -25,7 +25,7 @@ public void WhenUseCountWithOrderThenCutTheOrder() using (session.BeginTransaction()) { var baseQuery = from cat in session.Query() orderby cat.BirthDate select cat; - Executing.This(() => baseQuery.Count()).Should().NotThrow(); + Assert.That(() => baseQuery.Count(), Throws.Nothing); session.Transaction.Commit(); } } @@ -37,7 +37,7 @@ public void WhenUseLongCountWithOrderThenCutTheOrder() using (session.BeginTransaction()) { var baseQuery = from cat in session.Query() orderby cat.BirthDate select cat; - Executing.This(() => baseQuery.LongCount()).Should().NotThrow(); + Assert.That(() => baseQuery.LongCount(), Throws.Nothing); session.Transaction.Commit(); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2697/SampleTest.cs b/src/NHibernate.Test/NHSpecificTest/NH2697/SampleTest.cs index d86cc87d473..1e2ada06f74 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2697/SampleTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2697/SampleTest.cs @@ -65,9 +65,9 @@ protected override void OnTearDown() //} using (ISession session = this.OpenSession()) { - string hql = "from ArticleGroupItem"; - session.Delete(hql); - session.Flush(); + string hql = "from ArticleGroupItem"; + session.Delete(hql); + session.Flush(); } } @@ -90,7 +90,7 @@ public void Can_GetListOfArticleGroups() using (ISession session = this.OpenSession()) { result = session.CreateQuery(HQL).List(); } - result.Count.Should().Be.GreaterThan(0); + Assert.That(result.Count, Is.GreaterThan(0)); } [Test] @@ -113,7 +113,7 @@ public void Can_GetListOfArticles() using (ISession session = this.OpenSession()) { result = session.CreateQuery(HQL).List(); } - result.Count.Should().Be.GreaterThan(0); + Assert.That(result.Count, Is.GreaterThan(0)); } @@ -142,7 +142,7 @@ public void Can_SetArticleFavoriteWithHQL_NamedParam() using (ISession session = this.OpenSession()) { result = session.CreateQuery(HQL).List(); } - result.Count.Should().Be.GreaterThan(0); + Assert.That(result.Count, Is.GreaterThan(0)); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2705/Test.cs b/src/NHibernate.Test/NHSpecificTest/NH2705/Test.cs index bd12cbdbb45..12d632372cd 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2705/Test.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2705/Test.cs @@ -25,7 +25,7 @@ public void Fetch_OnComponent_ShouldNotThrow() { using (ISession s = OpenSession()) { - Executing.This(() => GetAndFetch("hello", s)).Should().NotThrow(); + Assert.That(() => GetAndFetch("hello", s), Throws.Nothing); } } @@ -36,8 +36,7 @@ public void HqlQueryWithFetch_WhenDerivedClassesUseComponentAndManyToOne_DoesNot { using (var log = new SqlLogSpy()) { - Executing.This(() => s.CreateQuery("from ItemWithComponentSubItem i left join fetch i.SubItem").List() - ).Should().NotThrow(); + Assert.That(() => s.CreateQuery("from ItemWithComponentSubItem i left join fetch i.SubItem").List(), Throws.Nothing); } } } @@ -49,8 +48,7 @@ public void HqlQueryWithFetch_WhenDerivedClassesUseComponentAndEagerFetchManyToO { using (var log = new SqlLogSpy()) { - Executing.This(() => s.CreateQuery("from ItemWithComponentSubItem i left join fetch i.SubItem.Details").List() - ).Should().NotThrow(); + Assert.That(() => s.CreateQuery("from ItemWithComponentSubItem i left join fetch i.SubItem.Details").List(), Throws.Nothing); } } } @@ -62,15 +60,13 @@ public void LinqQueryWithFetch_WhenDerivedClassesUseComponentAndManyToOne_DoesNo { using (var log = new SqlLogSpy()) { - Executing.This(() => s.Query() - .Fetch(p => p.SubItem).ToList() - ).Should().NotThrow(); + Assert.That(() => s.Query() + .Fetch(p => p.SubItem).ToList(), Throws.Nothing); // fetching second level properties should work too - Executing.This(() => s.Query() - .Fetch(p => p.SubItem).ThenFetch(p => p.Details).ToList() - ).Should().NotThrow(); + Assert.That(() => s.Query() + .Fetch(p => p.SubItem).ThenFetch(p => p.Details).ToList(), Throws.Nothing); } } } @@ -82,7 +78,7 @@ public void LinqQueryWithFetch_WhenDerivedClassesUseComponentAndEagerFetchManyTo { using (var log = new SqlLogSpy()) { - Executing.This(() => s.Query().Fetch(p => p.SubItem.Details).ToList()).Should().NotThrow(); + Assert.That(() => s.Query().Fetch(p => p.SubItem.Details).ToList(), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2746/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2746/Fixture.cs index cb4ac96cf41..367acc96595 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2746/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2746/Fixture.cs @@ -25,7 +25,7 @@ public void TestQuery() session.EnableFilter("nameFilter").SetParameter("name", "Another child"); - crit.Executing(c=> c.List()).NotThrows(); + Assert.That(() => crit.List(), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2761/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2761/Fixture.cs index ea6c6e20404..69c15b1715f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2761/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2761/Fixture.cs @@ -17,7 +17,7 @@ public void WhenMultipleConfigurationUseSameMappingsThenConstraintsHasSameNames( var fkNamesForMappings1 = mappings1.IterateTables.SelectMany(t => t.ForeignKeyIterator).Select(fk => fk.Name).ToArray(); var fkNamesForMappings2 = mappings2.IterateTables.SelectMany(t => t.ForeignKeyIterator).Select(fk => fk.Name).ToArray(); - fkNamesForMappings1.Should().Have.SameValuesAs(fkNamesForMappings2); + Assert.That(fkNamesForMappings1, Is.EquivalentTo(fkNamesForMappings2)); } private Mappings GetMappings() diff --git a/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs index 1798cff5c76..76fc707e44e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs @@ -20,8 +20,8 @@ public void WhenPersistShouldNotFetchUninitializedCollection() using (ITransaction tx = session.BeginTransaction()) { var company = session.Get(companyId); - company.Addresses.Count().Should().Be.EqualTo(1); - company.RemoveAddress(company.Addresses.First()).Should().Be.EqualTo(true); + Assert.That(company.Addresses.Count(), Is.EqualTo(1)); + Assert.That(company.RemoveAddress(company.Addresses.First()), Is.EqualTo(true)); //now this company will be saved and deleting the address. //BUT it should not try to load the BanckAccound collection! @@ -30,7 +30,7 @@ public void WhenPersistShouldNotFetchUninitializedCollection() } } var wholeMessage = sl.GetWholeLog(); - wholeMessage.Should().Not.Contain("BankAccount"); + Assert.That(wholeMessage, Is.Not.StringContaining("BankAccount")); } Cleanup(companyId); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2852/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2852/Fixture.cs index 814ffc4c012..9ab184192f2 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2852/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2852/Fixture.cs @@ -57,8 +57,8 @@ public void ThenFetchCanExecute() session.Close(); - Assert.True(NHibernateUtil.IsInitialized(results[0].Address)); - Assert.True(NHibernateUtil.IsInitialized(results[0].Address.City)); + Assert.That(NHibernateUtil.IsInitialized(results[0].Address), Is.True); + Assert.That(NHibernateUtil.IsInitialized(results[0].Address.City), Is.True); } } @@ -76,8 +76,8 @@ public void AlsoFails() session.Close(); - Assert.True(NHibernateUtil.IsInitialized(results[0].Parent)); - Assert.True(NHibernateUtil.IsInitialized(results[0].Parent.Parent)); + Assert.That(NHibernateUtil.IsInitialized(results[0].Parent), Is.True); + Assert.That(NHibernateUtil.IsInitialized(results[0].Parent.Parent), Is.True); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2875/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2875/Fixture.cs index 01f5ffbd065..474e410eaae 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2875/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2875/Fixture.cs @@ -45,7 +45,7 @@ public void SpecifiedForeignKeyNameInByCodeMappingIsUsedInGeneratedSchema() cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaExport(cfg).Execute(s => script.AppendLine(s), false, false); - script.ToString().Should().Contain(string.Format("constraint {0}", ForeignKeyName)); + Assert.That(script.ToString(), Is.StringContaining(string.Format("constraint {0}", ForeignKeyName))); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs index d4e56788325..8f448b5c75e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs @@ -49,7 +49,7 @@ public void UnfetchedLazyPropertyEquality() var first = new UnfetchedLazyProperty(); var second = new UnfetchedLazyProperty(); - Assert.True(Equals(first, second)); + Assert.That(Equals(first, second), Is.True); } [Test] @@ -58,7 +58,7 @@ public void UnfetchedLazyPropertyIsNotEqualToUnknownBackrefProperty() var first = new UnfetchedLazyProperty(); var second = new UnknownBackrefProperty(); - Assert.False(Equals(first, second)); + Assert.That(Equals(first, second), Is.False); } [Test] diff --git a/src/NHibernate.Test/NHSpecificTest/NH2907/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2907/Fixture.cs index be5115211ac..16ebf840186 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2907/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2907/Fixture.cs @@ -45,13 +45,13 @@ public void ShouldNotEagerLoadKeyManyToOneWhenOverridingGetHashCode() var compId = (IDictionary)loan["CompId"]; var group = compId["Group"]; - group.Should().Not.Be.Null(); + Assert.That(@group, Is.Not.Null); isInitialized = NHibernateUtil.IsInitialized(group); tx.Commit(); } - isInitialized.Should().Be.False(); + Assert.That(isInitialized, Is.False); } protected override void OnTearDown() diff --git a/src/NHibernate.Test/NHSpecificTest/NH3149/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3149/Fixture.cs index efde3d288ad..65d9b862510 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3149/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3149/Fixture.cs @@ -85,7 +85,7 @@ public void ShouldNotWaitForLock() thread.Join(); - watch.ElapsedMilliseconds.Should().Be.LessThan(3000); + Assert.That(watch.ElapsedMilliseconds, Is.LessThan(3000)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3153/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3153/Fixture.cs index 7a66d3b2a20..ec6aed09198 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3153/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3153/Fixture.cs @@ -21,7 +21,7 @@ public void ShouldGetIdentifierSchemaFromClassElement() var mappings = conf.CreateMappings(Dialect.Dialect.GetDialect()); var pc = mappings.GetClass(typeof(A).FullName); - ((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"].Should().Be("Test"); + Assert.That(((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"], Is.EqualTo("Test")); } @@ -34,7 +34,7 @@ public void ShouldGetIdentifierSchemaFromMappingElement() var mappings = conf.CreateMappings(Dialect.Dialect.GetDialect()); var pc = mappings.GetClass(typeof(A).FullName); - ((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"].Should().Be("Test"); + Assert.That(((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"], Is.EqualTo("Test")); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3590/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3590/Fixture.cs index bdd9306d54f..85fc6a4571f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3590/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3590/Fixture.cs @@ -39,8 +39,7 @@ public void ShouldUpdate() { using (s.BeginTransaction()) { - s.Get(_entity.Id).Dates.Count - .Should().Be.EqualTo(1); + Assert.That(s.Get(_entity.Id).Dates.Count, Is.EqualTo(1)); } } } @@ -62,8 +61,7 @@ public void ShouldMerge() { using (s.BeginTransaction()) { - s.Get(_entity.Id).Dates.Count - .Should().Be.EqualTo(1); + Assert.That(s.Get(_entity.Id).Dates.Count, Is.EqualTo(1)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs b/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs index bfb7aac6358..d8b78400492 100644 --- a/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs +++ b/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs @@ -35,70 +35,70 @@ protected internal void AProtectedInternal() { } public void GetTypeNotBeProxiable() { var method = typeof(object).GetMethod("GetType"); - method.ShouldBeProxiable().Should().Be.False(); + Assert.That(method.ShouldBeProxiable(), Is.False); } [Test] public void DisposeNotBeProxiable() { var method = typeof(MyClass).GetMethod("Dispose"); - method.ShouldBeProxiable().Should().Be.False(); + Assert.That(method.ShouldBeProxiable(), Is.False); } [Test] public void WhenProtectedNoVirtualPropertyThenShouldntBeProxiable() { var prop = typeof(ProtectedNoVirtualProperty).GetProperty("Aprop", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - prop.ShouldBeProxiable().Should().Be.False(); + Assert.That(prop.ShouldBeProxiable(), Is.False); } [Test] public void WhenProtectedInternalNoVirtualPropertyThenShouldBeProxiable() { var prop = typeof(ProtectedNoVirtualProperty).GetProperty("AProtectedInternalProp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - prop.ShouldBeProxiable().Should().Be.True(); + Assert.That(prop.ShouldBeProxiable(), Is.True); } [Test] public void WhenInternalNoVirtualPropertyThenShouldBeProxiable() { var prop = typeof(ProtectedNoVirtualProperty).GetProperty("AInternalProp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - prop.ShouldBeProxiable().Should().Be.True(); + Assert.That(prop.ShouldBeProxiable(), Is.True); } [Test] public void WhenProtectedNoVirtualMethodThenShouldntBeProxiable() { var method = typeof(NoVirtualMethods).GetMethod("AProtected", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - method.ShouldBeProxiable().Should().Be.False(); + Assert.That(method.ShouldBeProxiable(), Is.False); } [Test] public void WhenProtectedInternalNoVirtualMethodThenShouldBeProxiable() { var method = typeof(NoVirtualMethods).GetMethod("AProtectedInternal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - method.ShouldBeProxiable().Should().Be.True(); + Assert.That(method.ShouldBeProxiable(), Is.True); } [Test] public void WhenPrivateMethodThenShouldntBeProxiable() { var method = typeof(NoVirtualMethods).GetMethod("APrivate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - method.ShouldBeProxiable().Should().Be.False(); + Assert.That(method.ShouldBeProxiable(), Is.False); } [Test] public void WhenPublicMethodThenShouldBeProxiable() { var method = typeof(NoVirtualMethods).GetMethod("APublic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - method.ShouldBeProxiable().Should().Be.True(); + Assert.That(method.ShouldBeProxiable(), Is.True); } [Test] public void WhenInternalMethodThenShouldBeProxiable() { var method = typeof(NoVirtualMethods).GetMethod("AInternal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - method.ShouldBeProxiable().Should().Be.True(); + Assert.That(method.ShouldBeProxiable(), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHibernate.Test.build b/src/NHibernate.Test/NHibernate.Test.build index f454831f6c7..f879d97b620 100644 --- a/src/NHibernate.Test/NHibernate.Test.build +++ b/src/NHibernate.Test/NHibernate.Test.build @@ -27,7 +27,6 @@ - diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index 3a0d936dbc1..0c57966358b 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -80,10 +80,6 @@ False ..\..\lib\net\nunit.framework.dll - - False - ..\..\lib\net\SharpTestsEx.NUnit.dll - diff --git a/src/NHibernate.Test/Parameters/NamedParameterSpecificationTest.cs b/src/NHibernate.Test/Parameters/NamedParameterSpecificationTest.cs index 6cbaecded14..7f28306a9a7 100644 --- a/src/NHibernate.Test/Parameters/NamedParameterSpecificationTest.cs +++ b/src/NHibernate.Test/Parameters/NamedParameterSpecificationTest.cs @@ -10,28 +10,28 @@ public class NamedParameterSpecificationTest public void WhenHasSameNameThenSameHashCode() { var expected = (new NamedParameterSpecification(1, 0, "nhlist")).GetHashCode(); - (new NamedParameterSpecification(1, 0, "nhlist")).GetHashCode().Should().Be.EqualTo(expected); + Assert.That((new NamedParameterSpecification(1, 0, "nhlist")).GetHashCode(), Is.EqualTo(expected)); } [Test] public void WhenHasNoSameNameThenNoSameHashCode() { var expected = (new NamedParameterSpecification(1, 0, "nHlist")).GetHashCode(); - (new NamedParameterSpecification(1, 0, "nhlist")).GetHashCode().Should().Not.Be.EqualTo(expected); + Assert.That((new NamedParameterSpecification(1, 0, "nhlist")).GetHashCode(), Is.Not.EqualTo(expected)); } [Test] public void WhenHasSameNameThenAreEquals() { var expected = (new NamedParameterSpecification(1, 0, "nhlist")); - (new NamedParameterSpecification(1, 0, "nhlist")).Should().Be.EqualTo(expected); + Assert.That((new NamedParameterSpecification(1, 0, "nhlist")), Is.EqualTo(expected)); } [Test] public void WhenHasNoSameNameThenAreNotEquals() { var expected = (new NamedParameterSpecification(1, 0, "nHlist")); - (new NamedParameterSpecification(1, 0, "nhlist")).Should().Not.Be.EqualTo(expected); + Assert.That((new NamedParameterSpecification(1, 0, "nhlist")), Is.Not.EqualTo(expected)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/PolymorphicGetAndLoad/PolymorphicGetAndLoadTest.cs b/src/NHibernate.Test/PolymorphicGetAndLoad/PolymorphicGetAndLoadTest.cs index a4b50673da3..e7a0f83a99e 100644 --- a/src/NHibernate.Test/PolymorphicGetAndLoad/PolymorphicGetAndLoadTest.cs +++ b/src/NHibernate.Test/PolymorphicGetAndLoad/PolymorphicGetAndLoadTest.cs @@ -85,23 +85,23 @@ public void Dispose() public void WhenSaveDeleteBaseClassCastedToInterfaceThenNotThrows() { INamed a = new A { Name = "Patrick" }; - Executing.This(() => - { - using (var s = OpenSession()) - { - s.Save(a); - s.Flush(); - } - }).Should().NotThrow(); + Assert.That(() => + { + using (var s = OpenSession()) + { + s.Save(a); + s.Flush(); + } + }, Throws.Nothing); - Executing.This(() => - { - using (var s = OpenSession()) - { - s.Delete(a); - s.Flush(); - } - }).Should().NotThrow(); + Assert.That(() => + { + using (var s = OpenSession()) + { + s.Delete(a); + s.Flush(); + } + }, Throws.Nothing); } @@ -112,7 +112,7 @@ public void WhenLoadBaseClassUsingInterfaceThenNotThrows() { using (var s = OpenSession()) { - s.Executing(session => session.Load(scenario.A.Id)).NotThrows(); + Assert.That(() => s.Load(scenario.A.Id), Throws.Nothing); } } } @@ -124,7 +124,7 @@ public void WhenGetBaseClassUsingInterfaceThenNotThrows() { using (var s = OpenSession()) { - s.Executing(session => session.Get(scenario.A.Id)).NotThrows(); + Assert.That(() => s.Get(scenario.A.Id), Throws.Nothing); } } } @@ -136,7 +136,7 @@ public void WhenLoadInheritedClassUsingInterfaceThenNotThrows() { using (var s = OpenSession()) { - Executing.This(()=> s.Load(scenario.B.Id) ).Should().NotThrow(); + Assert.That(() => s.Load(scenario.B.Id), Throws.Nothing); } } } @@ -149,16 +149,16 @@ public void WhenLoadInheritedClassUsingInterfaceThenShouldAllowNarrowingProxy() using (var s = OpenSession()) { INamed loadedEntity = null; - Executing.This(() => loadedEntity = s.Load(scenario.B.Id)).Should().NotThrow(); - NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity).Should().Be(typeof(A)); + Assert.That(() => loadedEntity = s.Load(scenario.B.Id), Throws.Nothing); + Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity), Is.EqualTo(typeof(A))); var narrowedProxy = s.Load(scenario.B.Id); - NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy).Should().Be(typeof(B)); + Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy), Is.EqualTo(typeof(B))); var firstLoadedImpl = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s); var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s); - firstLoadedImpl.Should().Be.SameInstanceAs(secondLoadedImpl); + Assert.That(firstLoadedImpl, Is.SameAs(secondLoadedImpl)); } } } @@ -171,16 +171,16 @@ public void WhenLoadInterfaceThenShouldAllowNarrowingProxy() using (var s = OpenSession()) { INamed loadedEntity = null; - Executing.This(() => loadedEntity = s.Load(scenario.B.Id)).Should().NotThrow(); - NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity).Should().Be(typeof(A)); + Assert.That(() => loadedEntity = s.Load(scenario.B.Id), Throws.Nothing); + Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(loadedEntity), Is.EqualTo(typeof(A))); var narrowedProxy = s.Load(scenario.B.Id); - NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy).Should().Be(typeof(B)); + Assert.That(NHibernateProxyHelper.GetClassWithoutInitializingProxy(narrowedProxy), Is.EqualTo(typeof(B))); var firstLoadedImpl = ((INHibernateProxy)loadedEntity).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s); var secondLoadedImpl = ((INHibernateProxy)narrowedProxy).HibernateLazyInitializer.GetImplementation((ISessionImplementor)s); - firstLoadedImpl.Should().Be.SameInstanceAs(secondLoadedImpl); + Assert.That(firstLoadedImpl, Is.SameAs(secondLoadedImpl)); } } } @@ -193,8 +193,8 @@ public void WhenGetInheritedClassUsingInterfaceThenNotThrows() using (var s = OpenSession()) { INamed loadedEntity = null; - Executing.This(() => loadedEntity = s.Get(scenario.B.Id)).Should().NotThrow(); - loadedEntity.Should().Be.OfType(); + Assert.That(() => loadedEntity = s.Get(scenario.B.Id), Throws.Nothing); + Assert.That(loadedEntity, Is.TypeOf()); } } } @@ -204,13 +204,11 @@ public void WhenLoadClassUsingInterfaceOfMultippleHierarchyThenThrows() { using (var s = OpenSession()) { - Executing.This(() => s.Load(1)) - .Should().Throw() - .And.ValueOf.Message.Should() - .Contain("Ambiguous") - .And.Contain("GraphA") - .And.Contain("GraphB") - .And.Contain("IMultiGraphNamed"); + Assert.That(() => s.Load(1), Throws.TypeOf() + .And.Message.ContainsSubstring("Ambiguous") + .And.Message.ContainsSubstring("GraphA") + .And.Message.ContainsSubstring("GraphB") + .And.Message.ContainsSubstring("IMultiGraphNamed")); } } @@ -219,13 +217,12 @@ public void WhenGetClassUsingInterfaceOfMultippleHierarchyThenThrows() { using (var s = OpenSession()) { - Executing.This(() => s.Get(1)) - .Should().Throw() - .And.ValueOf.Message.Should() - .Contain("Ambiguous") - .And.Contain("GraphA") - .And.Contain("GraphB") - .And.Contain("IMultiGraphNamed"); + Assert.That(() => s.Get(1), + Throws.TypeOf() + .And.Message.StringContaining("Ambiguous") + .And.Message.StringContaining("GraphA") + .And.Message.StringContaining("GraphB") + .And.Message.StringContaining("IMultiGraphNamed")); } } @@ -238,7 +235,7 @@ public void WhenGetBaseClassUsingInterfaceFromSessionCacheThenNotThrows() { var id = scenario.A.Id; s.Get(id); - s.Executing(session => session.Get(id)).NotThrows(); + Assert.That(() => s.Get(id), Throws.Nothing); } } } @@ -252,7 +249,7 @@ public void WhenGetInheritedClassUsingInterfaceFromSessionCacheThenNotThrows() { var id = scenario.B.Id; s.Get(id); - s.Executing(session => session.Get(id)).NotThrows(); + Assert.That(() => s.Get(id), Throws.Nothing); } } } diff --git a/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs b/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs index f6a60d11acb..f156778901d 100644 --- a/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs +++ b/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs @@ -361,10 +361,10 @@ public void ExecutableQuery() { IQuery q = dq.GetExecutableQuery(s); IList l = q.List(); - Assert.AreEqual(2, l.Count); + Assert.That(l.Count, Is.EqualTo(2)); - Assert.True(l.Contains(new Foo("N2", "D2"))); - Assert.True(l.Contains(new Foo("N3", "D3"))); + Assert.That(l.Contains(new Foo("N2", "D2")), Is.True); + Assert.That(l.Contains(new Foo("N3", "D3")), Is.True); } // Pagination diff --git a/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs b/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs index 4a07739142f..0d7d16bceb0 100644 --- a/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs +++ b/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs @@ -439,7 +439,7 @@ public void ParameterPropertyShouldReturnNewInstances() Assert.IsNull(parameters2[0].ParameterPosition); // more simple version of the test - Parameter.Placeholder.Should().Not.Be.SameInstanceAs(Parameter.Placeholder); + Assert.That(Parameter.Placeholder, Is.Not.SameAs(Parameter.Placeholder)); } diff --git a/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs b/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs index 86b84e7e9eb..6ce8d082bbe 100644 --- a/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs +++ b/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs @@ -5,71 +5,71 @@ namespace NHibernate.Test.Stateless.Fetching { - [TestFixture] - public class StatelessSessionFetchingTest : TestCase - { - private static readonly ILog log = LogManager.GetLogger(typeof(StatelessSessionFetchingTest)); + [TestFixture] + public class StatelessSessionFetchingTest : TestCase + { + private static readonly ILog log = LogManager.GetLogger(typeof(StatelessSessionFetchingTest)); - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } - protected override IList Mappings - { - get - { - return new[] { "Stateless.Fetching.Mappings.hbm.xml" }; - } - } + protected override IList Mappings + { + get + { + return new[] { "Stateless.Fetching.Mappings.hbm.xml" }; + } + } - [Test] - public void DynamicFetch() - { - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - DateTime now = DateTime.Now; - User me = new User("me"); - User you = new User("you"); - Resource yourClock = new Resource("clock", you); - Task task = new Task(me, "clean", yourClock, now); // :) - s.Save(me); - s.Save(you); - s.Save(yourClock); - s.Save(task); - tx.Commit(); - } + [Test] + public void DynamicFetch() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + DateTime now = DateTime.Now; + User me = new User("me"); + User you = new User("you"); + Resource yourClock = new Resource("clock", you); + Task task = new Task(me, "clean", yourClock, now); // :) + s.Save(me); + s.Save(you); + s.Save(yourClock); + s.Save(task); + tx.Commit(); + } - using (IStatelessSession ss = sessions.OpenStatelessSession()) - using (ITransaction tx = ss.BeginTransaction()) - { - ss.BeginTransaction(); - Task taskRef = - (Task)ss.CreateQuery("from Task t join fetch t.Resource join fetch t.User").UniqueResult(); - Assert.True(taskRef != null); - Assert.True(NHibernateUtil.IsInitialized(taskRef)); - Assert.True(NHibernateUtil.IsInitialized(taskRef.User)); - Assert.True(NHibernateUtil.IsInitialized(taskRef.Resource)); - Assert.False(NHibernateUtil.IsInitialized(taskRef.Resource.Owner)); - tx.Commit(); - } + using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (ITransaction tx = ss.BeginTransaction()) + { + ss.BeginTransaction(); + Task taskRef = + (Task)ss.CreateQuery("from Task t join fetch t.Resource join fetch t.User").UniqueResult(); + Assert.That(taskRef, Is.Not.Null); + Assert.That(NHibernateUtil.IsInitialized(taskRef), Is.True); + Assert.That(NHibernateUtil.IsInitialized(taskRef.User), Is.True); + Assert.That(NHibernateUtil.IsInitialized(taskRef.Resource), Is.True); + Assert.That(NHibernateUtil.IsInitialized(taskRef.Resource.Owner), Is.False); + tx.Commit(); + } - cleanup(); - } + cleanup(); + } - private void cleanup() - { - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - s.BeginTransaction(); - s.CreateQuery("delete Task").ExecuteUpdate(); - s.CreateQuery("delete Resource").ExecuteUpdate(); - s.CreateQuery("delete User").ExecuteUpdate(); - tx.Commit(); - } - } - } + private void cleanup() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.BeginTransaction(); + s.CreateQuery("delete Task").ExecuteUpdate(); + s.CreateQuery("delete Resource").ExecuteUpdate(); + s.CreateQuery("delete User").ExecuteUpdate(); + tx.Commit(); + } + } + } } diff --git a/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs b/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs index ce890c0529b..bc4161a0a1a 100644 --- a/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs +++ b/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs @@ -17,18 +17,18 @@ protected override HbmMapping GetMappings() var mapper = new ModelMapper(); mapper.BeforeMapClass += (mi, t, cm) => cm.Id(im => im.Generator(Generators.HighLow)); mapper.Class(mc => - { - mc.Id(x => x.Id); - mc.Discriminator(dm => dm.Column("kind")); - mc.Property(x => x.Description); - }); + { + mc.Id(x => x.Id); + mc.Discriminator(dm => dm.Column("kind")); + mc.Property(x => x.Description); + }); mapper.Subclass(mc => { mc.Property(x => x.BodyTemperature); }); mapper.Subclass(mc => - { - mc.Property(x => x.Name); - mc.Property(x => x.NickName); - mc.Property(x => x.Birthdate, pm => pm.Type(NHibernateUtil.Date)); - }); + { + mc.Property(x => x.Name); + mc.Property(x => x.NickName); + mc.Property(x => x.Birthdate, pm => pm.Type(NHibernateUtil.Date)); + }); mapper.AddMapping>(); mapper.AddMapping>(); var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities(); @@ -50,23 +50,23 @@ public FamilyMap() DiscriminatorValue(familyOf); Where(string.Format("familyKind = '{0}'", familyOf)); ManyToOne(x => x.Father, map => - { - map.Lazy(LazyRelation.NoLazy); - map.Class(typeof (T)); - map.Cascade(Mapping.ByCode.Cascade.All); - }); + { + map.Lazy(LazyRelation.NoLazy); + map.Class(typeof (T)); + map.Cascade(Mapping.ByCode.Cascade.All); + }); ManyToOne(x => x.Mother, map => - { - map.Lazy(LazyRelation.NoLazy); - map.Class(typeof (T)); - map.Cascade(Mapping.ByCode.Cascade.All); - }); + { + map.Lazy(LazyRelation.NoLazy); + map.Class(typeof (T)); + map.Cascade(Mapping.ByCode.Cascade.All); + }); Set(x => x.Childs, cam => - { - cam.Key(km => km.Column("familyId")); - cam.Cascade(Mapping.ByCode.Cascade.All); - }, - rel => rel.OneToMany()); + { + cam.Key(km => km.Column("familyId")); + cam.Cascade(Mapping.ByCode.Cascade.All); + }, + rel => rel.OneToMany()); } } @@ -120,13 +120,13 @@ public void ShouldWorkLoadingComplexEntities() Assert.That(hf.Count, Is.EqualTo(1)); Assert.That(hf[0].Father.Name, Is.EqualTo(humanFather)); Assert.That(hf[0].Mother.Name, Is.EqualTo(humanMother)); - NHibernateUtil.IsInitialized(hf[0].Childs).Should("Lazy collection should NOT be initialized").Be.False(); + Assert.That(NHibernateUtil.IsInitialized(hf[0].Childs), Is.False, "Lazy collection should NOT be initialized"); IList> rf = s.CreateQuery("from ReptileFamily").List>(); Assert.That(rf.Count, Is.EqualTo(1)); Assert.That(rf[0].Father.Description, Is.EqualTo(crocodileFather)); Assert.That(rf[0].Mother.Description, Is.EqualTo(crocodileMother)); - NHibernateUtil.IsInitialized(hf[0].Childs).Should("Lazy collection should NOT be initialized").Be.False(); + Assert.That(NHibernateUtil.IsInitialized(hf[0].Childs), Is.False, "Lazy collection should NOT be initialized"); tx.Commit(); } diff --git a/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs b/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs index b5faf13479c..c016d8462b3 100644 --- a/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs +++ b/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs @@ -183,14 +183,14 @@ public void Refresh() [Test] public void WhenSetTheBatchSizeThenSetTheBatchSizeOfTheBatcher() { - if (!Dialect.SupportsSqlBatches) - Assert.Ignore("Dialect does not support sql batches."); + if (!Dialect.SupportsSqlBatches) + Assert.Ignore("Dialect does not support sql batches."); using (IStatelessSession ss = sessions.OpenStatelessSession()) { ss.SetBatchSize(37); var impl = (ISessionImplementor)ss; - impl.Batcher.BatchSize.Should().Be(37); + Assert.That(impl.Batcher.BatchSize, Is.EqualTo(37)); } } @@ -199,7 +199,7 @@ public void CanGetImplementor() { using (IStatelessSession ss = sessions.OpenStatelessSession()) { - ss.GetSessionImplementation().Should().Be.SameInstanceAs(ss); + Assert.That(ss.GetSessionImplementation(), Is.SameAs(ss)); } } @@ -210,8 +210,8 @@ public void HavingDetachedCriteriaThenCanGetExecutableCriteriaFromStatelessSessi using (IStatelessSession ss = sessions.OpenStatelessSession()) { ICriteria criteria = null; - Executing.This(()=> criteria = dc.GetExecutableCriteria(ss)).Should().NotThrow(); - criteria.Executing(c => c.List()).NotThrows(); + Assert.That(() => criteria = dc.GetExecutableCriteria(ss), Throws.Nothing); + Assert.That(() => criteria.List(), Throws.Nothing); } } diff --git a/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs b/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs index e89fe57cff9..ded36d587e6 100644 --- a/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs +++ b/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs @@ -66,14 +66,14 @@ public void ShouldWorkLoadingComplexEntities() Assert.That(hf.Count, Is.EqualTo(1)); Assert.That(hf[0].Father.Name, Is.EqualTo(humanFather)); Assert.That(hf[0].Mother.Name, Is.EqualTo(humanMother)); - NHibernateUtil.IsInitialized(hf[0].Childs).Should("No lazy collection should be initialized").Be.True(); + Assert.That(NHibernateUtil.IsInitialized(hf[0].Childs), Is.True, "No lazy collection should be initialized"); //Assert.That(hf[0].Childs, Is.Null, "Collections should be ignored by stateless session."); IList> rf = s.CreateQuery("from ReptilesFamily").List>(); Assert.That(rf.Count, Is.EqualTo(1)); Assert.That(rf[0].Father.Description, Is.EqualTo(crocodileFather)); Assert.That(rf[0].Mother.Description, Is.EqualTo(crocodileMother)); - NHibernateUtil.IsInitialized(hf[0].Childs).Should("No lazy collection should be initialized").Be.True(); + Assert.That(NHibernateUtil.IsInitialized(hf[0].Childs), Is.True, "No lazy collection should be initialized"); //Assert.That(rf[0].Childs, Is.Null, "Collections should be ignored by stateless session."); tx.Commit(); diff --git a/src/NHibernate.Test/Subselect/ClassSubselectFixture.cs b/src/NHibernate.Test/Subselect/ClassSubselectFixture.cs index 8233d04dca0..b5a9edd8c97 100644 --- a/src/NHibernate.Test/Subselect/ClassSubselectFixture.cs +++ b/src/NHibernate.Test/Subselect/ClassSubselectFixture.cs @@ -33,28 +33,28 @@ public void EntitySubselect() s.Save(x23y4); s.Flush(); var beings = s.CreateQuery("from Being").List(); - beings.Should().Have.Count.GreaterThan(0); + Assert.That(beings, Has.Count.GreaterThan(0)); foreach (var being in beings) { - being.Location.Should().Not.Be.NullOrEmpty(); - being.Identity.Should().Not.Be.NullOrEmpty(); - being.Species.Should().Not.Be.NullOrEmpty(); + Assert.That(being.Location, Is.Not.Null.And.Not.Empty); + Assert.That(being.Identity, Is.Not.Null.And.Not.Empty); + Assert.That(being.Species, Is.Not.Null.And.Not.Empty); } s.Clear(); Sfi.Evict(typeof (Being)); Being gav = s.Get(gavin.Id); - gav.Location.Should().Not.Be.NullOrEmpty(); - gav.Identity.Should().Not.Be.NullOrEmpty(); - gav.Species.Should().Not.Be.NullOrEmpty(); + Assert.That(gav.Location, Is.Not.Null.And.Not.Empty); + Assert.That(gav.Identity, Is.Not.Null.And.Not.Empty); + Assert.That(gav.Species, Is.Not.Null.And.Not.Empty); s.Clear(); //test the tag: gavin = s.Get(gavin.Id); gavin.Address = "Atlanta, GA"; gav = s.CreateQuery("from Being b where b.Location like '%GA%'").UniqueResult(); - gav.Location.Should().Be(gavin.Address); + Assert.That(gav.Location, Is.EqualTo(gavin.Address)); s.Delete(gavin); s.Delete(x23y4); - s.CreateQuery("from Being").List().Should().Be.Empty(); + Assert.That(s.CreateQuery("from Being").List(), Is.Empty); t.Commit(); s.Close(); } diff --git a/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs b/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs index a5acd3e5fc1..92ee51a12bc 100644 --- a/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs +++ b/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs @@ -29,7 +29,7 @@ public void WhenCalledExplicitlyThenTakeInAccountHbm2DdlKeyWordsSetting() var script = new StringBuilder(); new SchemaExport(configuration).Execute(s=> script.AppendLine(s), false, false); - script.ToString().Should().Contain("[Order]").And.Contain("[Select]").And.Contain("[From]").And.Contain("[And]"); + Assert.That(script.ToString(), Is.StringContaining("[Order]").And.Contains("[Select]").And.Contains("[From]").And.Contains("[And]")); } [Test] @@ -52,11 +52,11 @@ public void WhenUpdateCalledExplicitlyThenTakeInAccountHbm2DdlKeyWordsSetting() // With SchemaUpdate the auto-quote method should be called and the conf. should hold quoted stuff var cm = configuration.GetClassMapping(typeof(Order)); var culs = cm.Table.ColumnIterator.ToList(); - cm.Table.Satisfy(t=> t.IsQuoted); - culs.First(c => "From".Equals(c.Name)).Satisfy(c=> c.IsQuoted); - culs.First(c => "And".Equals(c.Name)).Satisfy(c => c.IsQuoted); - culs.First(c => "Select".Equals(c.Name)).Satisfy(c => c.IsQuoted); - culs.First(c => "Column".Equals(c.Name)).Satisfy(c => c.IsQuoted); + Assert.That(cm.Table.IsQuoted, Is.True); + Assert.That(culs.First(c => "From" == c.Name).IsQuoted, Is.True); + Assert.That(culs.First(c => "And" == c.Name).IsQuoted, Is.True); + Assert.That(culs.First(c => "Select" == c.Name).IsQuoted, Is.True); + Assert.That(culs.First(c => "Column" == c.Name).IsQuoted, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TransformTests/ImplementationOfEqualityTests.cs b/src/NHibernate.Test/TransformTests/ImplementationOfEqualityTests.cs index dda97b1b65c..9bd57940f41 100644 --- a/src/NHibernate.Test/TransformTests/ImplementationOfEqualityTests.cs +++ b/src/NHibernate.Test/TransformTests/ImplementationOfEqualityTests.cs @@ -13,8 +13,8 @@ public class ImplementationOfEqualityTests { private readonly IEnumerable transformerTypes = typeof (IResultTransformer).Assembly.GetTypes() - .Where(t => typeof (IResultTransformer).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) - .ToList(); + .Where(t => typeof (IResultTransformer).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) + .ToList(); [Test] public void AllEmbeddedTransformersOverridesEqualsAndGetHashCode() @@ -22,8 +22,8 @@ public void AllEmbeddedTransformersOverridesEqualsAndGetHashCode() foreach (var transformerType in transformerTypes) { var declaredMethods = transformerType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); - declaredMethods.Select(x => x.Name).Should("The type "+transformerType+" does not implement Equals").Contain("Equals"); - declaredMethods.Select(x => x.Name).Should("The type " + transformerType + " does not implement GetHashCode").Contain("GetHashCode"); + Assert.That(declaredMethods.Select(x => x.Name), Contains.Item("Equals"), "The type " + transformerType + " does not implement Equals"); + Assert.That(declaredMethods.Select(x => x.Name), Contains.Item("GetHashCode"), "The type " + transformerType + " does not implement GetHashCode"); } } @@ -45,8 +45,8 @@ public void AllEmbeddedTransformersWithDefaultCtorHasEqualityWorkingAsSingleton( continue; } var transformer2= (IResultTransformer)Activator.CreateInstance(transformerType); - transformer1.Should().Be.EqualTo(transformer2); - transformer1.GetHashCode().Should().Be.EqualTo(transformer2.GetHashCode()); + Assert.That(transformer1, Is.EqualTo(transformer2)); + Assert.That(transformer1.GetHashCode(), Is.EqualTo(transformer2.GetHashCode())); } } @@ -55,12 +55,12 @@ public void AliasToBeanResultTransformer_ShouldHaveEqualityBasedOnCtorParameter( { var transformer1 = new AliasToBeanResultTransformer(typeof(object)); var transformer2 = new AliasToBeanResultTransformer(typeof(object)); - transformer1.Should().Be.EqualTo(transformer2); - transformer1.GetHashCode().Should().Be.EqualTo(transformer2.GetHashCode()); + Assert.That(transformer1, Is.EqualTo(transformer2)); + Assert.That(transformer1.GetHashCode(), Is.EqualTo(transformer2.GetHashCode())); var transformer3 = new AliasToBeanResultTransformer(typeof(int)); - transformer1.Should().Not.Be.EqualTo(transformer3); - transformer1.GetHashCode().Should().Not.Be.EqualTo(transformer3.GetHashCode()); + Assert.That(transformer1, Is.Not.EqualTo(transformer3)); + Assert.That(transformer1.GetHashCode(), Is.Not.EqualTo(transformer3.GetHashCode())); } [Test] @@ -69,12 +69,12 @@ public void AliasToBeanConstructorResultTransformer_ShouldHaveEqualityBasedOnCto var emptyCtor = new System.Type[0]; var transformer1 = new AliasToBeanConstructorResultTransformer(typeof(object).GetConstructor(emptyCtor)); var transformer2 = new AliasToBeanConstructorResultTransformer(typeof(object).GetConstructor(emptyCtor)); - transformer1.Should().Be.EqualTo(transformer2); - transformer1.GetHashCode().Should().Be.EqualTo(transformer2.GetHashCode()); + Assert.That(transformer1, Is.EqualTo(transformer2)); + Assert.That(transformer1.GetHashCode(), Is.EqualTo(transformer2.GetHashCode())); var transformer3 = new AliasToBeanConstructorResultTransformer(typeof(ImplementationOfEqualityTests).GetConstructor(emptyCtor)); - transformer1.Should().Not.Be.EqualTo(transformer3); - transformer1.GetHashCode().Should().Not.Be.EqualTo(transformer3.GetHashCode()); + Assert.That(transformer1, Is.Not.EqualTo(transformer3)); + Assert.That(transformer1.GetHashCode(), Is.Not.EqualTo(transformer3.GetHashCode())); } [Test] @@ -84,13 +84,13 @@ public void LinqResultTransformer_ShouldHaveEqualityBasedOnCtorParameter() Func, IEnumerable> d2 = x => x; var transformer1 = new ResultTransformer(d1, d2); var transformer2 = new ResultTransformer(d1, d2); - transformer1.Should().Be.EqualTo(transformer2); - transformer1.GetHashCode().Should().Be.EqualTo(transformer2.GetHashCode()); + Assert.That(transformer1, Is.EqualTo(transformer2)); + Assert.That(transformer1.GetHashCode(), Is.EqualTo(transformer2.GetHashCode())); Func, IEnumerable> d3 = x => new [] { 1, 2, 3 }; var transformer3 = new ResultTransformer(d1, d3); - transformer1.Should().Not.Be.EqualTo(transformer3); - transformer1.GetHashCode().Should().Not.Be.EqualTo(transformer3.GetHashCode()); + Assert.That(transformer1, Is.Not.EqualTo(transformer3)); + Assert.That(transformer1.GetHashCode(), Is.Not.EqualTo(transformer3.GetHashCode())); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/BinaryBlobTypeFixture.cs b/src/NHibernate.Test/TypesTest/BinaryBlobTypeFixture.cs index 67f3a03c0e4..7e46aaa9a58 100644 --- a/src/NHibernate.Test/TypesTest/BinaryBlobTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/BinaryBlobTypeFixture.cs @@ -67,7 +67,7 @@ public void ReadWriteZeroLen() using (var s = OpenSession()) { var b = s.Get(savedId); - b.BinaryBlob.Should().Not.Be.Null().And.Have.Count.EqualTo(0); + Assert.That(b.BinaryBlob, Is.Not.Null.And.Length.EqualTo(0)); s.Delete(b); s.Flush(); } diff --git a/src/NHibernate.Test/TypesTest/CharClassFixture.cs b/src/NHibernate.Test/TypesTest/CharClassFixture.cs index 9be41bf463c..a44d798b15d 100644 --- a/src/NHibernate.Test/TypesTest/CharClassFixture.cs +++ b/src/NHibernate.Test/TypesTest/CharClassFixture.cs @@ -24,9 +24,9 @@ public void ReadWrite() using (var s = OpenSession()) { CharClass saved= null; - Executing.This(()=> saved = s.Get(1)).Should().NotThrow(); - saved.NormalChar.Should().Be('A'); - saved.NullableChar.Should().Not.Have.Value(); + Assert.That(() => saved = s.Get(1), Throws.Nothing); + Assert.That(saved.NormalChar, Is.EqualTo('A')); + Assert.That(saved.NullableChar, Is.Null); s.Delete(saved); s.Flush(); diff --git a/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs b/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs index f16eaaef72f..b847a2272e5 100644 --- a/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs @@ -5,52 +5,52 @@ namespace NHibernate.Test.TypesTest { - /// - /// TestFixtures for the . - /// - [TestFixture] - public class DateTime2TypeFixture - { - [Test] - public void Next() - { - DateTimeType type = (DateTimeType)NHibernateUtil.DateTime2; - object current = DateTime.Now.AddMilliseconds(-1); - object next = type.Next(current, null); - - next.Should().Be.OfType().And.Value.Should().Be.GreaterThan((DateTime)current); - } - - [Test] - public void Seed() - { - DateTimeType type = (DateTimeType)NHibernateUtil.DateTime; - Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime"); - } - - [Test] - public void DeepCopyNotNull() - { - NullableType type = NHibernateUtil.DateTime; - - object value1 = DateTime.Now; - object value2 = type.DeepCopy(value1, EntityMode.Poco, null); - - Assert.AreEqual(value1, value2, "Copies should be the same."); - - - value2 = ((DateTime)value2).AddHours(2); - Assert.IsFalse(value1 == value2, "value2 was changed, value1 should not have changed also."); - } - - [Test] - public void EqualityShouldIgnoreKindAndNotIgnoreMillisecond() - { - var type = (DateTimeType)NHibernateUtil.DateTime; - var localTime = DateTime.Now; - var unspecifiedKid = new DateTime(localTime.Ticks, DateTimeKind.Unspecified); - type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid)); - type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid, EntityMode.Poco)); - } - } + /// + /// TestFixtures for the . + /// + [TestFixture] + public class DateTime2TypeFixture + { + [Test] + public void Next() + { + DateTimeType type = NHibernateUtil.DateTime2; + object current = DateTime.Now.AddMilliseconds(-1); + object next = type.Next(current, null); + + Assert.That(next, Is.TypeOf().And.GreaterThan(current)); + } + + [Test] + public void Seed() + { + DateTimeType type = NHibernateUtil.DateTime; + Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime"); + } + + [Test] + public void DeepCopyNotNull() + { + NullableType type = NHibernateUtil.DateTime; + + object value1 = DateTime.Now; + object value2 = type.DeepCopy(value1, EntityMode.Poco, null); + + Assert.AreEqual(value1, value2, "Copies should be the same."); + + + value2 = ((DateTime)value2).AddHours(2); + Assert.IsFalse(value1 == value2, "value2 was changed, value1 should not have changed also."); + } + + [Test] + public void EqualityShouldIgnoreKindAndNotIgnoreMillisecond() + { + var type = NHibernateUtil.DateTime; + var localTime = DateTime.Now; + var unspecifiedKid = new DateTime(localTime.Ticks, DateTimeKind.Unspecified); + Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); + Assert.That(type.IsEqual(localTime, unspecifiedKid, EntityMode.Poco), Is.True); + } + } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs b/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs index 404eac90d5e..bf72c0aee3f 100644 --- a/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs @@ -20,7 +20,7 @@ public void Next() Assert.IsTrue(next is DateTime, "Next should be DateTime"); Assert.IsTrue((DateTime) next > (DateTime) current, - "next should be greater than current (could be equal depending on how quickly this occurs)"); + "next should be greater than current (could be equal depending on how quickly this occurs)"); } [Test] @@ -51,8 +51,8 @@ public void EqualityShouldIgnoreKindAndMillisecond() var type = (DateTimeType)NHibernateUtil.DateTime; var localTime = DateTime.Now; var unspecifiedKid = new DateTime(localTime.Year, localTime.Month, localTime.Day, localTime.Hour, localTime.Minute, localTime.Second, 0, DateTimeKind.Unspecified); - type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid)); - type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid, EntityMode.Poco)); + Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); + Assert.That(type.IsEqual(localTime, unspecifiedKid, EntityMode.Poco), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/DateTypeTest.cs b/src/NHibernate.Test/TypesTest/DateTypeTest.cs index c13c8920624..ab3c5b7bd00 100644 --- a/src/NHibernate.Test/TypesTest/DateTypeTest.cs +++ b/src/NHibernate.Test/TypesTest/DateTypeTest.cs @@ -13,7 +13,7 @@ public class DateTypeTest public void WhenNoParameterThenDefaultValueIsBaseDateValue() { var dateType = new DateType(); - dateType.DefaultValue.Should().Be(DateType.BaseDateValue); + Assert.That(dateType.DefaultValue, Is.EqualTo(DateType.BaseDateValue)); } [Test] @@ -21,14 +21,14 @@ public void WhenSetParameterThenDefaultValueIsParameterValue() { var dateType = new DateType(); dateType.SetParameterValues(new Dictionary{{DateType.BaseValueParameterName, "0001/01/01"}}); - dateType.DefaultValue.Should().Be(DateTime.MinValue); + Assert.That(dateType.DefaultValue, Is.EqualTo(DateTime.MinValue)); } [Test] public void WhenSetParameterNullThenNotThrow() { var dateType = new DateType(); - dateType.Executing(dt=> dt.SetParameterValues(null)).NotThrows(); + Assert.That(() => dateType.SetParameterValues(null), Throws.Nothing); } } @@ -47,7 +47,7 @@ public void ShouldBeDateType() Assert.Ignore("This test does not apply to " + Dialect); } var sqlType = Dialect.GetTypeName(NHibernateUtil.Date.SqlType); - sqlType.ToLowerInvariant().Should().Be("date"); + Assert.That(sqlType.ToLowerInvariant(), Is.EqualTo("date")); } [Test] @@ -65,7 +65,7 @@ public void ReadWriteNormal() using (ISession s = OpenSession()) { basic = s.Get(savedId); - basic.DateValue.Should().Be(expected); + Assert.That(basic.DateValue, Is.EqualTo(expected)); s.Delete(basic); s.Flush(); } @@ -84,7 +84,7 @@ public void ReadWriteBaseValue() using (ISession s = OpenSession()) { basic = s.Get(savedId); - basic.DateValue.HasValue.Should().Be.False(); + Assert.That(basic.DateValue.HasValue, Is.False); s.Delete(basic); s.Flush(); } diff --git a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs index 350f7d88e3f..2def33f5a72 100644 --- a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs @@ -129,8 +129,8 @@ public void CanWriteAndReadUsingBothHeuristicAndExplicitGenericDeclaration() using (ISession s = sessions.OpenSession()) { var saved = s.Get(1); - saved.A.Should().Be(A.Two); - saved.B.Should().Be(B.One); + Assert.That(saved.A, Is.EqualTo(A.Two)); + Assert.That(saved.B, Is.EqualTo(B.One)); s.Delete(saved); s.Flush(); } @@ -143,7 +143,7 @@ public class GenericEnumTypeTest public void TheNameShouldBeFullNameAndAssembly() { var enumType = new EnumType(); - enumType.Name.Should().Be(typeof(EnumType).FullName + ", NHibernate"); + Assert.That(enumType.Name, Is.EqualTo(typeof(EnumType).FullName + ", NHibernate")); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs index c5ba559c167..32941993640 100644 --- a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs +++ b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs @@ -83,28 +83,28 @@ public void MultiThreadAccess() // If one thread break the test you can see the result in the console. ((Logger) log.Logger).Level = log4net.Core.Level.Debug; MultiThreadRunner.ExecuteAction[] actions = new MultiThreadRunner.ExecuteAction[] - { - delegate(object o) - { - TypeFactory.GetStringType(rnd.Next(1, 50)); - totalCall++; - }, - delegate(object o) - { - TypeFactory.GetBinaryType(rnd.Next(1, 50)); - totalCall++; - }, - delegate(object o) - { - TypeFactory.GetSerializableType(rnd.Next(1, 50)); - totalCall++; - }, - delegate(object o) - { - TypeFactory.GetTypeType(rnd.Next(1, 20)); - totalCall++; - }, - }; + { + delegate(object o) + { + TypeFactory.GetStringType(rnd.Next(1, 50)); + totalCall++; + }, + delegate(object o) + { + TypeFactory.GetBinaryType(rnd.Next(1, 50)); + totalCall++; + }, + delegate(object o) + { + TypeFactory.GetSerializableType(rnd.Next(1, 50)); + totalCall++; + }, + delegate(object o) + { + TypeFactory.GetTypeType(rnd.Next(1, 20)); + totalCall++; + }, + }; MultiThreadRunner mtr = new MultiThreadRunner(100, actions); mtr.EndTimeout = 2000; mtr.TimeoutBetweenThreadStart = 2; @@ -149,14 +149,14 @@ public enum MyEnum public void WhenUseEnumThenReturnGenericEnumType() { var iType = TypeFactory.HeuristicType(typeof (MyEnum).AssemblyQualifiedName); - iType.Should().Be.OfType>(); + Assert.That(iType, Is.TypeOf>()); } [Test] public void WhenUseNullableEnumThenReturnGenericEnumType() { var iType = TypeFactory.HeuristicType(typeof(MyEnum?).AssemblyQualifiedName); - iType.Should().Be.OfType>(); + Assert.That(iType, Is.TypeOf>()); } } } diff --git a/src/NHibernate.Test/TypesTest/UriTypeFixture.cs b/src/NHibernate.Test/TypesTest/UriTypeFixture.cs index e613f6b709c..eb8794caf0b 100644 --- a/src/NHibernate.Test/TypesTest/UriTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/UriTypeFixture.cs @@ -26,8 +26,8 @@ public void ReadWrite() using (var s = OpenSession()) { var entity = s.Get(1); - entity.Url.Should().Not.Be.Null(); - entity.Url.OriginalString.Should().Be("http://www.fabiomaulo.blogspot.com/"); + Assert.That(entity.Url, Is.Not.Null); + Assert.That(entity.Url.OriginalString, Is.EqualTo("http://www.fabiomaulo.blogspot.com/")); entity.Url = new Uri("http://fabiomaulo.blogspot.com/2010/10/nhibernate-30-cookbook.html"); s.Save(entity); s.Flush(); @@ -35,7 +35,7 @@ public void ReadWrite() using (var s = OpenSession()) { var entity = s.Get(1); - entity.Url.OriginalString.Should().Be("http://fabiomaulo.blogspot.com/2010/10/nhibernate-30-cookbook.html"); + Assert.That(entity.Url.OriginalString, Is.EqualTo("http://fabiomaulo.blogspot.com/2010/10/nhibernate-30-cookbook.html")); s.Delete(entity); s.Flush(); } @@ -55,7 +55,7 @@ public void InsertNullValue() using (ISession s = OpenSession()) { var entity = s.Get(1); - entity.Url.Should().Be.Null(); + Assert.That(entity.Url, Is.Null); s.Delete(entity); s.Flush(); } @@ -66,7 +66,7 @@ public void AutoDiscoverFromNetType() { // integration test to be 100% sure var propertyType = sessions.GetEntityPersister(typeof(UriClass).FullName).GetPropertyType("AutoUri"); - propertyType.Should().Be.InstanceOf(); + Assert.That(propertyType, Is.InstanceOf()); } } diff --git a/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs b/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs index fac4f43db38..0878df7f283 100644 --- a/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs @@ -15,10 +15,10 @@ protected override string TypeName get { return "XDoc"; } } - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return TestDialect.SupportsSqlType(new SqlType(DbType.Xml)); - } + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return TestDialect.SupportsSqlType(new SqlType(DbType.Xml)); + } [Test] public void ReadWrite() @@ -26,7 +26,7 @@ public void ReadWrite() using (var s = OpenSession()) { var docEntity = new XDocClass {Id = 1 }; - docEntity.Document = XDocument.Parse("my Text"); + docEntity.Document = XDocument.Parse("my Text"); s.Save(docEntity); s.Flush(); } @@ -35,18 +35,18 @@ public void ReadWrite() { var docEntity = s.Get(1); var document = docEntity.Document; - document.Should().Not.Be.Null(); - document.Document.Root.ToString(SaveOptions.DisableFormatting).Should().Contain("my Text"); + Assert.That(document, Is.Not.Null); + Assert.That(document.Document.Root.ToString(SaveOptions.DisableFormatting), Is.StringContaining("my Text")); var xmlElement = new XElement("Pizza", new XAttribute("temp", "calda")); - document.Document.Root.Add(xmlElement); + document.Document.Root.Add(xmlElement); s.Save(docEntity); s.Flush(); } using (var s = OpenSession()) { var docEntity = s.Get(1); - var document = docEntity.Document; - document.Document.Root.ToString(SaveOptions.DisableFormatting).Should().Contain("Pizza temp=\"calda\""); + var document = docEntity.Document; + Assert.That(document.Document.Root.ToString(SaveOptions.DisableFormatting), Is.StringContaining("Pizza temp=\"calda\"")); s.Delete(docEntity); s.Flush(); } @@ -66,7 +66,7 @@ public void InsertNullValue() using (ISession s = OpenSession()) { var docEntity = s.Get(1); - docEntity.Document.Should().Be.Null(); + Assert.That(docEntity.Document, Is.Null); s.Delete(docEntity); s.Flush(); } @@ -77,7 +77,7 @@ public void AutoDiscoverFromNetType() { // integration test to be 100% sure var propertyType = sessions.GetEntityPersister(typeof (XDocClass).FullName).GetPropertyType("AutoDocument"); - propertyType.Should().Be.InstanceOf(); + Assert.That(propertyType, Is.InstanceOf()); } } } diff --git a/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs b/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs index a4834a3e930..3a5d4ff9387 100644 --- a/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs @@ -14,10 +14,10 @@ protected override string TypeName get { return "XmlDoc"; } } - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return TestDialect.SupportsSqlType(new SqlType(DbType.Xml)); - } + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return TestDialect.SupportsSqlType(new SqlType(DbType.Xml)); + } [Test] public void ReadWrite() @@ -35,8 +35,8 @@ public void ReadWrite() { var docEntity = s.Get(1); var document = docEntity.Document; - document.Should().Not.Be.Null(); - document.OuterXml.Should().Contain("my Text"); + Assert.That(document, Is.Not.Null); + Assert.That(document.OuterXml, Is.StringContaining("my Text")); var xmlElement = document.CreateElement("Pizza"); xmlElement.SetAttribute("temp", "calda"); document.FirstChild.AppendChild(xmlElement); @@ -46,7 +46,7 @@ public void ReadWrite() using (var s = OpenSession()) { var docEntity = s.Get(1); - docEntity.Document.OuterXml.Should().Contain("Pizza temp=\"calda\""); + Assert.That(docEntity.Document.OuterXml, Is.StringContaining("Pizza temp=\"calda\"")); s.Delete(docEntity); s.Flush(); } @@ -66,7 +66,7 @@ public void InsertNullValue() using (ISession s = OpenSession()) { var docEntity = s.Get(1); - docEntity.Document.Should().Be.Null(); + Assert.That(docEntity.Document, Is.Null); s.Delete(docEntity); s.Flush(); } @@ -77,7 +77,7 @@ public void AutoDiscoverFromNetType() { // integration test to be 100% sure var propertyType = sessions.GetEntityPersister(typeof (XmlDocClass).FullName).GetPropertyType("AutoDocument"); - propertyType.Should().Be.InstanceOf(); + Assert.That(propertyType, Is.InstanceOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/AnyExtensionTests.cs b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/AnyExtensionTests.cs index df494332e80..99da4bf94be 100644 --- a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/AnyExtensionTests.cs +++ b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/AnyExtensionTests.cs @@ -12,13 +12,13 @@ public class AnyExtensionTests [Test] public void WhenEmptyListThenReturnFalse() { - (new object[0]).Any().Should().Be.False(); + Assert.That((new object[0]).Any(), Is.False); } [Test] public void WhenNoEmptyListThenReturnTrue() { - (new object[1]).Any().Should().Be.True(); + Assert.That((new object[1]).Any(), Is.True); } private class MyDisposableList: IEnumerable @@ -70,7 +70,7 @@ public void WhenDisposableListThenCallDispose() { var disposeCalled = false; (new MyDisposableList(()=> disposeCalled = true)).Any(); - disposeCalled.Should().Be.True(); + Assert.That(disposeCalled, Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstExtensionTests.cs b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstExtensionTests.cs index 349bb9ac7b4..be147a35799 100644 --- a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstExtensionTests.cs +++ b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstExtensionTests.cs @@ -11,19 +11,19 @@ public class FirstExtensionTests [Test] public void WhenNullThenThenThrows() { - Executing.This(() => ((IEnumerable)null).First()).Should().Throw(); + Assert.That(() => ((IEnumerable)null).First(), Throws.TypeOf()); } [Test] public void WhenHasElementsThenReturnFirst() { - (new[] { 2, 1 }).First().Should().Be(2); + Assert.That((new[] { 2, 1 }).First(), Is.EqualTo(2)); } [Test] public void WhenEmptyThenThrowsInvalidOperation() { - Executing.This(() => (new object[0]).First()).Should().Throw(); + Assert.That(() => (new object[0]).First(), Throws.TypeOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs index 97f857e851f..c69cea9d5c5 100644 --- a/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs +++ b/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs @@ -11,19 +11,19 @@ public class FirstOrNullExtensionTests [Test] public void WhenNullThenThenThrows() { - Executing.This(() => ((IEnumerable)null).FirstOrNull()).Should().Throw(); + Assert.That(() => ((IEnumerable)null).FirstOrNull(), Throws.TypeOf()); } [Test] public void WhenHasElementsThenReturnFirst() { - (new[] { 2, 1 }).FirstOrNull().Should().Be(2); + Assert.That((new[] { 2, 1 }).FirstOrNull(), Is.EqualTo(2)); } [Test] public void WhenEmptyThenReturnNull() { - (new object[0]).FirstOrNull().Should().Be.Null(); + Assert.That((new object[0]).FirstOrNull(), Is.Null); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/PropertiesHelperTest.cs b/src/NHibernate.Test/UtilityTest/PropertiesHelperTest.cs index 3ec4af63224..baf550ea757 100644 --- a/src/NHibernate.Test/UtilityTest/PropertiesHelperTest.cs +++ b/src/NHibernate.Test/UtilityTest/PropertiesHelperTest.cs @@ -10,37 +10,37 @@ public class PropertiesHelperTest [Test] public void WhenInvalidBoolValueThenUseDefault() { - PropertiesHelper.GetBoolean("myProp", new Dictionary {{"myProp", "pizza"}}, false).Should().Be.False(); + Assert.That(PropertiesHelper.GetBoolean("myProp", new Dictionary {{"myProp", "pizza"}}, false), Is.False); } [Test] public void WhenInvalidInt32ValueThenUseDefault() { - PropertiesHelper.GetInt32("myProp", new Dictionary { { "myProp", "pizza" } }, 5).Should().Be(5); + Assert.That(PropertiesHelper.GetInt32("myProp", new Dictionary { { "myProp", "pizza" } }, 5), Is.EqualTo(5)); } [Test] public void WhenInvalidInt64ValueThenUseDefault() { - PropertiesHelper.GetInt64("myProp", new Dictionary { { "myProp", "pizza" } }, 5).Should().Be(5); + Assert.That(PropertiesHelper.GetInt64("myProp", new Dictionary { { "myProp", "pizza" } }, 5), Is.EqualTo(5)); } [Test] public void WhenValidBoolValueThenValue() { - PropertiesHelper.GetBoolean("myProp", new Dictionary { { "myProp", "true" } }, false).Should().Be.True(); + Assert.That(PropertiesHelper.GetBoolean("myProp", new Dictionary { { "myProp", "true" } }, false), Is.True); } [Test] public void WhenValidInt32ValueThenValue() { - PropertiesHelper.GetInt32("myProp", new Dictionary { { "myProp", int.MaxValue.ToString() } }, 5).Should().Be(int.MaxValue); + Assert.That(PropertiesHelper.GetInt32("myProp", new Dictionary { { "myProp", int.MaxValue.ToString() } }, 5), Is.EqualTo(int.MaxValue)); } [Test] public void WhenValidInt64ValueThenValue() { - PropertiesHelper.GetInt64("myProp", new Dictionary { { "myProp", long.MaxValue.ToString() } }, 5).Should().Be(long.MaxValue); + Assert.That(PropertiesHelper.GetInt64("myProp", new Dictionary { { "myProp", long.MaxValue.ToString() } }, 5), Is.EqualTo(long.MaxValue)); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs b/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs index 8010a34661e..619a97d9a33 100644 --- a/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs +++ b/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs @@ -40,43 +40,43 @@ string IHasSomething.Something public void WhenNullSourceThenNotFound() { System.Type source= null; - source.HasProperty("whatever").Should().Be.False(); + Assert.That(source.HasProperty("whatever"), Is.False); } [Test] public void WhenNullNameThenNotFound() { - typeof(Person).HasProperty(null).Should().Be.False(); + Assert.That(typeof(Person).HasProperty(null), Is.False); } [Test] public void WhenPropertyIsInClassThenFound() { - typeof(Person).HasProperty("Normal").Should().Be.True(); + Assert.That(typeof(Person).HasProperty("Normal"), Is.True); } [Test] public void WhenPropertyIsInBaseClassThenFound() { - typeof(Person).HasProperty("Id").Should().Be.True(); + Assert.That(typeof(Person).HasProperty("Id"), Is.True); } [Test] public void WhenPropertyIsExplicitImplementationOfInterfaceThenFound() { - typeof(Person).HasProperty("Something").Should().Be.True(); + Assert.That(typeof(Person).HasProperty("Something"), Is.True); } [Test] public void WhenFieldThenNotFound() { - typeof(Person).HasProperty("_firstName").Should().Be.False(); + Assert.That(typeof(Person).HasProperty("_firstName"), Is.False); } [Test] public void WhenPropertyNameWithDifferentCaseThenNotFound() { - typeof(Person).HasProperty("FirstName").Should().Be.False(); + Assert.That(typeof(Person).HasProperty("FirstName"), Is.False); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs b/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs index 9e35b4caa73..c9becea4f56 100644 --- a/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs +++ b/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs @@ -4,7 +4,6 @@ using NHibernate.Linq; using NHibernate.Util; using NUnit.Framework; -using SharpTestsEx; namespace NHibernate.Test.UtilityTest { @@ -13,19 +12,20 @@ public class ReflectionHelperIsMethodOfTests [Test] public void WhenNullMethodInfoThenThrows() { - ((MethodInfo) null).Executing(mi => mi.IsMethodOf(typeof (Object))).Throws(); + Assert.Throws(() => ((MethodInfo) null).IsMethodOf(typeof (Object))); } [Test] public void WhenNullTypeThenThrows() { - ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).Executing(mi => mi.IsMethodOf(null)).Throws(); + var methodInfo = ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)); + Assert.Throws(() => methodInfo.IsMethodOf(null)); } [Test] public void WhenDeclaringTypeMatchThenTrue() { - ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(List)).Should().Be.True(); + Assert.That(ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(List)), Is.True); } private class MyCollection: List @@ -36,33 +36,33 @@ private class MyCollection: List [Test] public void WhenCustomTypeMatchThenTrue() { - ReflectionHelper.GetMethodDefinition(t => t.Contains(5)).IsMethodOf(typeof(List)).Should().Be.True(); + Assert.That(ReflectionHelper.GetMethodDefinition(t => t.Contains(5)).IsMethodOf(typeof(List)), Is.True); } [Test] public void WhenTypeIsGenericDefinitionAndMatchThenTrue() { - ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(List<>)).Should().Be.True(); + Assert.That(ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(List<>)), Is.True); } [Test] public void WhenTypeIsGenericImplementedInterfaceAndMatchThenTrue() { var containsMethodDefinition = ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)); - containsMethodDefinition.IsMethodOf(typeof(ICollection)).Should().Be.True(); + Assert.That(containsMethodDefinition.IsMethodOf(typeof(ICollection)), Is.True); } [Test] public void WhenTypeIsGenericImplementedInterfaceAndMatchGenericInterfaceDefinitionThenTrue() { var containsMethodDefinition = ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)); - containsMethodDefinition.IsMethodOf(typeof(ICollection<>)).Should().Be.True(); + Assert.That(containsMethodDefinition.IsMethodOf(typeof(ICollection<>)), Is.True); } [Test] public void WhenNoMatchThenFalse() { - ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(IEnumerable<>)).Should().Be.False(); + Assert.That(ReflectionHelper.GetMethodDefinition>(t => t.Contains(5)).IsMethodOf(typeof(IEnumerable<>)), Is.False); } private abstract class MyAbstractClass @@ -79,14 +79,14 @@ private class MyClass : MyAbstractClass public void WhenTypeIsGenericImplementedAbstractAndMatchThenTrue() { var containsMethodDefinition = ReflectionHelper.GetMethodDefinition(t => t.MyMethod()); - containsMethodDefinition.IsMethodOf(typeof(MyAbstractClass)).Should().Be.True(); + Assert.That(containsMethodDefinition.IsMethodOf(typeof(MyAbstractClass)), Is.True); } [Test] public void WhenTypeIsGenericImplementedAbstractAndMatchGenericInterfaceDefinitionThenTrue() { var containsMethodDefinition = ReflectionHelper.GetMethodDefinition(t => t.MyMethod()); - containsMethodDefinition.IsMethodOf(typeof(MyAbstractClass<>)).Should().Be.True(); + Assert.That(containsMethodDefinition.IsMethodOf(typeof(MyAbstractClass<>)), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/ReflectionHelperTest.cs b/src/NHibernate.Test/UtilityTest/ReflectionHelperTest.cs index 929b94ebdb8..9bb4699fd67 100644 --- a/src/NHibernate.Test/UtilityTest/ReflectionHelperTest.cs +++ b/src/NHibernate.Test/UtilityTest/ReflectionHelperTest.cs @@ -20,55 +20,55 @@ public void GenericMethod() { } [Test] public void WhenGetMethodForNullThenThrows() { - Executing.This(() => ReflectionHelper.GetMethodDefinition((Expression) null)).Should().Throw(); + Assert.That(() => ReflectionHelper.GetMethodDefinition((Expression) null), Throws.TypeOf()); } [Test] public void WhenGenericGetMethodForNullThenThrows() { - Executing.This(() => ReflectionHelper.GetMethodDefinition((Expression>)null)).Should().Throw(); + Assert.That(() => ReflectionHelper.GetMethodDefinition((Expression>)null), Throws.TypeOf()); } [Test] public void WhenGetPropertyForNullThenThrows() { - Executing.This(() => ReflectionHelper.GetProperty(null)).Should().Throw(); + Assert.That(() => ReflectionHelper.GetProperty(null), Throws.TypeOf()); } [Test] public void WhenGenericMethodOfClassThenReturnGenericDefinition() { - ReflectionHelper.GetMethodDefinition(mc => mc.GenericMethod()).Should().Be(typeof (MyClass).GetMethod("GenericMethod").GetGenericMethodDefinition()); + Assert.That(ReflectionHelper.GetMethodDefinition(mc => mc.GenericMethod()), Is.EqualTo(typeof (MyClass).GetMethod("GenericMethod").GetGenericMethodDefinition())); } [Test] public void WhenNoGenericMethodOfClassThenReturnDefinition() { - ReflectionHelper.GetMethodDefinition(mc => mc.NoGenericMethod()).Should().Be(typeof(MyClass).GetMethod("NoGenericMethod")); + Assert.That(ReflectionHelper.GetMethodDefinition(mc => mc.NoGenericMethod()), Is.EqualTo(typeof(MyClass).GetMethod("NoGenericMethod"))); } [Test] public void WhenStaticGenericMethodThenReturnGenericDefinition() { - ReflectionHelper.GetMethodDefinition(() => Enumerable.All(null, null)).Should().Be(typeof(Enumerable).GetMethod("All").GetGenericMethodDefinition()); + Assert.That(ReflectionHelper.GetMethodDefinition(() => Enumerable.All(null, null)), Is.EqualTo(typeof(Enumerable).GetMethod("All").GetGenericMethodDefinition())); } [Test] public void WhenStaticNoGenericMethodThenReturnDefinition() { - ReflectionHelper.GetMethodDefinition(() => string.Join(null, null)).Should().Be(typeof(string).GetMethod("Join", new []{typeof(string), typeof(string[])})); + Assert.That(ReflectionHelper.GetMethodDefinition(() => string.Join(null, null)), Is.EqualTo(typeof(string).GetMethod("Join", new []{typeof(string), typeof(string[])}))); } [Test] public void WhenGetPropertyThenReturnPropertyInfo() { - ReflectionHelper.GetProperty(mc => mc.BaseProperty).Should().Be(typeof(MyClass).GetProperty("BaseProperty")); + Assert.That(ReflectionHelper.GetProperty(mc => mc.BaseProperty), Is.EqualTo(typeof(MyClass).GetProperty("BaseProperty"))); } [Test] public void WhenGetPropertyForBoolThenReturnPropertyInfo() { - ReflectionHelper.GetProperty(mc => mc.BaseBool).Should().Be(typeof(MyClass).GetProperty("BaseBool")); + Assert.That(ReflectionHelper.GetProperty(mc => mc.BaseBool), Is.EqualTo(typeof(MyClass).GetProperty("BaseBool"))); } } } \ No newline at end of file