diff --git a/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs b/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs index 9e501c3..205eb94 100644 --- a/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs +++ b/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs @@ -22,7 +22,7 @@ // new TestModel {Name = "Test2"}, // }.AsQueryable(); -// [Test] +// [Fact] // public void Should_Call_Fetch_Successfully() // { // using (var fakeProvider = new ContextScopeProviderHelper()) @@ -32,13 +32,13 @@ // var result = originalQuery.Fetch(s => s.Parent); -// Assert.IsNotNull(result); +// Assert.NotNull(result); // Assert.Equal(result.Count(), 1); -// Assert.IsTrue(result.Any(r => r.Name == "Fetch_Result")); +// Assert.True(result.Any(r => r.Name == "Fetch_Result")); // } // } -// [Test] +// [Fact] // public void Should_Call_FetchMany_Successfully() // { // using (var fakeProvider = new ContextScopeProviderHelper()) @@ -48,13 +48,13 @@ // var result = originalQuery.FetchMany(s => s.Children); -// Assert.IsNotNull(result); +// Assert.NotNull(result); // Assert.Equal(result.Count(), 1); -// Assert.IsTrue(result.Any(r => r.Name == "FetchMany_Result")); +// Assert.True(result.Any(r => r.Name == "FetchMany_Result")); // } // } -// [Test] +// [Fact] // public void Should_Call_ThenFetch_Successfully() // { // using (var fakeProvider = new ContextScopeProviderHelper()) @@ -64,13 +64,13 @@ // var result = originalQuery.Fetch(s => s.Parent).ThenFetch(s => s.Parent); -// Assert.IsNotNull(result); +// Assert.NotNull(result); // Assert.Equal(result.Count(), 1); -// Assert.IsTrue(result.Any(r => r.Name == "ThenFetch_Result")); +// Assert.True(result.Any(r => r.Name == "ThenFetch_Result")); // } // } -// [Test] +// [Fact] // public void Should_Call_ThenFetchMany_Successfully() // { // using (var fakeProvider = new ContextScopeProviderHelper()) @@ -80,9 +80,9 @@ // var result = originalQuery.FetchMany(s => s.Children).ThenFetchMany(s => s.Children); -// Assert.IsNotNull(result); +// Assert.NotNull(result); // Assert.Equal(result.Count(), 1); -// Assert.IsTrue(result.Any(r => r.Name == "ThenFetchMany_Result")); +// Assert.True(result.Any(r => r.Name == "ThenFetchMany_Result")); // } // } @@ -103,9 +103,9 @@ // .Setup(p => p.ThenFetch(It.IsAny>(), It.IsAny>>())) // .Returns, Expression>>((query, expression) => // { -// Assert.IsNotNull(query); +// Assert.NotNull(query); // Assert.Equal(query.Count(), 1); -// Assert.IsTrue(query.Any(r => r.Name == "Fetch_Result")); +// Assert.True(query.Any(r => r.Name == "Fetch_Result")); // var result = new List {new TestModel {Name = "ThenFetch_Result"}}.AsQueryable(); // return new FetchRequestTest(result); @@ -125,9 +125,9 @@ // .Setup(p => p.ThenFetchMany(It.IsAny>(), It.IsAny>>>())) // .Returns, Expression>>>((query, expression) => // { -// Assert.IsNotNull(query); +// Assert.NotNull(query); // Assert.Equal(query.Count(), 1); -// Assert.IsTrue(query.Any(r => r.Name == "FetchMany_Result")); +// Assert.True(query.Any(r => r.Name == "FetchMany_Result")); // var result = new List {new TestModel {Name = "ThenFetchMany_Result"}}.AsQueryable(); // return new FetchRequestTest(result); diff --git a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs index 9dc765a..ba5dda6 100644 --- a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs @@ -51,10 +51,10 @@ public void ShouldLoad_Assembly_GetLoadableTypes() // var testBaseType = typeof(TestBase); // var types = loader.GetLoadableTypes(assembly, testBaseType); - // Assert.IsNotNull(types); + // Assert.NotNull(types); // Assert.Greater(types.Count(), 1); - // Assert.IsTrue(types.Contains(GetType())); - // Assert.IsTrue(types.All(testBaseType.IsAssignableFrom)); + // Assert.True(types.Contains(GetType())); + // Assert.True(types.All(testBaseType.IsAssignableFrom)); //} } } diff --git a/vNext/test/BetterModules.Core.Tests/Environment/FileSystem/DefaultWorkingDirectoryTests.cs b/vNext/test/BetterModules.Core.Tests/Environment/FileSystem/DefaultWorkingDirectoryTests.cs index fd6fd51..d16d4db 100644 --- a/vNext/test/BetterModules.Core.Tests/Environment/FileSystem/DefaultWorkingDirectoryTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Environment/FileSystem/DefaultWorkingDirectoryTests.cs @@ -2,70 +2,52 @@ using System.IO; using System.Linq; using BetterModules.Core.Environment.FileSystem; -using NUnit.Framework; +using Microsoft.Framework.Logging; +using Xunit; namespace BetterModules.Core.Tests.Environment.FileSystem { - [TestFixture] - public class DefaultWorkingDirectoryTests : TestBase + public class DefaultWorkingDirectoryTests { - private string OriginalFileName - { - get - { - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "TestModules", "test.dll"); - } - } - - private string RuntimeFileName - { - get - { - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.dll"); - } - } + private string OriginalFileName => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "TestModules", "test.dll"); - private string ModuleFileName - { - get - { - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "Modules", "test.dll"); - } - } + private string RuntimeFileName => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.dll"); + + private string ModuleFileName => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "Modules", "test.dll"); - [Test] + [Fact] public void ShouldReturn_Correct_WorkingDirectoryPath() { - var service = new DefaultWorkingDirectory(); + var service = new DefaultWorkingDirectory(new LoggerFactory()); var path = service.GetWorkingDirectoryPath(); - Assert.IsNotNull(path); - Assert.IsTrue(path.Contains(AppDomain.CurrentDomain.BaseDirectory)); + Assert.NotNull(path); + Assert.True(path.Contains(AppDomain.CurrentDomain.BaseDirectory)); } - [Test] + [Fact] public void ShouldReturn_AvailableModules() { PrepareTestDll(); - var service = new DefaultWorkingDirectory(); + var service = new DefaultWorkingDirectory(new LoggerFactory()); var modules = service.GetAvailableModules(); - Assert.IsNotNull(modules); - Assert.AreEqual(modules.Count(), 1); - Assert.AreEqual(modules.First().Name, "test.dll"); + Assert.NotNull(modules); + Assert.Equal(modules.Count(), 1); + Assert.Equal(modules.First().Name, "test.dll"); RemoveTestDll(); } - [Test] + [Fact] public void ShouldCopy_ModulesToRuntimeDirectory_Successfully() { PrepareTestDll(); - var service = new DefaultWorkingDirectory(); + var service = new DefaultWorkingDirectory(new LoggerFactory()); service.RecopyModulesToRuntimeFolder(new FileInfo(ModuleFileName)); - Assert.IsTrue(File.Exists(RuntimeFileName)); + Assert.True(File.Exists(RuntimeFileName)); RemoveTestDll(); } diff --git a/vNext/test/BetterModules.Core.Tests/Events/CoreEventsTests.cs b/vNext/test/BetterModules.Core.Tests/Events/CoreEventsTests.cs index 1212e85..15b03a7 100644 --- a/vNext/test/BetterModules.Core.Tests/Events/CoreEventsTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Events/CoreEventsTests.cs @@ -2,19 +2,18 @@ using BetterModules.Events; using Moq; using NHibernate; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Events { - [TestFixture] - public class CoreEventsTests : TestBase + public class CoreEventsTests { private int firedDelete; private int firedSave; private IEntity entity; private ISession session; - [Test] + [Fact] public void Should_FireDeleteEvents_Correctly() { firedDelete = 0; @@ -22,16 +21,16 @@ public void Should_FireDeleteEvents_Correctly() CoreEvents.Instance.EntityDeleting += Instance_EntityDeleting; - Assert.AreEqual(firedDelete, 0); + Assert.Equal(firedDelete, 0); CoreEvents.Instance.OnEntityDelete(entity); - Assert.AreEqual(firedDelete, 1); + Assert.Equal(firedDelete, 1); CoreEvents.Instance.OnEntityDelete(entity); - Assert.AreEqual(firedDelete, 2); + Assert.Equal(firedDelete, 2); CoreEvents.Instance.EntityDeleting -= Instance_EntityDeleting; } - [Test] + [Fact] public void Should_FireSaveEvents_Correctly() { firedSave = 0; @@ -40,11 +39,11 @@ public void Should_FireSaveEvents_Correctly() CoreEvents.Instance.EntitySaving += Instance_EntitySaving; - Assert.AreEqual(firedSave, 0); + Assert.Equal(firedSave, 0); CoreEvents.Instance.OnEntitySaving(entity, session); - Assert.AreEqual(firedSave, 1); + Assert.Equal(firedSave, 1); CoreEvents.Instance.OnEntitySaving(entity, session); - Assert.AreEqual(firedSave, 2); + Assert.Equal(firedSave, 2); CoreEvents.Instance.EntitySaving -= Instance_EntitySaving; } diff --git a/vNext/test/BetterModules.Core.Tests/Events/EntitySavingEventArgsTests.cs b/vNext/test/BetterModules.Core.Tests/Events/EntitySavingEventArgsTests.cs index 386f292..9981969 100644 --- a/vNext/test/BetterModules.Core.Tests/Events/EntitySavingEventArgsTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Events/EntitySavingEventArgsTests.cs @@ -2,14 +2,13 @@ using BetterModules.Events; using Moq; using NHibernate; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Events { - [TestFixture] - public class EntitySavingEventArgsTests : TestBase + public class EntitySavingEventArgsTests { - [Test] + [Fact] public void Should_Assign_Correct_Session_Arg() { var session = new Mock().Object; @@ -17,8 +16,8 @@ public void Should_Assign_Correct_Session_Arg() var args = new EntitySavingEventArgs(entity, session); - Assert.AreEqual(args.Session, session); - Assert.AreEqual(args.Entity, entity); + Assert.Equal(args.Session, session); + Assert.Equal(args.Entity, entity); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Events/SingleItemEventArgsTests.cs b/vNext/test/BetterModules.Core.Tests/Events/SingleItemEventArgsTests.cs index 36c2e5b..5269d03 100644 --- a/vNext/test/BetterModules.Core.Tests/Events/SingleItemEventArgsTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Events/SingleItemEventArgsTests.cs @@ -1,17 +1,16 @@ using BetterModules.Events; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Events { - [TestFixture] - public class SingleItemEventArgsTests : TestBase + public class SingleItemEventArgsTests { - [Test] + [Fact] public void Should_Assign_Correct_Single_Event_Arg() { var args = new SingleItemEventArgs(13); - Assert.AreEqual(args.Item, 13); + Assert.Equal(args.Item, 13); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/ConcurrentDataExceptionTests.cs b/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/ConcurrentDataExceptionTests.cs index c6a6bea..c1bff45 100644 --- a/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/ConcurrentDataExceptionTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/ConcurrentDataExceptionTests.cs @@ -1,48 +1,47 @@ using System; using BetterModules.Core.Exceptions.DataTier; using BetterModules.Sample.Module.Models; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Exceptions.DataTier { - [TestFixture] public class ConcurrentDataExceptionTests { private const string Message = "TestExcMessage"; - [Test] + [Fact] public void Should_Create_Exception_With_Message() { var exception = new ConcurrentDataException(Message); - Assert.AreEqual(exception.Message, Message); - Assert.IsNull(exception.InnerException); - Assert.IsNull(exception.StaleEntity); + Assert.Equal(exception.Message, Message); + Assert.Null(exception.InnerException); + Assert.Null(exception.StaleEntity); } - [Test] + [Fact] public void Should_Create_Exception_With_Message_And_InnerException() { var innerException = new Exception(Message); var exception = new ConcurrentDataException(Message, innerException); - Assert.AreEqual(exception.Message, Message); - Assert.AreEqual(exception.InnerException, innerException); - Assert.IsNull(exception.StaleEntity); + Assert.Equal(exception.Message, Message); + Assert.Equal(exception.InnerException, innerException); + Assert.Null(exception.StaleEntity); } - [Test] + [Fact] public void Should_Create_Exception_With_Stale_Entity() { var guid = Guid.NewGuid(); var entity = new TestItemModel { Id = guid }; var exception = new ConcurrentDataException(entity); - Assert.IsNotNull(exception.Message); - Assert.IsTrue(exception.Message.Contains(guid.ToString())); - Assert.IsTrue(exception.Message.Contains("TestItemModel")); - Assert.AreEqual(exception.StaleEntity, entity); - Assert.IsNull(exception.InnerException); + Assert.NotNull(exception.Message); + Assert.True(exception.Message.Contains(guid.ToString())); + Assert.True(exception.Message.Contains("TestItemModel")); + Assert.Equal(exception.StaleEntity, entity); + Assert.Null(exception.InnerException); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/EntityNotFoundExceptionTests.cs b/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/EntityNotFoundExceptionTests.cs index 66dcc4a..ce25e42 100644 --- a/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/EntityNotFoundExceptionTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Exceptions/DataTier/EntityNotFoundExceptionTests.cs @@ -1,56 +1,55 @@ using System; using BetterModules.Core.Exceptions.DataTier; using BetterModules.Sample.Module.Models; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Exceptions.DataTier { - [TestFixture] public class EntityNotFoundExceptionTests { private const string Message = "TestExcMessage"; - [Test] + [Fact] public void Should_Create_Exception_With_Message() { var exception = new EntityNotFoundException(Message); - Assert.AreEqual(exception.Message, Message); - Assert.IsNull(exception.InnerException); + Assert.Equal(exception.Message, Message); + Assert.Null(exception.InnerException); } - [Test] + [Fact] public void Should_Create_Exception_With_Message_And_InnerException() { var innerException = new Exception(Message); var exception = new EntityNotFoundException(Message, innerException); - Assert.AreEqual(exception.Message, Message); - Assert.AreEqual(exception.InnerException, innerException); + Assert.Equal(exception.Message, Message); + Assert.Equal(exception.InnerException, innerException); } - [Test] + [Fact] public void Should_Create_Exception_With_Type_And_Id() { var guid = Guid.NewGuid(); var exception = new EntityNotFoundException(typeof(TestItemModel), guid); - Assert.IsNotNull(exception.Message); - Assert.IsTrue(exception.Message.Contains(guid.ToString())); - Assert.IsTrue(exception.Message.Contains("TestItemModel")); - Assert.IsNull(exception.InnerException); + Assert.NotNull(exception.Message); + Assert.True(exception.Message.Contains(guid.ToString())); + Assert.True(exception.Message.Contains("TestItemModel")); + Assert.Null(exception.InnerException); } - [Test] + [Fact] public void Should_Create_Exception_With_Type_And_Filter() { var filter = "test filter"; var exception = new EntityNotFoundException(typeof(TestItemModel), filter); - Assert.IsNotNull(exception.Message); - Assert.IsTrue(exception.Message.Contains(filter)); - Assert.IsTrue(exception.Message.Contains("TestItemModel")); - Assert.IsNull(exception.InnerException); + Assert.NotNull(exception.Message); + Assert.True(exception.Message.Contains(filter)); + Assert.True(exception.Message.Contains("TestItemModel")); + Assert.Null(exception.InnerException); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Extensions/TypeExtensionsTests.cs b/vNext/test/BetterModules.Core.Tests/Extensions/TypeExtensionsTests.cs index 7da41a4..91334d3 100644 --- a/vNext/test/BetterModules.Core.Tests/Extensions/TypeExtensionsTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Extensions/TypeExtensionsTests.cs @@ -1,33 +1,32 @@ using BetterModules.Core.Extensions; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Extensions { - [TestFixture] - public class TypeExtensionsTests : TestBase + public class TypeExtensionsTests { - [Test] + [Fact] public void Should_Check_GenericType_Correctly() { var instance = new TestClass(); var type = instance.GetType(); - Assert.IsTrue(type.IsAssignableToGenericType(typeof(ITestInterface1<>))); - Assert.IsTrue(type.IsAssignableToGenericType(typeof(ITestInterface2<,>))); - Assert.IsTrue(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); - Assert.IsTrue(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); + Assert.True(type.IsAssignableToGenericType(typeof(ITestInterface1<>))); + Assert.True(type.IsAssignableToGenericType(typeof(ITestInterface2<,>))); + Assert.True(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); + Assert.True(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); } - [Test] + [Fact] public void Should_Check_NonGenericType_Correctly() { var instance = new TestClass2(); var type = instance.GetType(); - Assert.IsFalse(type.IsAssignableToGenericType(typeof(ITestInterface1<>))); - Assert.IsFalse(type.IsAssignableToGenericType(typeof(ITestInterface2<,>))); - Assert.IsFalse(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); - Assert.IsFalse(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); + Assert.False(type.IsAssignableToGenericType(typeof(ITestInterface1<>))); + Assert.False(type.IsAssignableToGenericType(typeof(ITestInterface2<,>))); + Assert.False(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); + Assert.False(type.IsAssignableToGenericType(typeof(AbstractTestBase<>))); } public interface ITestInterface1 diff --git a/vNext/test/BetterModules.Core.Tests/Models/EquatableEntityTests.cs b/vNext/test/BetterModules.Core.Tests/Models/EquatableEntityTests.cs index b5c490a..0f11a2a 100644 --- a/vNext/test/BetterModules.Core.Tests/Models/EquatableEntityTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Models/EquatableEntityTests.cs @@ -1,86 +1,85 @@ using System; using BetterModules.Core.Models; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Models { - [TestFixture] public class EquatableEntityTests { - [Test] + [Fact] public void Should_Compare_Empty_Entities_Using_Equal_Operator() { var model1 = new TestEquatableEntity(); var model2 = new TestEquatableEntity(); var model3 = model1; - Assert.IsTrue(model1 == model3); - Assert.IsFalse(model1 == model2); + Assert.True(model1 == model3); + Assert.False(model1 == model2); } - [Test] + [Fact] public void Should_Compare_Empty_Entities_Using_NotEqual_Operator() { var model1 = new TestEquatableEntity(); var model2 = new TestEquatableEntity(); var model3 = model1; - Assert.IsFalse(model1 != model3); - Assert.IsTrue(model1 != model2); + Assert.False(model1 != model3); + Assert.True(model1 != model2); } - [Test] + [Fact] public void Should_Compare_Entities_Using_Equal_Operator() { var model1 = new TestEquatableEntity {Id = Guid.NewGuid()}; var model2 = new TestEquatableEntity {Id = Guid.NewGuid()}; var model3 = model1; - Assert.IsTrue(model1 == model3); - Assert.IsFalse(model1 == model2); + Assert.True(model1 == model3); + Assert.False(model1 == model2); } - [Test] + [Fact] public void Should_Compare_Entities_Using_NotEqual_Operator() { var model1 = new TestEquatableEntity { Id = Guid.NewGuid() }; var model2 = new TestEquatableEntity { Id = Guid.NewGuid() }; var model3 = model1; - Assert.IsFalse(model1 != model3); - Assert.IsTrue(model1 != model2); + Assert.False(model1 != model3); + Assert.True(model1 != model2); } - [Test] + [Fact] public void Should_Compare_Two_Entities_With_Same_Id() { var guid = Guid.NewGuid(); var model1 = new TestEquatableEntity { Id = guid }; var model2 = new TestEquatableEntity { Id = guid }; - Assert.AreEqual(model1, model2); - Assert.IsTrue(model1 == model2); - Assert.IsTrue(model1.Equals(model2)); - Assert.IsTrue(model2.Equals(model1)); + Assert.Equal(model1, model2); + Assert.True(model1 == model2); + Assert.True(model1.Equals(model2)); + Assert.True(model2.Equals(model1)); } - [Test] + [Fact] public void Should_Compare_Two_Entities_With_Same_Id_HashCodes() { var guid = Guid.NewGuid(); var model1 = new TestEquatableEntity { Id = guid }; var model2 = new TestEquatableEntity { Id = guid }; - Assert.AreEqual(model1.GetHashCode(), model2.GetHashCode()); + Assert.Equal(model1.GetHashCode(), model2.GetHashCode()); } - [Test] + [Fact] public void Should_Compare_Two_Entities_Without_Id_HashCodes() { var model1 = new TestEquatableEntity(); var model2 = new TestEquatableEntity(); - Assert.AreNotEqual(model1.GetHashCode(), model2.GetHashCode()); + Assert.NotEqual(model1.GetHashCode(), model2.GetHashCode()); } private class TestEquatableEntity : EquatableEntity diff --git a/vNext/test/BetterModules.Core.Tests/Models/SchemaNameProviderTests.cs b/vNext/test/BetterModules.Core.Tests/Models/SchemaNameProviderTests.cs index b18d936..c741fac 100644 --- a/vNext/test/BetterModules.Core.Tests/Models/SchemaNameProviderTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Models/SchemaNameProviderTests.cs @@ -1,12 +1,11 @@ using BetterModules.Core.Models; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Models { - [TestFixture] - public class SchemaNameProviderTests : TestBase + public class SchemaNameProviderTests { - [Test] + [Fact] public void Should_Provide_Correct_Schema_Name() { var origPattern = SchemaNameProvider.SchemaNamePattern; @@ -15,7 +14,7 @@ public void Should_Provide_Correct_Schema_Name() { SchemaNameProvider.SchemaNamePattern = "test_{0}_test"; - Assert.AreEqual(SchemaNameProvider.GetSchemaName("MoDuLe"), "test_module_test"); + Assert.Equal(SchemaNameProvider.GetSchemaName("MoDuLe"), "test_module_test"); } finally { diff --git a/vNext/test/BetterModules.Core.Tests/Modules/ModuleDescriptorTests.cs b/vNext/test/BetterModules.Core.Tests/Modules/ModuleDescriptorTests.cs index b2b6d71..51429bd 100644 --- a/vNext/test/BetterModules.Core.Tests/Modules/ModuleDescriptorTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Modules/ModuleDescriptorTests.cs @@ -1,28 +1,27 @@ using BetterModules.Core.Modules; using BetterModules.Core.Modules.Registration; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Modules { - [TestFixture] - public class ModuleDescriptorTests : TestBase + public class ModuleDescriptorTests { - [Test] + [Fact] public void Should_Return_Correct_Assembly_Name() { var descriptor = new TestModuleDescriptor(); - Assert.AreEqual(descriptor.AssemblyName.Name, GetType().Assembly.GetName().Name); + Assert.Equal(descriptor.AssemblyName.Name, GetType().Assembly.GetName().Name); } - [Test] + [Fact] public void Should_Return_Correct_RegistrationContext() { var descriptor = new TestModuleDescriptor(); var context = descriptor.CreateRegistrationContext(); - Assert.IsNotNull(context); - Assert.AreEqual(context.GetType(), typeof(ModuleRegistrationContext)); + Assert.NotNull(context); + Assert.Equal(context.GetType(), typeof(ModuleRegistrationContext)); } private class TestModuleDescriptor : ModuleDescriptor diff --git a/vNext/test/BetterModules.Core.Tests/Modules/Registration/DefaultModulesRegistrationTests.cs b/vNext/test/BetterModules.Core.Tests/Modules/Registration/DefaultModulesRegistrationTests.cs index 2de9862..d01c97a 100644 --- a/vNext/test/BetterModules.Core.Tests/Modules/Registration/DefaultModulesRegistrationTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Modules/Registration/DefaultModulesRegistrationTests.cs @@ -5,21 +5,22 @@ using BetterModules.Core.Environment.Assemblies; using BetterModules.Core.Modules.Registration; using BetterModules.Sample.Module; +using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Logging; using Moq; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Modules.Registration { - [TestFixture] - public class DefaultModulesRegistrationTests : TestBase + public class DefaultModulesRegistrationTests { - [Test] + [Fact] public void ShouldAddDescriptor_FromAssembly_Correctly() { AddAssembly(1); } - [Test] + [Fact] public void ShouldNotAddDescriptor_FromAssembly_Correctly() { AddAssembly(0); @@ -32,14 +33,16 @@ private void AddAssembly(int expectedResult) .Setup(a => a.GetLoadableTypes(It.IsAny())) .Returns(a => new List { typeof(TType) }); - var registration = new DefaultModulesRegistration(assemblyLoaderMock.Object); + var registration = new DefaultModulesRegistration(assemblyLoaderMock.Object, new LoggerFactory()); registration.AddModuleDescriptorTypeFromAssembly(typeof(TType).Assembly); - registration.InitializeModules(); + var services = new ServiceCollection(); + + registration.InitializeModules(services); var modules = registration.GetModules(); - Assert.IsNotNull(modules); - Assert.AreEqual(modules.Count(), expectedResult); + Assert.NotNull(modules); + Assert.Equal(modules.Count(), expectedResult); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Modules/Registration/ModuleRegistrationContextTests.cs b/vNext/test/BetterModules.Core.Tests/Modules/Registration/ModuleRegistrationContextTests.cs index af1ce4b..9656a89 100644 --- a/vNext/test/BetterModules.Core.Tests/Modules/Registration/ModuleRegistrationContextTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Modules/Registration/ModuleRegistrationContextTests.cs @@ -1,20 +1,19 @@ using BetterModules.Core.Modules.Registration; using BetterModules.Sample.Module; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Modules.Registration { - [TestFixture] - public class ModuleRegistrationContextTests : TestBase + public class ModuleRegistrationContextTests { - [Test] + [Fact] public void Should_Initialize_Context_Correctly() { var descriptor = new SampleModuleDescriptor(); var context = new ModuleRegistrationContext(descriptor); - Assert.AreEqual(context.ModuleDescriptor, descriptor); - Assert.IsNotNull(context.GetRegistrationName()); + Assert.Equal(context.ModuleDescriptor, descriptor); + Assert.NotNull(context.GetRegistrationName()); } } } diff --git a/vNext/test/BetterModules.Core.Tests/Security/DefaultPrincipalProviderTests.cs b/vNext/test/BetterModules.Core.Tests/Security/DefaultPrincipalProviderTests.cs index 3eda016..4649a35 100644 --- a/vNext/test/BetterModules.Core.Tests/Security/DefaultPrincipalProviderTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Security/DefaultPrincipalProviderTests.cs @@ -1,14 +1,13 @@ using System.Security.Principal; using System.Threading; using BetterModules.Core.Security; -using NUnit.Framework; +using Xunit; namespace BetterModules.Core.Tests.Security { - [TestFixture] - public class DefaultPrincipalProviderTests : TestBase + public class DefaultPrincipalProviderTests { - [Test] + [Fact] public void Should_Return_CurrectPrincipal() { var origPrincipal = Thread.CurrentPrincipal; @@ -18,12 +17,12 @@ public void Should_Return_CurrectPrincipal() var principalProvider = new DefaultPrincipalProvider(); var retrievedPrincipal = principalProvider.GetCurrentPrincipal(); - Assert.AreEqual(principal, retrievedPrincipal); + Assert.Equal(principal, retrievedPrincipal); Thread.CurrentPrincipal = origPrincipal; } - [Test] + [Fact] public void Should_Return_CurrectPrincipal_Name() { var origPrincipal = Thread.CurrentPrincipal; @@ -33,12 +32,12 @@ public void Should_Return_CurrectPrincipal_Name() var principalProvider = new DefaultPrincipalProvider(); var name = principalProvider.CurrentPrincipalName; - Assert.AreEqual(name, "TestPrincipal2"); + Assert.Equal(name, "TestPrincipal2"); Thread.CurrentPrincipal = origPrincipal; } - [Test] + [Fact] public void Should_Return_Anonymous_Principal_Name() { var origPrincipal = Thread.CurrentPrincipal; @@ -47,7 +46,7 @@ public void Should_Return_Anonymous_Principal_Name() var principalProvider = new DefaultPrincipalProvider(); var name = principalProvider.CurrentPrincipalName; - Assert.AreEqual(name, DefaultPrincipalProvider.AnonymousPrincipalName); + Assert.Equal(name, DefaultPrincipalProvider.AnonymousPrincipalName); Thread.CurrentPrincipal = origPrincipal; } diff --git a/vNext/test/BetterModules.Core.Tests/TestHelpers/ContextScopeProviderHelper.cs b/vNext/test/BetterModules.Core.Tests/TestHelpers/ContextScopeProviderHelper.cs index d3a856f..a7e4422 100644 --- a/vNext/test/BetterModules.Core.Tests/TestHelpers/ContextScopeProviderHelper.cs +++ b/vNext/test/BetterModules.Core.Tests/TestHelpers/ContextScopeProviderHelper.cs @@ -1,63 +1,63 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Autofac; -using BetterModules.Core.Dependencies; - -namespace BetterModules.Core.Tests.TestHelpers -{ - public class ContextScopeProviderHelper : IDisposable - { - private IDictionary originalObjects = new Dictionary(); - - public void RegisterFakeService(Type type, Type interfaceType) - { - using (var container = ContextScopeProvider.CreateChildContainer()) - { - var service = container.Resolve(interfaceType); - if (!originalObjects.ContainsKey(interfaceType)) - { - originalObjects.Add(interfaceType, service.GetType()); - } - } - - var builder = new ContainerBuilder(); - builder.RegisterType(type).As(interfaceType).InstancePerLifetimeScope(); - - ContextScopeProvider.RegisterTypes(builder); - } +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using Autofac; +//using BetterModules.Core.Dependencies; + +//namespace BetterModules.Core.Tests.TestHelpers +//{ +// public class ContextScopeProviderHelper : IDisposable +// { +// private IDictionary originalObjects = new Dictionary(); + +// public void RegisterFakeService(Type type, Type interfaceType) +// { +// using (var container = ContextScopeProvider.CreateChildContainer()) +// { +// var service = container.Resolve(interfaceType); +// if (!originalObjects.ContainsKey(interfaceType)) +// { +// originalObjects.Add(interfaceType, service.GetType()); +// } +// } + +// var builder = new ContainerBuilder(); +// builder.RegisterType(type).As(interfaceType).InstancePerLifetimeScope(); + +// ContextScopeProvider.RegisterTypes(builder); +// } - public void RegisterFakeServiceInstance(Object type, Type interfaceType) - { - using (var container = ContextScopeProvider.CreateChildContainer()) - { - var service = container.Resolve(interfaceType); - if (!originalObjects.ContainsKey(interfaceType)) - { - originalObjects.Add(interfaceType, service.GetType()); - } - } - - var builder = new ContainerBuilder(); - builder.RegisterInstance(type).As(interfaceType).SingleInstance(); - - ContextScopeProvider.RegisterTypes(builder); - } - - public void Dispose() - { - if (!originalObjects.Any()) - { - return; - } - - var builder = new ContainerBuilder(); - foreach (var keyValue in originalObjects) - { - builder.RegisterType(keyValue.Value).As(keyValue.Key).InstancePerLifetimeScope(); - } - - ContextScopeProvider.RegisterTypes(builder); - } - } -} +// public void RegisterFakeServiceInstance(Object type, Type interfaceType) +// { +// using (var container = ContextScopeProvider.CreateChildContainer()) +// { +// var service = container.Resolve(interfaceType); +// if (!originalObjects.ContainsKey(interfaceType)) +// { +// originalObjects.Add(interfaceType, service.GetType()); +// } +// } + +// var builder = new ContainerBuilder(); +// builder.RegisterInstance(type).As(interfaceType).SingleInstance(); + +// ContextScopeProvider.RegisterTypes(builder); +// } + +// public void Dispose() +// { +// if (!originalObjects.Any()) +// { +// return; +// } + +// var builder = new ContainerBuilder(); +// foreach (var keyValue in originalObjects) +// { +// builder.RegisterType(keyValue.Value).As(keyValue.Key).InstancePerLifetimeScope(); +// } + +// ContextScopeProvider.RegisterTypes(builder); +// } +// } +//}