From 862d99385b7fbbe680b9ac60617a366d965c25f1 Mon Sep 17 00:00:00 2001 From: Lukas Gerbenis Date: Thu, 1 Oct 2015 16:42:53 +0300 Subject: [PATCH] #3 moving tests --- .../BetterModules.Sample.Module.xproj | 2 +- .../BetterModules.Core.Tests.xproj | 7 ++- .../EventListenerHelperTests.cs | 0 .../DataContext/Fetching/EagerFetchTests.cs | 0 .../DataContext/QueryableExtensionsTests.cs | 0 .../DataAccess/PredicateBuilderTests.cs | 0 .../Assemblies/DefaultAssemblyLoaderTests.cs | 60 +++++++++---------- .../Assemblies/DefaultAssemblyManagerTests.cs | 32 +++++----- .../BetterModules.Core.Tests/project.json | 34 ++++++----- 9 files changed, 71 insertions(+), 64 deletions(-) rename {BetterModules.Core.Tests => vNext/test/BetterModules.Core.Tests}/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs (100%) rename {BetterModules.Core.Tests => vNext/test/BetterModules.Core.Tests}/DataAccess/DataContext/Fetching/EagerFetchTests.cs (100%) rename {BetterModules.Core.Tests => vNext/test/BetterModules.Core.Tests}/DataAccess/DataContext/QueryableExtensionsTests.cs (100%) rename {BetterModules.Core.Tests => vNext/test/BetterModules.Core.Tests}/DataAccess/PredicateBuilderTests.cs (100%) diff --git a/vNext/src/BetterModules.Sample.Module/BetterModules.Sample.Module.xproj b/vNext/src/BetterModules.Sample.Module/BetterModules.Sample.Module.xproj index 63699af..8becb57 100644 --- a/vNext/src/BetterModules.Sample.Module/BetterModules.Sample.Module.xproj +++ b/vNext/src/BetterModules.Sample.Module/BetterModules.Sample.Module.xproj @@ -15,7 +15,7 @@ 2.0 - False + True \ No newline at end of file diff --git a/vNext/test/BetterModules.Core.Tests/BetterModules.Core.Tests.xproj b/vNext/test/BetterModules.Core.Tests/BetterModules.Core.Tests.xproj index ed010af..e0e3f78 100644 --- a/vNext/test/BetterModules.Core.Tests/BetterModules.Core.Tests.xproj +++ b/vNext/test/BetterModules.Core.Tests/BetterModules.Core.Tests.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 00b11517-daeb-43aa-b826-b2aa545ae166 @@ -12,9 +11,11 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 + + + - + \ No newline at end of file diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs b/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs similarity index 100% rename from BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs rename to vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs b/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs similarity index 100% rename from BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs rename to vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/EagerFetchTests.cs diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsTests.cs b/vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsTests.cs similarity index 100% rename from BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsTests.cs rename to vNext/test/BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsTests.cs diff --git a/BetterModules.Core.Tests/DataAccess/PredicateBuilderTests.cs b/vNext/test/BetterModules.Core.Tests/DataAccess/PredicateBuilderTests.cs similarity index 100% rename from BetterModules.Core.Tests/DataAccess/PredicateBuilderTests.cs rename to vNext/test/BetterModules.Core.Tests/DataAccess/PredicateBuilderTests.cs diff --git a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs index 41ee5af..9dc765a 100644 --- a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyLoaderTests.cs @@ -1,60 +1,60 @@ using System.Linq; using System.Reflection; using BetterModules.Core.Environment.Assemblies; -using NUnit.Framework; +using Microsoft.Framework.Logging; +using Xunit; namespace BetterModules.Core.Tests.Environment.Assemblies { - [TestFixture] - public class DefaultAssemblyLoaderTests : TestBase + public class DefaultAssemblyLoaderTests { - [Test] + [Fact] public void ShouldLoad_Assembly_FileByStringName() { - var loader = new DefaultAssemblyLoader(); + var loader = new DefaultAssemblyLoader(new LoggerFactory()); var assembly = loader.LoadFromFile("BetterModules.Sample.Module.dll"); - Assert.IsNotNull(assembly); - Assert.IsTrue(assembly.FullName.StartsWith("BetterModules.Sample.Module")); + Assert.NotNull(assembly); + Assert.True(assembly.FullName.StartsWith("BetterModules.Sample.Module")); } - [Test] + [Fact] public void ShouldLoad_Assembly_FileByAssemblyName() { - var loader = new DefaultAssemblyLoader(); + var loader = new DefaultAssemblyLoader(new LoggerFactory()); var assemblyName = AssemblyName.GetAssemblyName("BetterModules.Sample.Module.dll"); var assembly = loader.Load(assemblyName); - Assert.IsNotNull(assembly); - Assert.IsTrue(assembly.FullName.StartsWith("BetterModules.Sample.Module")); + Assert.NotNull(assembly); + Assert.True(assembly.FullName.StartsWith("BetterModules.Sample.Module")); } - [Test] + [Fact] public void ShouldLoad_Assembly_GetLoadableTypes() { var type = GetType(); var assembly = type.Assembly; - var loader = new DefaultAssemblyLoader(); + var loader = new DefaultAssemblyLoader(new LoggerFactory()); var types = loader.GetLoadableTypes(assembly); - Assert.IsNotNull(types); - Assert.Greater(types.Count(), 1); - Assert.IsTrue(types.Contains(GetType())); + Assert.NotNull(types); + Assert.True(types.Any()); + Assert.True(types.Contains(GetType())); } - [Test] - public void ShouldLoad_Assembly_GetLoadableTypes_Generic() - { - var type = GetType(); - var assembly = type.Assembly; - var loader = new DefaultAssemblyLoader(); - var testBaseType = typeof(TestBase); - var types = loader.GetLoadableTypes(assembly, testBaseType); - - Assert.IsNotNull(types); - Assert.Greater(types.Count(), 1); - Assert.IsTrue(types.Contains(GetType())); - Assert.IsTrue(types.All(testBaseType.IsAssignableFrom)); - } + //[Fact] + //public void ShouldLoad_Assembly_GetLoadableTypes_Generic() + //{ + // var type = GetType(); + // var assembly = type.Assembly; + // var loader = new DefaultAssemblyLoader(new LoggerFactory()); + // var testBaseType = typeof(TestBase); + // var types = loader.GetLoadableTypes(assembly, testBaseType); + + // Assert.IsNotNull(types); + // Assert.Greater(types.Count(), 1); + // Assert.IsTrue(types.Contains(GetType())); + // Assert.IsTrue(types.All(testBaseType.IsAssignableFrom)); + //} } } diff --git a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyManagerTests.cs b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyManagerTests.cs index 53b1129..a84b2f1 100644 --- a/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyManagerTests.cs +++ b/vNext/test/BetterModules.Core.Tests/Environment/Assemblies/DefaultAssemblyManagerTests.cs @@ -6,20 +6,23 @@ using BetterModules.Core.Environment.Assemblies; using BetterModules.Core.Environment.FileSystem; using BetterModules.Core.Modules.Registration; +using Microsoft.Dnx.Runtime; +using Microsoft.Framework.Logging; using Moq; -using NUnit.Framework; +using Xunit; +using IAssemblyLoader = BetterModules.Core.Environment.Assemblies.IAssemblyLoader; namespace BetterModules.Core.Tests.Environment.Assemblies { - [TestFixture] - public class DefaultAssemblyManagerTests : TestBase + public class DefaultAssemblyManagerTests { - [Test] + [Fact] public void ShouldAddReferencedModulesCorrectly() { var registrationMock = new Mock(); var assemblyLoaderMock = new Mock(); var workingDirectoryMock = new Mock(); + var libraryManegerMock = new Mock(); var allAssemblies = new List(); @@ -37,22 +40,23 @@ public void ShouldAddReferencedModulesCorrectly() } }); - var manager = new DefaultAssemblyManager(workingDirectoryMock.Object, registrationMock.Object, assemblyLoaderMock.Object); + var manager = new DefaultAssemblyManager(workingDirectoryMock.Object, registrationMock.Object, assemblyLoaderMock.Object, libraryManegerMock.Object, new LoggerFactory()); manager.AddReferencedModules(); - Assert.IsTrue(allAssemblies.Any(a => a.Contains("BetterModules.Sample.Module"))); + Assert.True(allAssemblies.Any(a => a.Contains("BetterModules.Sample.Module"))); } /// /// Should retrieve the lists of modules from working directory, copy them to bin folder /// and load them using assembly loader /// - [Test] + [Fact] public void ShouldAddUploadedModulesCorrectly() { var registrationMock = new Mock(); var assemblyLoaderMock = new Mock(); var workingDirectoryMock = new Mock(); + var libraryManegerMock = new Mock(); var assemblyLoaded = false; var assemblyCopied = false; @@ -61,14 +65,14 @@ public void ShouldAddUploadedModulesCorrectly() workingDirectoryMock .Setup(d => d.GetAvailableModules()) .Returns(() => files); - + workingDirectoryMock .Setup(d => d.RecopyModulesToRuntimeFolder(It.IsAny())) .Returns( file => { assemblyCopied = true; - Assert.AreEqual(files[0], file); + Assert.Equal(files[0], file); return file; }); @@ -79,14 +83,14 @@ public void ShouldAddUploadedModulesCorrectly() file => { assemblyLoaded = true; - Assert.AreEqual(file.Name, "ClassLibrary1"); - } ); + Assert.Equal(file.Name, "ClassLibrary1"); + }); - var manager = new DefaultAssemblyManager(workingDirectoryMock.Object, registrationMock.Object, assemblyLoaderMock.Object); + var manager = new DefaultAssemblyManager(workingDirectoryMock.Object, registrationMock.Object, assemblyLoaderMock.Object, libraryManegerMock.Object, new LoggerFactory()); manager.AddUploadedModules(); - Assert.IsTrue(assemblyLoaded); - Assert.IsTrue(assemblyCopied); + Assert.True(assemblyLoaded); + Assert.True(assemblyCopied); } } } diff --git a/vNext/test/BetterModules.Core.Tests/project.json b/vNext/test/BetterModules.Core.Tests/project.json index 04c68d3..de14535 100644 --- a/vNext/test/BetterModules.Core.Tests/project.json +++ b/vNext/test/BetterModules.Core.Tests/project.json @@ -1,22 +1,24 @@ { - "version": "1.0.0-*", - "description": "BetterModules.Core.Tests Class Library", - "authors": [ "user" ], - "tags": [ "" ], - "projectUrl": "", - "licenseUrl": "", + "version": "1.0.0-*", + "description": "BetterModules.Core.Tests Class Library", + "authors": [ "user" ], + "tags": [ "" ], + "projectUrl": "", + "licenseUrl": "", "dependencies": { - "System.Collections": "4.0.10-beta-23109", - "System.Linq": "4.0.0-beta-23109", - "System.Threading": "4.0.10-beta-23109", - "System.Runtime": "4.0.10-beta-23109", - "Microsoft.CSharp": "4.0.0-beta-23109", "xunit": "2.1.0", - "xunit.runner.dnx": "2.1.0-beta5a-build188" + "xunit.runner.dnx": "2.1.0-beta5a-build188", + "BetterModules.Core": "1.0.0-*", + "BetterModules.Sample.Module": "1.0.0-*", + "Moq": "4.2.1506.2515" }, - "frameworks": { - "dnx451": { } - } -} + "commands": { + "test": "xunit.runner.dnx" + }, + + "frameworks": { + "dnx451": { } + } +} \ No newline at end of file