From 3e60396948fb5ed019bf971cba5fc2c2776c5e80 Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sun, 10 Nov 2019 20:50:31 +0200 Subject: [PATCH 01/11] added unit tests to userservice Created tests using xunit and moq --- Tests/Properties/AssemblyInfo.cs | 20 + Tests/Tests.csproj | 544 +++++++++++++++++++ Tests/UnitTest1.cs | 45 ++ Tests/app.config | 95 ++++ Tests/packages.config | 154 ++++++ UnitTests/Properties/AssemblyInfo.cs | 20 + UnitTests/UnitTest1.cs | 29 + UnitTests/UnitTests.csproj | 84 +++ UnitTests/packages.config | 10 + uthTrip.BLL/Interfaces/IUserService.cs | 2 + uthTrip.BLL/Services/UserService.cs | 58 +- uthTrip.Tests/UnitTest1.cs | 257 +++++---- uthTrip.Tests/packages.config | 7 + uthTrip.Tests/uthTrip.Tests.csproj | 34 ++ uthTripProject.sln | 10 +- uthTripProject/Controllers/FaqController.cs | 27 + uthTripProject/Controllers/UserController.cs | 23 + uthTripProject/UnitTest/Test.cs | 161 ++++++ uthTripProject/Web.config | 250 ++++++++- uthTripProject/packages.config | 15 +- uthTripProject/uthTripProject.csproj | 45 +- 21 files changed, 1753 insertions(+), 137 deletions(-) create mode 100644 Tests/Properties/AssemblyInfo.cs create mode 100644 Tests/Tests.csproj create mode 100644 Tests/UnitTest1.cs create mode 100644 Tests/app.config create mode 100644 Tests/packages.config create mode 100644 UnitTests/Properties/AssemblyInfo.cs create mode 100644 UnitTests/UnitTest1.cs create mode 100644 UnitTests/UnitTests.csproj create mode 100644 UnitTests/packages.config create mode 100644 uthTripProject/Controllers/FaqController.cs create mode 100644 uthTripProject/UnitTest/Test.cs diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d6e6f8c --- /dev/null +++ b/Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("ddc86d49-c599-4782-b3e4-d66167bac90f")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj new file mode 100644 index 0000000..ce0f36a --- /dev/null +++ b/Tests/Tests.csproj @@ -0,0 +1,544 @@ + + + + + + + + + + + Debug + AnyCPU + {DDC86D49-C599-4782-B3E4-D66167BAC90F} + Library + Properties + Tests + Tests + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll + + + ..\packages\Microsoft.AspNetCore.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll + + + ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll + + + ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll + + + ..\packages\Microsoft.AspNetCore.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ApiExplorer.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ApiExplorer.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.RazorPages.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.TagHelpers.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll + + + ..\packages\Microsoft.AspNetCore.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Language.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Language.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Runtime.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll + + + ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Routing.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll + + + ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview2.19523.17\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.CodeAnalysis.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.dll + + + ..\packages\Microsoft.CodeAnalysis.CSharp.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll + + + ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + + + ..\packages\Microsoft.CodeAnalysis.Razor.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.CodeAnalysis.Razor.dll + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll + + + + ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview2.19525.4\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview2.19525.4\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Composite.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Composite.dll + + + ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll + + + ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll + + + ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll + + + ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Core.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Core.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Templating.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Templating.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Utils.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Utils.dll + + + ..\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.dll + + + ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Newtonsoft.Json.Bson.1.0.1\lib\net45\Newtonsoft.Json.Bson.dll + + + ..\packages\NuGet.Frameworks.4.7.0\lib\net46\NuGet.Frameworks.dll + + + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + ..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + + + ..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + + + ..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + + + ..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + + + ..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + True + + + + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + True + + + ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + True + True + + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + True + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + + ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll + + + + ..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + True + True + + + + ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + True + True + + + + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + True + + + ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + True + True + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + True + True + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + True + True + + + ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll + + + + + + + + + + + + + + + + + + {edec0e39-cc42-426b-8773-f9356ba20df9} + uthTrip.BLL + + + {f78c2ccb-0aa4-48f9-8dc1-9f65a5135e05} + uthTrip.DAL + + + {32e72533-0bdc-440a-9540-af7783555306} + uthTripProject + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs new file mode 100644 index 0000000..7c33807 --- /dev/null +++ b/Tests/UnitTest1.cs @@ -0,0 +1,45 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Linq; +//using Microsoft.AspNetCore.Mvc; +using uthTrip.BLL.Services; +using uthTrip.DAL.Interfaces; +using uthTrip.BLL.Interfaces; +using Moq; +using Xunit; +using uthTripProject.Controllers; +using System.Web; +namespace Tests +{ + + public class UnitTest1 + { + [Fact] + public void Index_View_Result() + { + // Setup + var expectedUserAccountCount = 2; + + var mockUserAccountService = new Mock(); + + mockUserAccountService.Setup(x => x.GetAll()) + .Returns(GetTestUserAccounts()); + + // Inject + var homeController = new UserController(mockUserAccountService.Object); + + // Act + var result = homeController.Index(); + + // Assert + var viewResult = Assert.IsType(result); + + var model = Assert.IsAssignableFrom>( + viewResult.ViewData.Model); + + Assert.Equal(expectedUserAccountCount, model.Count()); + } + + } +} diff --git a/Tests/app.config b/Tests/app.config new file mode 100644 index 0000000..9ccae07 --- /dev/null +++ b/Tests/app.config @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/packages.config b/Tests/packages.config new file mode 100644 index 0000000..4a68283 --- /dev/null +++ b/Tests/packages.config @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bffcdc5 --- /dev/null +++ b/UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("4a5a0491-90e9-42ef-9f0d-cf980a763af7")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTests/UnitTest1.cs b/UnitTests/UnitTest1.cs new file mode 100644 index 0000000..1368e4e --- /dev/null +++ b/UnitTests/UnitTest1.cs @@ -0,0 +1,29 @@ +//using System; +//using Microsoft.VisualStudio.TestTools.UnitTesting; +//using System.Web.Mvc; +//using Moq; +//namespace UnitTests +//{ +// [TestClass] +// public class UnitTest1 +// { +// [TestMethod] +// public void Sum_Products_Correctly() +// { +// // Arrange (добавляем имитированный объект) +// Mock mock = new Mock(); +// mock.Setup(m => m.GetAll()); + +// UserController controller = new UserController(mock.Object); +// string expected = "В базе данных 1 объект"; + +// // Act +// controller.Index(); +// ViewResult result = controller.Index() as ViewResult; +// string actual = result.ViewBag.Message as string; + +// // Assert +// Assert.AreEqual(expected, actual); +// } +// } +//} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj new file mode 100644 index 0000000..259885b --- /dev/null +++ b/UnitTests/UnitTests.csproj @@ -0,0 +1,84 @@ + + + + + + Debug + AnyCPU + {4A5A0491-90E9-42EF-9F0D-CF980A763AF7} + Library + Properties + UnitTests + UnitTests + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + + + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.Web.Mvc.Extensions.1.1.1.2\lib\net45\System.Web.Mvc.Extensions.dll + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/UnitTests/packages.config b/UnitTests/packages.config new file mode 100644 index 0000000..ac38aa6 --- /dev/null +++ b/UnitTests/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.BLL/Interfaces/IUserService.cs b/uthTrip.BLL/Interfaces/IUserService.cs index ba5bc26..ba846d6 100644 --- a/uthTrip.BLL/Interfaces/IUserService.cs +++ b/uthTrip.BLL/Interfaces/IUserService.cs @@ -12,6 +12,8 @@ public interface IUserService { void CreateUser(UserDTO userDto); UserDTO GetById(int? id); + UserDTO Get(int userAccountId); + string GetFirstName(int userAccountId); UserDTO GetByUsernamePassword(string username, string password); IEnumerable GetAll(); void Dispose(int id); diff --git a/uthTrip.BLL/Services/UserService.cs b/uthTrip.BLL/Services/UserService.cs index ccb2533..7551f3d 100644 --- a/uthTrip.BLL/Services/UserService.cs +++ b/uthTrip.BLL/Services/UserService.cs @@ -6,6 +6,7 @@ using uthTrip.BLL.Infrastructure; using uthTrip.BLL.Interfaces; using System.Collections.Generic; +using System.Linq; using AutoMapper; namespace uthTrip.BLL.Services @@ -39,6 +40,23 @@ public void CreateUser(UserDTO userDto) Database.Users.Create(user); Database.Save(); } + + public string GetFirstName(int userAccountId) + { + var result = GetAllUsers() + .Where(x => x.User_ID == userAccountId) + .Select(x => x.First_Name) + .FirstOrDefault(); + + return result; + } + public UserDTO Get(int userAccountId) + { + var userAccount = GetAllUsers() + .FirstOrDefault(x => x.User_ID == userAccountId); + + return userAccount; + } //public int Authenticate(string username, string password) //{ // if (string.IsNullOrEmpty(username)) @@ -62,7 +80,7 @@ public void CreateUser(UserDTO userDto) // return user.Id; //} - + public UserDTO GetById(int? id) { @@ -113,5 +131,41 @@ public UserDTO GetByUsernamePassword(string username, string password) return null; } } + private List GetAllUsers() + { + DateTime somedate = new DateTime(2000, 07, 21); + return new List() + { + + + + new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email= "simongilbert@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "some boy" + + }, + new UserDTO + { + User_ID = 456, + First_Name = "Alexander", + Last_Name = "Hill", + Username = "alexhill", + Email= "alexhill@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "anpther boy" + }, + }; + } + } } -} + diff --git a/uthTrip.Tests/UnitTest1.cs b/uthTrip.Tests/UnitTest1.cs index 6784f6b..4b1d1be 100644 --- a/uthTrip.Tests/UnitTest1.cs +++ b/uthTrip.Tests/UnitTest1.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; -using NUnit.Framework; +//using NUnit.Framework; using uthTrip.BLL.Services; using uthTrip.BLL.Interfaces; using uthTripProject.Models; @@ -10,125 +10,148 @@ using uthTrip.DAL.EF; using uthTrip.DAL.Repositories; using uthTrip.BLL.DTO; +using uthTrip.DAL.Entities; using uthTrip.BLL.Infrastructure; +using uthTripProject.Controllers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Web.Mvc; +using Moq; namespace uthTrip.Tests { - public class UnitTest1 - { - readonly string testConnectionString = "Initial Catalog=UthTripDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; - UserService CreateUserService() - { - return new UserService( - new EFUnitOfWork( - new uthtripContext(testConnectionString) - ) - ); - } - - [TearDown] - public void ClearDB() - { - var context = new uthtripContext(testConnectionString); - context.Users.RemoveRange(context.Users); - context.SaveChanges(); - } - - [Test] - public void CreateTest() - { - var userService = CreateUserService(); - - DateTime somedate = new DateTime(2000, 07, 21); - - UserDTO usermodel = new UserDTO(); - usermodel.User_ID = 2; - usermodel.First_Name = "Nadia"; - usermodel.Last_Name = "Padalka"; - usermodel.Email = "nadiapadalka@gmail.com"; - usermodel.Username = "nadiapadalka"; - usermodel.Password = "1111"; - usermodel.Birthday = somedate; - usermodel.Photo_Url = "www"; - usermodel.Info = "super girl"; - userService.CreateUser(usermodel); - - var user = userService.GetAll().SingleOrDefault(); - Assert.AreEqual("Nadia", user.First_Name); - } - - [Test] - public void DeleteUser() - { - var userService = CreateUserService(); - - DateTime somedate = new DateTime(2000, 07, 21); - - UserDTO usermodel = new UserDTO(); - usermodel.User_ID = 2; - usermodel.First_Name = "Nadia"; - usermodel.Last_Name = "Padalka"; - usermodel.Email = "nadiapadalka@gmail.com"; - usermodel.Username = "nadiapadalka"; - usermodel.Password = "1111"; - usermodel.Birthday = somedate; - usermodel.Photo_Url = "www"; - usermodel.Info = "super girl"; - userService.CreateUser(usermodel); - - var user = userService.GetAll().SingleOrDefault(); - - userService.Dispose(user.User_ID); - Assert.AreEqual(0, userService.GetAll().Count()); - } - - - - [Test] - public void GetByIdTest() - { - var userService = CreateUserService(); - - DateTime somedate = new DateTime(2000, 07, 21); - - UserDTO usermodel = new UserDTO(); - usermodel.User_ID = 2; - usermodel.First_Name = "Nadia"; - usermodel.Last_Name = "Padalka"; - usermodel.Email = "nadiapadalka@gmail.com"; - usermodel.Username = "nadiapadalka"; - usermodel.Password = "1111"; - usermodel.Birthday = somedate; - usermodel.Photo_Url = "www"; - usermodel.Info = "super girl"; - userService.CreateUser(usermodel); - var user = userService.GetAll().FirstOrDefault(); - Assert.NotNull(userService.GetById(user.User_ID)); - } - - [Test] - public void GetAll() - { - var userService = CreateUserService(); - - DateTime somedate = new DateTime(2000, 07, 21); - - UserDTO usermodel = new UserDTO(); - usermodel.User_ID = 2; - usermodel.First_Name = "Nadia"; - usermodel.Last_Name = "Padalka"; - usermodel.Email = "nadiapadalka@gmail.com"; - usermodel.Username = "nadiapadalka"; - usermodel.Password = "1111"; - usermodel.Birthday = somedate; - usermodel.Photo_Url = "www"; - usermodel.Info = "super girl"; - userService.CreateUser(usermodel); - UserDTO user1 = new UserDTO(3, "Marichka", "Dymyd", "mariia@gmail.com", "mariicka", "1212", somedate, "www", "giirl"); - userService.CreateUser(user1); - - Assert.AreEqual(2, userService.GetAll().Count()); - } - } + // [TestClass] + // public class UnitTest1 + // { + // readonly string testConnectionString = "Initial Catalog=UthTripDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; + // UserService CreateUserService() + // { + // return new UserService( + // new EFUnitOfWork( + // new uthtripContext(testConnectionString) + // ) + // ); + // } + + // //[TearDown] + // //public void ClearDB() + // //{ + // // var context = new uthtripContext(testConnectionString); + // // context.Users.RemoveRange(context.Users); + // // context.SaveChanges(); + // //} + + // //[Test] + // //public void CreateTest() + // //{ + // // var userService = CreateUserService(); + + // // DateTime somedate = new DateTime(2000, 07, 21); + + // // UserDTO usermodel = new UserDTO(); + // // usermodel.User_ID = 2; + // // usermodel.First_Name = "Nadia"; + // // usermodel.Last_Name = "Padalka"; + // // usermodel.Email = "nadiapadalka@gmail.com"; + // // usermodel.Username = "nadiapadalka"; + // // usermodel.Password = "1111"; + // // usermodel.Birthday = somedate; + // // usermodel.Photo_Url = "www"; + // // usermodel.Info = "super girl"; + // // userService.CreateUser(usermodel); + + // // var user = userService.GetAll().SingleOrDefault(); + // // Assert.AreEqual("Nadia", user.First_Name); + // //} + // [TestMethod] + // public void Sum_Products_Correctly() + // { + // // Arrange (добавляем имитированный объект) + // Mock mock = new Mock(); + // mock.Setup(m => m.GetAll()); + + // UserController controller = new UserController(mock.Object); + // //string expected = "В базе данных 1 объект"; + + // // Act + + // ViewResult result = controller.Index() as ViewResult; + // string actual = result.ViewBag.Message as string; + + // // Assert + // Assert.IsNotNull(result.Model); + // } + // //[Test] + // //public void DeleteUser() + // //{ + // // var userService = CreateUserService(); + + // // DateTime somedate = new DateTime(2000, 07, 21); + + // // UserDTO usermodel = new UserDTO(); + // // usermodel.User_ID = 2; + // // usermodel.First_Name = "Nadia"; + // // usermodel.Last_Name = "Padalka"; + // // usermodel.Email = "nadiapadalka@gmail.com"; + // // usermodel.Username = "nadiapadalka"; + // // usermodel.Password = "1111"; + // // usermodel.Birthday = somedate; + // // usermodel.Photo_Url = "www"; + // // usermodel.Info = "super girl"; + // // userService.CreateUser(usermodel); + + // // var user = userService.GetAll().SingleOrDefault(); + + // // userService.Dispose(user.User_ID); + // // Assert.AreEqual(0, userService.GetAll().Count()); + // //} + + + + // //[Test] + // //public void GetByIdTest() + // //{ + // // var userService = CreateUserService(); + + // // DateTime somedate = new DateTime(2000, 07, 21); + + // // UserDTO usermodel = new UserDTO(); + // // usermodel.User_ID = 2; + // // usermodel.First_Name = "Nadia"; + // // usermodel.Last_Name = "Padalka"; + // // usermodel.Email = "nadiapadalka@gmail.com"; + // // usermodel.Username = "nadiapadalka"; + // // usermodel.Password = "1111"; + // // usermodel.Birthday = somedate; + // // usermodel.Photo_Url = "www"; + // // usermodel.Info = "super girl"; + // // userService.CreateUser(usermodel); + // // var user = userService.GetAll().FirstOrDefault(); + // // Assert.NotNull(userService.GetById(user.User_ID)); + // //} + + // //[Test] + // //public void GetAll() + // //{ + // // var userService = CreateUserService(); + + // // DateTime somedate = new DateTime(2000, 07, 21); + + // // UserDTO usermodel = new UserDTO(); + // // usermodel.User_ID = 2; + // // usermodel.First_Name = "Nadia"; + // // usermodel.Last_Name = "Padalka"; + // // usermodel.Email = "nadiapadalka@gmail.com"; + // // usermodel.Username = "nadiapadalka"; + // // usermodel.Password = "1111"; + // // usermodel.Birthday = somedate; + // // usermodel.Photo_Url = "www"; + // // usermodel.Info = "super girl"; + // // userService.CreateUser(usermodel); + // // UserDTO user1 = new UserDTO(3, "Marichka", "Dymyd", "mariia@gmail.com", "mariicka", "1212", somedate, "www", "giirl"); + // // userService.CreateUser(user1); + + // // Assert.AreEqual(2, userService.GetAll().Count()); + // //} + // } } \ No newline at end of file diff --git a/uthTrip.Tests/packages.config b/uthTrip.Tests/packages.config index c6b74cb..d3238c8 100644 --- a/uthTrip.Tests/packages.config +++ b/uthTrip.Tests/packages.config @@ -1,7 +1,14 @@  + + + + + + + \ No newline at end of file diff --git a/uthTrip.Tests/uthTrip.Tests.csproj b/uthTrip.Tests/uthTrip.Tests.csproj index 19e9a38..d3c1525 100644 --- a/uthTrip.Tests/uthTrip.Tests.csproj +++ b/uthTrip.Tests/uthTrip.Tests.csproj @@ -41,6 +41,9 @@ 4 + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.dll @@ -54,12 +57,40 @@ ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + + ..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + @@ -83,6 +114,9 @@ uthTripProject + + + diff --git a/uthTripProject.sln b/uthTripProject.sln index d47b408..afeeb6a 100644 --- a/uthTripProject.sln +++ b/uthTripProject.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.852 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.202 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTripProject", "uthTripProject\uthTripProject.csproj", "{32E72533-0BDC-440A-9540-AF7783555306}" EndProject @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.DAL", "uthTrip.DAL\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.BLL", "uthTrip.BLL\uthTrip.BLL.csproj", "{EDEC0E39-CC42-426B-8773-F9356BA20DF9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.Tests", "uthTrip.Tests\uthTrip.Tests.csproj", "{92D1958E-8110-402B-8A96-4C7FE9FFF0EC}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,10 +27,6 @@ Global {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.Build.0 = Release|Any CPU - {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/uthTripProject/Controllers/FaqController.cs b/uthTripProject/Controllers/FaqController.cs new file mode 100644 index 0000000..a58f1d2 --- /dev/null +++ b/uthTripProject/Controllers/FaqController.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; +//using System.Web.Mvc; +//namespace uthTripProject.Controllers +//{ +// public class FaqController : Controller +// { +// private readonly IFaqRepository _repository; +// public FaqController() : this(new FaqRepository()) { } +// public FaqController(IFaqRepository repository) +// { +// _repository = repository; +// } +// public ActionResult Index() +// { +// var records = _repository.GetAll(); +// var model = new FaqViewModel +// { +// FAQs = records +// }; +// return View(model); +// } +// } +//} diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index 6d68a7c..149f61c 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -21,11 +21,16 @@ public UserController(IUserService serv) { userService = serv; } + public ActionResult Index() { IEnumerable userDtos = userService.GetAll(); var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); var users = mapper.Map, List>(userDtos); + //var model = repo.GetComputerList(); + if (users.Count > 0) + ViewBag.Message = String.Format("В базі даних {0} об'єкт", users.Count); + return View(users); } [HttpGet] @@ -61,7 +66,25 @@ public ActionResult Login() { return View(); } + public ActionResult Account(int id) + { + var userAccount = userService.Get(id); + + var viewModel = new UserViewModel + { + User_ID = userAccount.User_ID, + First_Name = userAccount.First_Name, + Last_Name = userAccount.Last_Name, + Username = userAccount.Username, + Email = userAccount.Email, + Password = userAccount.Password, + Birthday = userAccount.Birthday, + Photo_Url = userAccount.Photo_Url, + Info = userAccount.Info + }; + return View(viewModel); + } [HttpPost] public ActionResult Login(UserViewModel userModel) { diff --git a/uthTripProject/UnitTest/Test.cs b/uthTripProject/UnitTest/Test.cs new file mode 100644 index 0000000..f983e55 --- /dev/null +++ b/uthTripProject/UnitTest/Test.cs @@ -0,0 +1,161 @@ +using System.Collections.Generic; +using System.Linq; +using System; +using Moq; +using uthTripProject.Controllers; +using uthTripProject.Models; +using uthTrip.BLL.Services; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; +using System.Web.Mvc; +using Xunit; + +namespace uthTripProject.Tests +{ + public class HomeControllerTests + { + DateTime somedate = new DateTime(2000, 07, 21); + + [Fact] + public void Index_View_Result() + { + // Setup + var expectedUserAccountCount = 2; + + var mockUserAccountService = new Mock(); + + mockUserAccountService.Setup(x => x.GetAll()) + .Returns(GetTestUserAccounts()); + + // Inject + var homeController = new UserController(mockUserAccountService.Object); + + // Act + var result = homeController.Index(); + + // Assert + var viewResult = Assert.IsType(result); + + var model = Assert.IsAssignableFrom>( + viewResult.ViewData.Model); + + Assert.Equal(expectedUserAccountCount, model.Count()); + } + + [Fact] + public void Account_View_Result_One() + { + // Setup + var expectedUserAccountId = 123; + + var mockUserAccountService = new Mock(); + + mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + .Returns(GetTestUserAccountOne()); + + // Inject + var homeController = new UserController(mockUserAccountService.Object); + + // Act + var result = homeController.Account(expectedUserAccountId); + + // Assert + var viewResult = Assert.IsType(result); + + var viewModel = Assert.IsAssignableFrom( + viewResult.ViewData.Model); + + Assert.Equal(expectedUserAccountId, viewModel.User_ID); + } + + [Fact] + public void Account_View_Result_Two() + { + // Setup + var expectedUserAccountId = 456; + + var mockUserAccountService = new Mock(); + + mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + .Returns(GetTestUserAccountTwo()); + + // Inject + var homeController = new UserController(mockUserAccountService.Object); + + // Act + var result = homeController.Account(expectedUserAccountId); + + // Assert + var viewResult = Assert.IsType(result); + + var viewModel = Assert.IsAssignableFrom( + viewResult.ViewData.Model); + + Assert.Equal(expectedUserAccountId, viewModel.User_ID); + } + + //[Fact] + //public void Get_First_Name_Result() + //{ + // // Setup + // var userAccountId = 123; + // var userAccountFirstName = "Simon"; + + // var mockUserAccountService = new Mock(); + + // mockUserAccountService.Setup(x => x.GetFirstName(userAccountId)) + // .Returns(userAccountFirstName); + + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); + + // // Act + // var result = homeController.ActionInvoker + + // // Assert + // Assert.Equal(userAccountFirstName, result); + //} + + private List GetTestUserAccounts() + { + return new List() + { + GetTestUserAccountOne(), + GetTestUserAccountTwo(), + }; + } + + private UserDTO GetTestUserAccountOne() + { + + return new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "some boy" + }; + } + + private UserDTO GetTestUserAccountTwo() + { + return new UserDTO + { + User_ID = 456, + First_Name = "Alexander", + Last_Name = "Hill", + Username = "alexhill", + Email = "alexhill@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "anpther boy" + }; + } + } +} diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index d832b55..7fa4b29 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -38,6 +38,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,4 +348,4 @@ - \ No newline at end of file + diff --git a/uthTripProject/packages.config b/uthTripProject/packages.config index 3d8b573..48a81f5 100644 --- a/uthTripProject/packages.config +++ b/uthTripProject/packages.config @@ -3,6 +3,7 @@ + @@ -24,17 +25,27 @@ + + - - + + + + + + + + + + \ No newline at end of file diff --git a/uthTripProject/uthTripProject.csproj b/uthTripProject/uthTripProject.csproj index 3dd27ed..b5a6050 100644 --- a/uthTripProject/uthTripProject.csproj +++ b/uthTripProject/uthTripProject.csproj @@ -1,7 +1,7 @@  - - + + @@ -51,7 +51,16 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\packages\Microsoft.VisualStudio.UnitTesting.11.0.50727.1\lib\net45\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -64,9 +73,6 @@ ..\packages\Ninject.MVC5.3.3.0\lib\net45\Ninject.Web.Mvc.dll - - ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - ..\packages\PagedList.1.17.0.0\lib\net40\PagedList.dll @@ -77,8 +83,14 @@ + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + @@ -138,6 +150,18 @@ True ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll + + ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll + @@ -196,6 +220,7 @@ + @@ -208,6 +233,7 @@ + @@ -306,6 +332,9 @@ uthTrip.BLL + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -339,9 +368,11 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnitTestProject1/packages.config b/UnitTestProject1/packages.config new file mode 100644 index 0000000..828fb10 --- /dev/null +++ b/UnitTestProject1/packages.config @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.BLL/App.config b/uthTrip.BLL/App.config index c5c407b..21d33da 100644 --- a/uthTrip.BLL/App.config +++ b/uthTrip.BLL/App.config @@ -1,4 +1,35 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.BLL/Interfaces/IUserService.cs b/uthTrip.BLL/Interfaces/IUserService.cs index ba846d6..2c180b9 100644 --- a/uthTrip.BLL/Interfaces/IUserService.cs +++ b/uthTrip.BLL/Interfaces/IUserService.cs @@ -12,9 +12,7 @@ public interface IUserService { void CreateUser(UserDTO userDto); UserDTO GetById(int? id); - UserDTO Get(int userAccountId); - string GetFirstName(int userAccountId); - UserDTO GetByUsernamePassword(string username, string password); + UserDTO GetByUsernamePassword(string username, string password); IEnumerable GetAll(); void Dispose(int id); int FindMaxId(); diff --git a/uthTrip.BLL/Services/UserService.cs b/uthTrip.BLL/Services/UserService.cs index 7551f3d..d9db319 100644 --- a/uthTrip.BLL/Services/UserService.cs +++ b/uthTrip.BLL/Services/UserService.cs @@ -7,8 +7,13 @@ using uthTrip.BLL.Interfaces; using System.Collections.Generic; using System.Linq; +using uthTrip.DAL.EF; + using AutoMapper; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + namespace uthTrip.BLL.Services { public class UserService : IUserService @@ -23,6 +28,7 @@ public UserService(IUnitOfWork uow) { Database = uow; } + public void CreateUser(UserDTO userDto) { User user = new User @@ -41,46 +47,6 @@ public void CreateUser(UserDTO userDto) Database.Save(); } - public string GetFirstName(int userAccountId) - { - var result = GetAllUsers() - .Where(x => x.User_ID == userAccountId) - .Select(x => x.First_Name) - .FirstOrDefault(); - - return result; - } - public UserDTO Get(int userAccountId) - { - var userAccount = GetAllUsers() - .FirstOrDefault(x => x.User_ID == userAccountId); - - return userAccount; - } - //public int Authenticate(string username, string password) - //{ - // if (string.IsNullOrEmpty(username)) - // { - // throw new Exception("Username is empty."); - // } - // else if (string.IsNullOrEmpty(password)) - // { - // throw new Exception("Password is empty."); - // } - - // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - // if (user == null) - // { - // throw new Exception("User with current name does not exist."); - // } - // else if (!VerifyHash(password, user.Hash)) - // { - // throw new Exception("Invalid password."); - // } - - // return user.Id; - //} - public UserDTO GetById(int? id) { @@ -131,41 +97,7 @@ public UserDTO GetByUsernamePassword(string username, string password) return null; } } - private List GetAllUsers() - { - DateTime somedate = new DateTime(2000, 07, 21); - return new List() - { - - - new UserDTO - { - User_ID = 123, - First_Name = "Simon", - Last_Name = "Gilbert", - Username = "simongilbert", - Email= "simongilbert@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "some boy" - - }, - new UserDTO - { - User_ID = 456, - First_Name = "Alexander", - Last_Name = "Hill", - Username = "alexhill", - Email= "alexhill@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "anpther boy" - }, - }; - } } } diff --git a/uthTrip.BLL/packages.config b/uthTrip.BLL/packages.config index f2f5f08..f66e532 100644 --- a/uthTrip.BLL/packages.config +++ b/uthTrip.BLL/packages.config @@ -1,5 +1,29 @@  + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.BLL/uthTrip.BLL.csproj b/uthTrip.BLL/uthTrip.BLL.csproj index e704b66..741c879 100644 --- a/uthTrip.BLL/uthTrip.BLL.csproj +++ b/uthTrip.BLL/uthTrip.BLL.csproj @@ -34,14 +34,84 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll + + + ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + diff --git a/uthTrip.DAL/App.config b/uthTrip.DAL/App.config index 288b373..bac9f49 100644 --- a/uthTrip.DAL/App.config +++ b/uthTrip.DAL/App.config @@ -12,4 +12,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.DAL/EF/uthtripContext.cs b/uthTrip.DAL/EF/uthtripContext.cs index 80e3c4c..2090a5e 100644 --- a/uthTrip.DAL/EF/uthtripContext.cs +++ b/uthTrip.DAL/EF/uthtripContext.cs @@ -1,10 +1,12 @@ namespace uthTrip.DAL.EF { using System; - using System.Data.Entity; + //using System.Data.Entity; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using uthTrip.DAL.Entities; + using Microsoft.EntityFrameworkCore; + public partial class uthtripContext : DbContext { @@ -14,10 +16,12 @@ public uthtripContext(string conString) { connectionString = conString; } - public uthtripContext() - : base("name=uthtripContext") - { - } + //public uthtripContext() { } + public uthtripContext(DbContextOptions options) : base(options) { } + //public uthtripContext() + // : base("name=uthtripContext") + //{ + //} public virtual DbSet Blocked_Users { get; set; } public virtual DbSet Dates_ranges { get; set; } @@ -28,101 +32,101 @@ public uthtripContext() public virtual DbSet Trips { get; set; } public virtual DbSet Users { get; set; } - protected override void OnModelCreating(DbModelBuilder modelBuilder) - { - modelBuilder.Entity() - .HasMany(e => e.Trips) - .WithRequired(e => e.Dates_ranges) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .Property(e => e.Country) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.City) - .IsUnicode(false); - - modelBuilder.Entity() - .HasMany(e => e.Trips) - .WithRequired(e => e.Destination) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .Property(e => e.Review1) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Title) - .IsUnicode(false); - - modelBuilder.Entity() - .HasMany(e => e.Rights) - .WithRequired(e => e.Role) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .Property(e => e.Trip_Title) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Description) - .IsUnicode(false); - - modelBuilder.Entity() - .HasMany(e => e.Reviews) - .WithRequired(e => e.Trip) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .HasMany(e => e.Rights) - .WithRequired(e => e.Trip) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .Property(e => e.First_Name) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Last_Name) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Email) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Username) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Password) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Photo_Url) - .IsUnicode(false); - - modelBuilder.Entity() - .Property(e => e.Info) - .IsUnicode(false); - - modelBuilder.Entity() - .HasMany(e => e.Reviews) - .WithRequired(e => e.User) - .HasForeignKey(e => e.Writer_ID) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .HasMany(e => e.Rights) - .WithRequired(e => e.User) - .WillCascadeOnDelete(false); - - modelBuilder.Entity() - .HasMany(e => e.Trips) - .WithRequired(e => e.User) - .HasForeignKey(e => e.Creator_ID) - .WillCascadeOnDelete(false); - } + //// protected override void OnModelCreating(DbModelBuilder modelBuilder) + // { + // modelBuilder.Entity() + // .HasMany(e => e.Trips) + // .WithRequired(e => e.Dates_ranges) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .Property(e => e.Country) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.City) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Trips) + // .WithRequired(e => e.Destination) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .Property(e => e.Review1) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Title) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Rights) + // .WithRequired(e => e.Role) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .Property(e => e.Trip_Title) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Description) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Reviews) + // .WithRequired(e => e.Trip) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Rights) + // .WithRequired(e => e.Trip) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .Property(e => e.First_Name) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Last_Name) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Email) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Username) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Password) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Photo_Url) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .Property(e => e.Info) + // .IsUnicode(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Reviews) + // .WithRequired(e => e.User) + // .HasForeignKey(e => e.Writer_ID) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Rights) + // .WithRequired(e => e.User) + // .WillCascadeOnDelete(false); + + // modelBuilder.Entity() + // .HasMany(e => e.Trips) + // .WithRequired(e => e.User) + // .HasForeignKey(e => e.Creator_ID) + // .WillCascadeOnDelete(false); + // } } } diff --git a/uthTrip.DAL/Repositories/BlockedUserRepository.cs b/uthTrip.DAL/Repositories/BlockedUserRepository.cs index 21ade9f..5790495 100644 --- a/uthTrip.DAL/Repositories/BlockedUserRepository.cs +++ b/uthTrip.DAL/Repositories/BlockedUserRepository.cs @@ -6,7 +6,8 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +//using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/DateRangeRepository.cs b/uthTrip.DAL/Repositories/DateRangeRepository.cs index 002d381..29b8cda 100644 --- a/uthTrip.DAL/Repositories/DateRangeRepository.cs +++ b/uthTrip.DAL/Repositories/DateRangeRepository.cs @@ -6,7 +6,8 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; +//using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/DestinationRepository.cs b/uthTrip.DAL/Repositories/DestinationRepository.cs index 0c4ea80..8126fdc 100644 --- a/uthTrip.DAL/Repositories/DestinationRepository.cs +++ b/uthTrip.DAL/Repositories/DestinationRepository.cs @@ -6,7 +6,8 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +//using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/EFUnitOfWork.cs b/uthTrip.DAL/Repositories/EFUnitOfWork.cs index 7da1a21..015532e 100644 --- a/uthTrip.DAL/Repositories/EFUnitOfWork.cs +++ b/uthTrip.DAL/Repositories/EFUnitOfWork.cs @@ -26,6 +26,7 @@ public EFUnitOfWork(string connectionString) { db = new uthtripContext(connectionString); } + public IRepository Users { get diff --git a/uthTrip.DAL/Repositories/ReviewRepository.cs b/uthTrip.DAL/Repositories/ReviewRepository.cs index a294fe0..4a4669a 100644 --- a/uthTrip.DAL/Repositories/ReviewRepository.cs +++ b/uthTrip.DAL/Repositories/ReviewRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/RightRepository.cs b/uthTrip.DAL/Repositories/RightRepository.cs index 1568729..6b96819 100644 --- a/uthTrip.DAL/Repositories/RightRepository.cs +++ b/uthTrip.DAL/Repositories/RightRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/RoleRepository.cs b/uthTrip.DAL/Repositories/RoleRepository.cs index 785a03e..3bbfdb0 100644 --- a/uthTrip.DAL/Repositories/RoleRepository.cs +++ b/uthTrip.DAL/Repositories/RoleRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/TripRepository.cs b/uthTrip.DAL/Repositories/TripRepository.cs index 374a659..32ccb4b 100644 --- a/uthTrip.DAL/Repositories/TripRepository.cs +++ b/uthTrip.DAL/Repositories/TripRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/UserRepository.cs b/uthTrip.DAL/Repositories/UserRepository.cs index c3f1d5a..21af98c 100644 --- a/uthTrip.DAL/Repositories/UserRepository.cs +++ b/uthTrip.DAL/Repositories/UserRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using System.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/packages.config b/uthTrip.DAL/packages.config index 2cd2314..3e1a073 100644 --- a/uthTrip.DAL/packages.config +++ b/uthTrip.DAL/packages.config @@ -1,4 +1,28 @@  + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.DAL/uthTrip.DAL.csproj b/uthTrip.DAL/uthTrip.DAL.csproj index 1e26807..63be2f3 100644 --- a/uthTrip.DAL/uthTrip.DAL.csproj +++ b/uthTrip.DAL/uthTrip.DAL.csproj @@ -40,11 +40,81 @@ ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll + + + ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + diff --git a/uthTripProject.sln b/uthTripProject.sln index afeeb6a..410b14c 100644 --- a/uthTripProject.sln +++ b/uthTripProject.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.DAL", "uthTrip.DAL\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.BLL", "uthTrip.BLL\uthTrip.BLL.csproj", "{EDEC0E39-CC42-426B-8773-F9356BA20DF9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{8B8D5CC4-86F5-4793-89EB-296325CA02F9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.Build.0 = Release|Any CPU + {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index 149f61c..94940e3 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -66,10 +66,11 @@ public ActionResult Login() { return View(); } - public ActionResult Account(int id) - { - var userAccount = userService.Get(id); + //public ActionResult Account(int id) + //{ + // var userAccount = userService.Get(id); +<<<<<<< Updated upstream var viewModel = new UserViewModel { User_ID = userAccount.User_ID, @@ -82,9 +83,23 @@ public ActionResult Account(int id) Photo_Url = userAccount.Photo_Url, Info = userAccount.Info }; +======= + // var viewModel = new UserViewModel + // { + // User_ID = userAccount.User_ID, + // First_Name = userAccount.First_Name, + // Last_Name = userAccount.Last_Name, + // Username = userAccount.Username, + // Email = userAccount.Email, + // Password = userAccount.Password, + // Birthday = userAccount.Birthday, + // Photo_Url = userAccount.Photo_Url, + // Info = userAccount.Info + // }; +>>>>>>> Stashed changes - return View(viewModel); - } + // return View(viewModel); + //} [HttpPost] public ActionResult Login(UserViewModel userModel) { diff --git a/uthTripProject/UnitTest/Test.cs b/uthTripProject/UnitTest/Test.cs index f983e55..1844ca6 100644 --- a/uthTripProject/UnitTest/Test.cs +++ b/uthTripProject/UnitTest/Test.cs @@ -43,56 +43,56 @@ public void Index_View_Result() } [Fact] - public void Account_View_Result_One() - { - // Setup - var expectedUserAccountId = 123; + //public void Account_View_Result_One() + //{ + // // Setup + // var expectedUserAccountId = 123; - var mockUserAccountService = new Mock(); + // var mockUserAccountService = new Mock(); - mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - .Returns(GetTestUserAccountOne()); + // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + // .Returns(GetTestUserAccountOne()); - // Inject - var homeController = new UserController(mockUserAccountService.Object); + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); - // Act - var result = homeController.Account(expectedUserAccountId); + // // Act + // var result = homeController.Account(expectedUserAccountId); - // Assert - var viewResult = Assert.IsType(result); + // // Assert + // var viewResult = Assert.IsType(result); - var viewModel = Assert.IsAssignableFrom( - viewResult.ViewData.Model); + // var viewModel = Assert.IsAssignableFrom( + // viewResult.ViewData.Model); - Assert.Equal(expectedUserAccountId, viewModel.User_ID); - } + // Assert.Equal(expectedUserAccountId, viewModel.User_ID); + //} - [Fact] - public void Account_View_Result_Two() - { - // Setup - var expectedUserAccountId = 456; + //[Fact] + //public void Account_View_Result_Two() + //{ + // // Setup + // var expectedUserAccountId = 456; - var mockUserAccountService = new Mock(); + // var mockUserAccountService = new Mock(); - mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - .Returns(GetTestUserAccountTwo()); + // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + // .Returns(GetTestUserAccountTwo()); - // Inject - var homeController = new UserController(mockUserAccountService.Object); + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); - // Act - var result = homeController.Account(expectedUserAccountId); + // // Act + // var result = homeController.Account(expectedUserAccountId); - // Assert - var viewResult = Assert.IsType(result); + // // Assert + // var viewResult = Assert.IsType(result); - var viewModel = Assert.IsAssignableFrom( - viewResult.ViewData.Model); + // var viewModel = Assert.IsAssignableFrom( + // viewResult.ViewData.Model); - Assert.Equal(expectedUserAccountId, viewModel.User_ID); - } + // Assert.Equal(expectedUserAccountId, viewModel.User_ID); + //} //[Fact] //public void Get_First_Name_Result() diff --git a/uthTripProject/Views/Account/EditData.cshtml b/uthTripProject/Views/Account/EditData.cshtml new file mode 100644 index 0000000..7cf47ae --- /dev/null +++ b/uthTripProject/Views/Account/EditData.cshtml @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace uthTripProject.Views.Account +{ + interface EditData + { + } +} diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index 7fa4b29..83b7f6c 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -334,6 +334,18 @@ + + + + + + + + + + + + From 1f8c6ecabae0659b399dce7bb1a55d77d92c279a Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sun, 24 Nov 2019 17:03:30 +0200 Subject: [PATCH 03/11] added unit tests for userservice --- uthTrip.BLL/Services/TripService.cs | 2 +- uthTripProject/Controllers/UserController.cs | 32 ++-- uthTripProject/UnitTest/Test.cs | 161 ------------------- 3 files changed, 16 insertions(+), 179 deletions(-) delete mode 100644 uthTripProject/UnitTest/Test.cs diff --git a/uthTrip.BLL/Services/TripService.cs b/uthTrip.BLL/Services/TripService.cs index 79309c4..46d6879 100644 --- a/uthTrip.BLL/Services/TripService.cs +++ b/uthTrip.BLL/Services/TripService.cs @@ -1,4 +1,4 @@ -using System; + using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index 94940e3..1fac1b8 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -67,23 +67,22 @@ public ActionResult Login() return View(); } //public ActionResult Account(int id) - //{ - // var userAccount = userService.Get(id); + ////{ + // var userAccount = userService.Get(id); + + // var viewModel = new UserViewModel + // { + // User_ID = userAccount.User_ID, + // First_Name = userAccount.First_Name, + // Last_Name = userAccount.Last_Name, + // Username = userAccount.Username, + // Email = userAccount.Email, + // Password = userAccount.Password, + // Birthday = userAccount.Birthday, + // Photo_Url = userAccount.Photo_Url, + // Info = userAccount.Info + // }; -<<<<<<< Updated upstream - var viewModel = new UserViewModel - { - User_ID = userAccount.User_ID, - First_Name = userAccount.First_Name, - Last_Name = userAccount.Last_Name, - Username = userAccount.Username, - Email = userAccount.Email, - Password = userAccount.Password, - Birthday = userAccount.Birthday, - Photo_Url = userAccount.Photo_Url, - Info = userAccount.Info - }; -======= // var viewModel = new UserViewModel // { // User_ID = userAccount.User_ID, @@ -96,7 +95,6 @@ public ActionResult Login() // Photo_Url = userAccount.Photo_Url, // Info = userAccount.Info // }; ->>>>>>> Stashed changes // return View(viewModel); //} diff --git a/uthTripProject/UnitTest/Test.cs b/uthTripProject/UnitTest/Test.cs deleted file mode 100644 index 1844ca6..0000000 --- a/uthTripProject/UnitTest/Test.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System; -using Moq; -using uthTripProject.Controllers; -using uthTripProject.Models; -using uthTrip.BLL.Services; -using uthTrip.BLL.Interfaces; -using uthTrip.BLL.DTO; -using System.Web.Mvc; -using Xunit; - -namespace uthTripProject.Tests -{ - public class HomeControllerTests - { - DateTime somedate = new DateTime(2000, 07, 21); - - [Fact] - public void Index_View_Result() - { - // Setup - var expectedUserAccountCount = 2; - - var mockUserAccountService = new Mock(); - - mockUserAccountService.Setup(x => x.GetAll()) - .Returns(GetTestUserAccounts()); - - // Inject - var homeController = new UserController(mockUserAccountService.Object); - - // Act - var result = homeController.Index(); - - // Assert - var viewResult = Assert.IsType(result); - - var model = Assert.IsAssignableFrom>( - viewResult.ViewData.Model); - - Assert.Equal(expectedUserAccountCount, model.Count()); - } - - [Fact] - //public void Account_View_Result_One() - //{ - // // Setup - // var expectedUserAccountId = 123; - - // var mockUserAccountService = new Mock(); - - // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - // .Returns(GetTestUserAccountOne()); - - // // Inject - // var homeController = new UserController(mockUserAccountService.Object); - - // // Act - // var result = homeController.Account(expectedUserAccountId); - - // // Assert - // var viewResult = Assert.IsType(result); - - // var viewModel = Assert.IsAssignableFrom( - // viewResult.ViewData.Model); - - // Assert.Equal(expectedUserAccountId, viewModel.User_ID); - //} - - //[Fact] - //public void Account_View_Result_Two() - //{ - // // Setup - // var expectedUserAccountId = 456; - - // var mockUserAccountService = new Mock(); - - // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - // .Returns(GetTestUserAccountTwo()); - - // // Inject - // var homeController = new UserController(mockUserAccountService.Object); - - // // Act - // var result = homeController.Account(expectedUserAccountId); - - // // Assert - // var viewResult = Assert.IsType(result); - - // var viewModel = Assert.IsAssignableFrom( - // viewResult.ViewData.Model); - - // Assert.Equal(expectedUserAccountId, viewModel.User_ID); - //} - - //[Fact] - //public void Get_First_Name_Result() - //{ - // // Setup - // var userAccountId = 123; - // var userAccountFirstName = "Simon"; - - // var mockUserAccountService = new Mock(); - - // mockUserAccountService.Setup(x => x.GetFirstName(userAccountId)) - // .Returns(userAccountFirstName); - - // // Inject - // var homeController = new UserController(mockUserAccountService.Object); - - // // Act - // var result = homeController.ActionInvoker - - // // Assert - // Assert.Equal(userAccountFirstName, result); - //} - - private List GetTestUserAccounts() - { - return new List() - { - GetTestUserAccountOne(), - GetTestUserAccountTwo(), - }; - } - - private UserDTO GetTestUserAccountOne() - { - - return new UserDTO - { - User_ID = 123, - First_Name = "Simon", - Last_Name = "Gilbert", - Username = "simongilbert", - Email = "simongilbert@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "some boy" - }; - } - - private UserDTO GetTestUserAccountTwo() - { - return new UserDTO - { - User_ID = 456, - First_Name = "Alexander", - Last_Name = "Hill", - Username = "alexhill", - Email = "alexhill@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "anpther boy" - }; - } - } -} From e47dfd1418f5efcf941c9bba5ab1f6f594a2154b Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sun, 24 Nov 2019 18:53:46 +0200 Subject: [PATCH 04/11] Revert "added unit tests for userservice" This reverts commit 1f8c6ecabae0659b399dce7bb1a55d77d92c279a. --- uthTrip.BLL/Services/TripService.cs | 2 +- uthTripProject/Controllers/UserController.cs | 32 ++-- uthTripProject/UnitTest/Test.cs | 161 +++++++++++++++++++ 3 files changed, 179 insertions(+), 16 deletions(-) create mode 100644 uthTripProject/UnitTest/Test.cs diff --git a/uthTrip.BLL/Services/TripService.cs b/uthTrip.BLL/Services/TripService.cs index 46d6879..79309c4 100644 --- a/uthTrip.BLL/Services/TripService.cs +++ b/uthTrip.BLL/Services/TripService.cs @@ -1,4 +1,4 @@ - using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index 1fac1b8..94940e3 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -67,22 +67,23 @@ public ActionResult Login() return View(); } //public ActionResult Account(int id) - ////{ - // var userAccount = userService.Get(id); - - // var viewModel = new UserViewModel - // { - // User_ID = userAccount.User_ID, - // First_Name = userAccount.First_Name, - // Last_Name = userAccount.Last_Name, - // Username = userAccount.Username, - // Email = userAccount.Email, - // Password = userAccount.Password, - // Birthday = userAccount.Birthday, - // Photo_Url = userAccount.Photo_Url, - // Info = userAccount.Info - // }; + //{ + // var userAccount = userService.Get(id); +<<<<<<< Updated upstream + var viewModel = new UserViewModel + { + User_ID = userAccount.User_ID, + First_Name = userAccount.First_Name, + Last_Name = userAccount.Last_Name, + Username = userAccount.Username, + Email = userAccount.Email, + Password = userAccount.Password, + Birthday = userAccount.Birthday, + Photo_Url = userAccount.Photo_Url, + Info = userAccount.Info + }; +======= // var viewModel = new UserViewModel // { // User_ID = userAccount.User_ID, @@ -95,6 +96,7 @@ public ActionResult Login() // Photo_Url = userAccount.Photo_Url, // Info = userAccount.Info // }; +>>>>>>> Stashed changes // return View(viewModel); //} diff --git a/uthTripProject/UnitTest/Test.cs b/uthTripProject/UnitTest/Test.cs new file mode 100644 index 0000000..1844ca6 --- /dev/null +++ b/uthTripProject/UnitTest/Test.cs @@ -0,0 +1,161 @@ +using System.Collections.Generic; +using System.Linq; +using System; +using Moq; +using uthTripProject.Controllers; +using uthTripProject.Models; +using uthTrip.BLL.Services; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; +using System.Web.Mvc; +using Xunit; + +namespace uthTripProject.Tests +{ + public class HomeControllerTests + { + DateTime somedate = new DateTime(2000, 07, 21); + + [Fact] + public void Index_View_Result() + { + // Setup + var expectedUserAccountCount = 2; + + var mockUserAccountService = new Mock(); + + mockUserAccountService.Setup(x => x.GetAll()) + .Returns(GetTestUserAccounts()); + + // Inject + var homeController = new UserController(mockUserAccountService.Object); + + // Act + var result = homeController.Index(); + + // Assert + var viewResult = Assert.IsType(result); + + var model = Assert.IsAssignableFrom>( + viewResult.ViewData.Model); + + Assert.Equal(expectedUserAccountCount, model.Count()); + } + + [Fact] + //public void Account_View_Result_One() + //{ + // // Setup + // var expectedUserAccountId = 123; + + // var mockUserAccountService = new Mock(); + + // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + // .Returns(GetTestUserAccountOne()); + + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); + + // // Act + // var result = homeController.Account(expectedUserAccountId); + + // // Assert + // var viewResult = Assert.IsType(result); + + // var viewModel = Assert.IsAssignableFrom( + // viewResult.ViewData.Model); + + // Assert.Equal(expectedUserAccountId, viewModel.User_ID); + //} + + //[Fact] + //public void Account_View_Result_Two() + //{ + // // Setup + // var expectedUserAccountId = 456; + + // var mockUserAccountService = new Mock(); + + // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + // .Returns(GetTestUserAccountTwo()); + + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); + + // // Act + // var result = homeController.Account(expectedUserAccountId); + + // // Assert + // var viewResult = Assert.IsType(result); + + // var viewModel = Assert.IsAssignableFrom( + // viewResult.ViewData.Model); + + // Assert.Equal(expectedUserAccountId, viewModel.User_ID); + //} + + //[Fact] + //public void Get_First_Name_Result() + //{ + // // Setup + // var userAccountId = 123; + // var userAccountFirstName = "Simon"; + + // var mockUserAccountService = new Mock(); + + // mockUserAccountService.Setup(x => x.GetFirstName(userAccountId)) + // .Returns(userAccountFirstName); + + // // Inject + // var homeController = new UserController(mockUserAccountService.Object); + + // // Act + // var result = homeController.ActionInvoker + + // // Assert + // Assert.Equal(userAccountFirstName, result); + //} + + private List GetTestUserAccounts() + { + return new List() + { + GetTestUserAccountOne(), + GetTestUserAccountTwo(), + }; + } + + private UserDTO GetTestUserAccountOne() + { + + return new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "some boy" + }; + } + + private UserDTO GetTestUserAccountTwo() + { + return new UserDTO + { + User_ID = 456, + First_Name = "Alexander", + Last_Name = "Hill", + Username = "alexhill", + Email = "alexhill@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "anpther boy" + }; + } + } +} From 0f307af43cd7987546c90c827aed52f8bbdc2058 Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sun, 24 Nov 2019 18:59:58 +0200 Subject: [PATCH 05/11] reverting --- Tests/Properties/AssemblyInfo.cs | 20 - Tests/Tests.csproj | 544 ------------------- Tests/UnitTest1.cs | 45 -- Tests/app.config | 95 ---- Tests/packages.config | 154 ------ UnitTests/Properties/AssemblyInfo.cs | 20 - UnitTests/UnitTest1.cs | 29 - UnitTests/UnitTests.csproj | 84 --- UnitTests/packages.config | 10 - uthTrip.BLL/Interfaces/IUserService.cs | 4 + uthTrip.BLL/Services/UserService.cs | 34 +- uthTrip.Tests/UnitTest1.cs | 257 ++++----- uthTrip.Tests/packages.config | 7 - uthTrip.Tests/uthTrip.Tests.csproj | 34 -- uthTripProject.sln | 15 +- uthTripProject/Controllers/FaqController.cs | 27 - uthTripProject/Controllers/UserController.cs | 9 +- uthTripProject/Web.config | 250 +-------- uthTripProject/packages.config | 15 +- uthTripProject/uthTripProject.csproj | 45 +- 20 files changed, 181 insertions(+), 1517 deletions(-) delete mode 100644 Tests/Properties/AssemblyInfo.cs delete mode 100644 Tests/Tests.csproj delete mode 100644 Tests/UnitTest1.cs delete mode 100644 Tests/app.config delete mode 100644 Tests/packages.config delete mode 100644 UnitTests/Properties/AssemblyInfo.cs delete mode 100644 UnitTests/UnitTest1.cs delete mode 100644 UnitTests/UnitTests.csproj delete mode 100644 UnitTests/packages.config delete mode 100644 uthTripProject/Controllers/FaqController.cs diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e6f8c..0000000 --- a/Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("ddc86d49-c599-4782-b3e4-d66167bac90f")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj deleted file mode 100644 index ce0f36a..0000000 --- a/Tests/Tests.csproj +++ /dev/null @@ -1,544 +0,0 @@ - - - - - - - - - - - Debug - AnyCPU - {DDC86D49-C599-4782-B3E4-D66167BAC90F} - Library - Properties - Tests - Tests - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll - - - ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll - - - ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll - - - ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll - - - ..\packages\Microsoft.AspNetCore.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cors.dll - - - ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll - - - ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll - - - ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Http.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll - - - ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll - - - ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll - - - ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll - - - ..\packages\Microsoft.AspNetCore.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.ApiExplorer.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ApiExplorer.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Cors.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.RazorPages.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.TagHelpers.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll - - - ..\packages\Microsoft.AspNetCore.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll - - - ..\packages\Microsoft.AspNetCore.Razor.Language.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Language.dll - - - ..\packages\Microsoft.AspNetCore.Razor.Runtime.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll - - - ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Routing.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll - - - ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll - - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview2.19523.17\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\Microsoft.CodeAnalysis.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.dll - - - ..\packages\Microsoft.CodeAnalysis.CSharp.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll - - - ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll - - - ..\packages\Microsoft.CodeAnalysis.Razor.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.CodeAnalysis.Razor.dll - - - ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll - - - - ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview2.19525.4\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview2.19525.4\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll - - - ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll - - - ..\packages\Microsoft.Extensions.FileProviders.Composite.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Composite.dll - - - ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll - - - ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll - - - ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll - - - ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Core.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Core.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Templating.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Templating.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Utils.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Utils.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.dll - - - ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Newtonsoft.Json.Bson.1.0.1\lib\net45\Newtonsoft.Json.Bson.dll - - - ..\packages\NuGet.Frameworks.4.7.0\lib\net46\NuGet.Frameworks.dll - - - - ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll - True - True - - - ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll - - - ..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll - - - ..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll - - - ..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll - - - ..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll - - - - ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll - True - True - - - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll - True - True - - - ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll - True - True - - - - ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll - True - True - - - ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll - True - True - - - ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll - True - True - - - ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll - True - True - - - ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll - True - True - - - ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll - True - True - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll - True - True - - - ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll - - - ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll - True - True - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll - True - True - - - ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll - True - True - - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - True - - - - ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll - - - ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll - True - True - - - ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - True - True - - - ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - True - True - - - ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll - True - True - - - ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll - - - ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll - - - ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll - - - - ..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll - - - ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll - True - True - - - - ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll - True - True - - - - - ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll - True - True - - - ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll - True - True - - - ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll - True - True - - - ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll - True - True - - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - - - - - - - - - - - - - - - - - - {edec0e39-cc42-426b-8773-f9356ba20df9} - uthTrip.BLL - - - {f78c2ccb-0aa4-48f9-8dc1-9f65a5135e05} - uthTrip.DAL - - - {32e72533-0bdc-440a-9540-af7783555306} - uthTripProject - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs deleted file mode 100644 index 7c33807..0000000 --- a/Tests/UnitTest1.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; -using System.Linq; -//using Microsoft.AspNetCore.Mvc; -using uthTrip.BLL.Services; -using uthTrip.DAL.Interfaces; -using uthTrip.BLL.Interfaces; -using Moq; -using Xunit; -using uthTripProject.Controllers; -using System.Web; -namespace Tests -{ - - public class UnitTest1 - { - [Fact] - public void Index_View_Result() - { - // Setup - var expectedUserAccountCount = 2; - - var mockUserAccountService = new Mock(); - - mockUserAccountService.Setup(x => x.GetAll()) - .Returns(GetTestUserAccounts()); - - // Inject - var homeController = new UserController(mockUserAccountService.Object); - - // Act - var result = homeController.Index(); - - // Assert - var viewResult = Assert.IsType(result); - - var model = Assert.IsAssignableFrom>( - viewResult.ViewData.Model); - - Assert.Equal(expectedUserAccountCount, model.Count()); - } - - } -} diff --git a/Tests/app.config b/Tests/app.config deleted file mode 100644 index 9ccae07..0000000 --- a/Tests/app.config +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/packages.config b/Tests/packages.config deleted file mode 100644 index 4a68283..0000000 --- a/Tests/packages.config +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index bffcdc5..0000000 --- a/UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("UnitTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UnitTests")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("4a5a0491-90e9-42ef-9f0d-cf980a763af7")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTests/UnitTest1.cs b/UnitTests/UnitTest1.cs deleted file mode 100644 index 1368e4e..0000000 --- a/UnitTests/UnitTest1.cs +++ /dev/null @@ -1,29 +0,0 @@ -//using System; -//using Microsoft.VisualStudio.TestTools.UnitTesting; -//using System.Web.Mvc; -//using Moq; -//namespace UnitTests -//{ -// [TestClass] -// public class UnitTest1 -// { -// [TestMethod] -// public void Sum_Products_Correctly() -// { -// // Arrange (добавляем имитированный объект) -// Mock mock = new Mock(); -// mock.Setup(m => m.GetAll()); - -// UserController controller = new UserController(mock.Object); -// string expected = "В базе данных 1 объект"; - -// // Act -// controller.Index(); -// ViewResult result = controller.Index() as ViewResult; -// string actual = result.ViewBag.Message as string; - -// // Assert -// Assert.AreEqual(expected, actual); -// } -// } -//} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj deleted file mode 100644 index 259885b..0000000 --- a/UnitTests/UnitTests.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - Debug - AnyCPU - {4A5A0491-90E9-42EF-9F0D-CF980A763AF7} - Library - Properties - UnitTests - UnitTests - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.Web.Mvc.Extensions.1.1.1.2\lib\net45\System.Web.Mvc.Extensions.dll - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/UnitTests/packages.config b/UnitTests/packages.config deleted file mode 100644 index ac38aa6..0000000 --- a/UnitTests/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.BLL/Interfaces/IUserService.cs b/uthTrip.BLL/Interfaces/IUserService.cs index 2c180b9..3666613 100644 --- a/uthTrip.BLL/Interfaces/IUserService.cs +++ b/uthTrip.BLL/Interfaces/IUserService.cs @@ -12,7 +12,11 @@ public interface IUserService { void CreateUser(UserDTO userDto); UserDTO GetById(int? id); +<<<<<<< HEAD UserDTO GetByUsernamePassword(string username, string password); +======= + UserDTO GetByUsernamePassword(string username, string password); +>>>>>>> parent of 3e60396... added unit tests to userservice IEnumerable GetAll(); void Dispose(int id); int FindMaxId(); diff --git a/uthTrip.BLL/Services/UserService.cs b/uthTrip.BLL/Services/UserService.cs index d9db319..375871c 100644 --- a/uthTrip.BLL/Services/UserService.cs +++ b/uthTrip.BLL/Services/UserService.cs @@ -6,9 +6,12 @@ using uthTrip.BLL.Infrastructure; using uthTrip.BLL.Interfaces; using System.Collections.Generic; +<<<<<<< HEAD using System.Linq; using uthTrip.DAL.EF; +======= +>>>>>>> parent of 3e60396... added unit tests to userservice using AutoMapper; using System.Threading.Tasks; @@ -46,6 +49,32 @@ public void CreateUser(UserDTO userDto) Database.Users.Create(user); Database.Save(); } +<<<<<<< HEAD +======= + //public int Authenticate(string username, string password) + //{ + // if (string.IsNullOrEmpty(username)) + // { + // throw new Exception("Username is empty."); + // } + // else if (string.IsNullOrEmpty(password)) + // { + // throw new Exception("Password is empty."); + // } + + // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); + // if (user == null) + // { + // throw new Exception("User with current name does not exist."); + // } + // else if (!VerifyHash(password, user.Hash)) + // { + // throw new Exception("Invalid password."); + // } + + // return user.Id; + //} +>>>>>>> parent of 3e60396... added unit tests to userservice public UserDTO GetById(int? id) @@ -97,7 +126,10 @@ public UserDTO GetByUsernamePassword(string username, string password) return null; } } +<<<<<<< HEAD } +======= +>>>>>>> parent of 3e60396... added unit tests to userservice } - +} diff --git a/uthTrip.Tests/UnitTest1.cs b/uthTrip.Tests/UnitTest1.cs index 4b1d1be..6784f6b 100644 --- a/uthTrip.Tests/UnitTest1.cs +++ b/uthTrip.Tests/UnitTest1.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; -//using NUnit.Framework; +using NUnit.Framework; using uthTrip.BLL.Services; using uthTrip.BLL.Interfaces; using uthTripProject.Models; @@ -10,148 +10,125 @@ using uthTrip.DAL.EF; using uthTrip.DAL.Repositories; using uthTrip.BLL.DTO; -using uthTrip.DAL.Entities; using uthTrip.BLL.Infrastructure; -using uthTripProject.Controllers; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Web.Mvc; -using Moq; namespace uthTrip.Tests { - // [TestClass] - // public class UnitTest1 - // { - // readonly string testConnectionString = "Initial Catalog=UthTripDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; - // UserService CreateUserService() - // { - // return new UserService( - // new EFUnitOfWork( - // new uthtripContext(testConnectionString) - // ) - // ); - // } - - // //[TearDown] - // //public void ClearDB() - // //{ - // // var context = new uthtripContext(testConnectionString); - // // context.Users.RemoveRange(context.Users); - // // context.SaveChanges(); - // //} - - // //[Test] - // //public void CreateTest() - // //{ - // // var userService = CreateUserService(); - - // // DateTime somedate = new DateTime(2000, 07, 21); - - // // UserDTO usermodel = new UserDTO(); - // // usermodel.User_ID = 2; - // // usermodel.First_Name = "Nadia"; - // // usermodel.Last_Name = "Padalka"; - // // usermodel.Email = "nadiapadalka@gmail.com"; - // // usermodel.Username = "nadiapadalka"; - // // usermodel.Password = "1111"; - // // usermodel.Birthday = somedate; - // // usermodel.Photo_Url = "www"; - // // usermodel.Info = "super girl"; - // // userService.CreateUser(usermodel); - - // // var user = userService.GetAll().SingleOrDefault(); - // // Assert.AreEqual("Nadia", user.First_Name); - // //} - // [TestMethod] - // public void Sum_Products_Correctly() - // { - // // Arrange (добавляем имитированный объект) - // Mock mock = new Mock(); - // mock.Setup(m => m.GetAll()); - - // UserController controller = new UserController(mock.Object); - // //string expected = "В базе данных 1 объект"; - - // // Act - - // ViewResult result = controller.Index() as ViewResult; - // string actual = result.ViewBag.Message as string; - - // // Assert - // Assert.IsNotNull(result.Model); - // } - // //[Test] - // //public void DeleteUser() - // //{ - // // var userService = CreateUserService(); - - // // DateTime somedate = new DateTime(2000, 07, 21); - - // // UserDTO usermodel = new UserDTO(); - // // usermodel.User_ID = 2; - // // usermodel.First_Name = "Nadia"; - // // usermodel.Last_Name = "Padalka"; - // // usermodel.Email = "nadiapadalka@gmail.com"; - // // usermodel.Username = "nadiapadalka"; - // // usermodel.Password = "1111"; - // // usermodel.Birthday = somedate; - // // usermodel.Photo_Url = "www"; - // // usermodel.Info = "super girl"; - // // userService.CreateUser(usermodel); - - // // var user = userService.GetAll().SingleOrDefault(); - - // // userService.Dispose(user.User_ID); - // // Assert.AreEqual(0, userService.GetAll().Count()); - // //} - - - - // //[Test] - // //public void GetByIdTest() - // //{ - // // var userService = CreateUserService(); - - // // DateTime somedate = new DateTime(2000, 07, 21); - - // // UserDTO usermodel = new UserDTO(); - // // usermodel.User_ID = 2; - // // usermodel.First_Name = "Nadia"; - // // usermodel.Last_Name = "Padalka"; - // // usermodel.Email = "nadiapadalka@gmail.com"; - // // usermodel.Username = "nadiapadalka"; - // // usermodel.Password = "1111"; - // // usermodel.Birthday = somedate; - // // usermodel.Photo_Url = "www"; - // // usermodel.Info = "super girl"; - // // userService.CreateUser(usermodel); - // // var user = userService.GetAll().FirstOrDefault(); - // // Assert.NotNull(userService.GetById(user.User_ID)); - // //} - - // //[Test] - // //public void GetAll() - // //{ - // // var userService = CreateUserService(); - - // // DateTime somedate = new DateTime(2000, 07, 21); - - // // UserDTO usermodel = new UserDTO(); - // // usermodel.User_ID = 2; - // // usermodel.First_Name = "Nadia"; - // // usermodel.Last_Name = "Padalka"; - // // usermodel.Email = "nadiapadalka@gmail.com"; - // // usermodel.Username = "nadiapadalka"; - // // usermodel.Password = "1111"; - // // usermodel.Birthday = somedate; - // // usermodel.Photo_Url = "www"; - // // usermodel.Info = "super girl"; - // // userService.CreateUser(usermodel); - // // UserDTO user1 = new UserDTO(3, "Marichka", "Dymyd", "mariia@gmail.com", "mariicka", "1212", somedate, "www", "giirl"); - // // userService.CreateUser(user1); - - // // Assert.AreEqual(2, userService.GetAll().Count()); - // //} - // } + public class UnitTest1 + { + readonly string testConnectionString = "Initial Catalog=UthTripDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; + UserService CreateUserService() + { + return new UserService( + new EFUnitOfWork( + new uthtripContext(testConnectionString) + ) + ); + } + + [TearDown] + public void ClearDB() + { + var context = new uthtripContext(testConnectionString); + context.Users.RemoveRange(context.Users); + context.SaveChanges(); + } + + [Test] + public void CreateTest() + { + var userService = CreateUserService(); + + DateTime somedate = new DateTime(2000, 07, 21); + + UserDTO usermodel = new UserDTO(); + usermodel.User_ID = 2; + usermodel.First_Name = "Nadia"; + usermodel.Last_Name = "Padalka"; + usermodel.Email = "nadiapadalka@gmail.com"; + usermodel.Username = "nadiapadalka"; + usermodel.Password = "1111"; + usermodel.Birthday = somedate; + usermodel.Photo_Url = "www"; + usermodel.Info = "super girl"; + userService.CreateUser(usermodel); + + var user = userService.GetAll().SingleOrDefault(); + Assert.AreEqual("Nadia", user.First_Name); + } + + [Test] + public void DeleteUser() + { + var userService = CreateUserService(); + + DateTime somedate = new DateTime(2000, 07, 21); + + UserDTO usermodel = new UserDTO(); + usermodel.User_ID = 2; + usermodel.First_Name = "Nadia"; + usermodel.Last_Name = "Padalka"; + usermodel.Email = "nadiapadalka@gmail.com"; + usermodel.Username = "nadiapadalka"; + usermodel.Password = "1111"; + usermodel.Birthday = somedate; + usermodel.Photo_Url = "www"; + usermodel.Info = "super girl"; + userService.CreateUser(usermodel); + + var user = userService.GetAll().SingleOrDefault(); + + userService.Dispose(user.User_ID); + Assert.AreEqual(0, userService.GetAll().Count()); + } + + + + [Test] + public void GetByIdTest() + { + var userService = CreateUserService(); + + DateTime somedate = new DateTime(2000, 07, 21); + + UserDTO usermodel = new UserDTO(); + usermodel.User_ID = 2; + usermodel.First_Name = "Nadia"; + usermodel.Last_Name = "Padalka"; + usermodel.Email = "nadiapadalka@gmail.com"; + usermodel.Username = "nadiapadalka"; + usermodel.Password = "1111"; + usermodel.Birthday = somedate; + usermodel.Photo_Url = "www"; + usermodel.Info = "super girl"; + userService.CreateUser(usermodel); + var user = userService.GetAll().FirstOrDefault(); + Assert.NotNull(userService.GetById(user.User_ID)); + } + + [Test] + public void GetAll() + { + var userService = CreateUserService(); + + DateTime somedate = new DateTime(2000, 07, 21); + + UserDTO usermodel = new UserDTO(); + usermodel.User_ID = 2; + usermodel.First_Name = "Nadia"; + usermodel.Last_Name = "Padalka"; + usermodel.Email = "nadiapadalka@gmail.com"; + usermodel.Username = "nadiapadalka"; + usermodel.Password = "1111"; + usermodel.Birthday = somedate; + usermodel.Photo_Url = "www"; + usermodel.Info = "super girl"; + userService.CreateUser(usermodel); + UserDTO user1 = new UserDTO(3, "Marichka", "Dymyd", "mariia@gmail.com", "mariicka", "1212", somedate, "www", "giirl"); + userService.CreateUser(user1); + + Assert.AreEqual(2, userService.GetAll().Count()); + } + } } \ No newline at end of file diff --git a/uthTrip.Tests/packages.config b/uthTrip.Tests/packages.config index d3238c8..c6b74cb 100644 --- a/uthTrip.Tests/packages.config +++ b/uthTrip.Tests/packages.config @@ -1,14 +1,7 @@  - - - - - - - \ No newline at end of file diff --git a/uthTrip.Tests/uthTrip.Tests.csproj b/uthTrip.Tests/uthTrip.Tests.csproj index d3c1525..19e9a38 100644 --- a/uthTrip.Tests/uthTrip.Tests.csproj +++ b/uthTrip.Tests/uthTrip.Tests.csproj @@ -41,9 +41,6 @@ 4 - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.dll @@ -57,40 +54,12 @@ ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll - - - ..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll - - - ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll - - - ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll - - - ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll - @@ -114,9 +83,6 @@ uthTripProject - - - diff --git a/uthTripProject.sln b/uthTripProject.sln index 410b14c..17cf497 100644 --- a/uthTripProject.sln +++ b/uthTripProject.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.202 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.852 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTripProject", "uthTripProject\uthTripProject.csproj", "{32E72533-0BDC-440A-9540-AF7783555306}" EndProject @@ -9,7 +9,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.DAL", "uthTrip.DAL\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.BLL", "uthTrip.BLL\uthTrip.BLL.csproj", "{EDEC0E39-CC42-426B-8773-F9356BA20DF9}" EndProject +<<<<<<< HEAD Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{8B8D5CC4-86F5-4793-89EB-296325CA02F9}" +======= +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.Tests", "uthTrip.Tests\uthTrip.Tests.csproj", "{92D1958E-8110-402B-8A96-4C7FE9FFF0EC}" +>>>>>>> parent of 3e60396... added unit tests to userservice EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,10 +33,17 @@ Global {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.Build.0 = Release|Any CPU +<<<<<<< HEAD {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.Build.0 = Release|Any CPU +======= + {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.Build.0 = Release|Any CPU +>>>>>>> parent of 3e60396... added unit tests to userservice EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/uthTripProject/Controllers/FaqController.cs b/uthTripProject/Controllers/FaqController.cs deleted file mode 100644 index a58f1d2..0000000 --- a/uthTripProject/Controllers/FaqController.cs +++ /dev/null @@ -1,27 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; -//using System.Web.Mvc; -//namespace uthTripProject.Controllers -//{ -// public class FaqController : Controller -// { -// private readonly IFaqRepository _repository; -// public FaqController() : this(new FaqRepository()) { } -// public FaqController(IFaqRepository repository) -// { -// _repository = repository; -// } -// public ActionResult Index() -// { -// var records = _repository.GetAll(); -// var model = new FaqViewModel -// { -// FAQs = records -// }; -// return View(model); -// } -// } -//} diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index 94940e3..c6f6965 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -21,16 +21,11 @@ public UserController(IUserService serv) { userService = serv; } - public ActionResult Index() { IEnumerable userDtos = userService.GetAll(); var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); var users = mapper.Map, List>(userDtos); - //var model = repo.GetComputerList(); - if (users.Count > 0) - ViewBag.Message = String.Format("В базі даних {0} об'єкт", users.Count); - return View(users); } [HttpGet] @@ -66,6 +61,7 @@ public ActionResult Login() { return View(); } +<<<<<<< HEAD //public ActionResult Account(int id) //{ // var userAccount = userService.Get(id); @@ -100,6 +96,9 @@ public ActionResult Login() // return View(viewModel); //} +======= + +>>>>>>> parent of 3e60396... added unit tests to userservice [HttpPost] public ActionResult Login(UserViewModel userModel) { diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index 83b7f6c..cef9d1e 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -38,254 +38,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -360,4 +112,4 @@ - + \ No newline at end of file diff --git a/uthTripProject/packages.config b/uthTripProject/packages.config index 48a81f5..3d8b573 100644 --- a/uthTripProject/packages.config +++ b/uthTripProject/packages.config @@ -3,7 +3,6 @@ - @@ -25,27 +24,17 @@ - - + + - - - - - - - - - - \ No newline at end of file diff --git a/uthTripProject/uthTripProject.csproj b/uthTripProject/uthTripProject.csproj index b5a6050..3dd27ed 100644 --- a/uthTripProject/uthTripProject.csproj +++ b/uthTripProject/uthTripProject.csproj @@ -1,7 +1,7 @@  - - + + @@ -51,16 +51,7 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\Microsoft.VisualStudio.UnitTesting.11.0.50727.1\lib\net45\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -73,6 +64,9 @@ ..\packages\Ninject.MVC5.3.3.0\lib\net45\Ninject.Web.Mvc.dll + + ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + ..\packages\PagedList.1.17.0.0\lib\net40\PagedList.dll @@ -83,14 +77,8 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - @@ -150,18 +138,6 @@ True ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - @@ -220,7 +196,6 @@ - @@ -233,7 +208,6 @@ - @@ -332,9 +306,6 @@ uthTrip.BLL - - - 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -368,11 +339,9 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTestProject1/packages.config b/UnitTestProject1/packages.config deleted file mode 100644 index 828fb10..0000000 --- a/UnitTestProject1/packages.config +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.BLL/App.config b/uthTrip.BLL/App.config index 21d33da..c5c407b 100644 --- a/uthTrip.BLL/App.config +++ b/uthTrip.BLL/App.config @@ -1,35 +1,4 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.BLL/Interfaces/IUserService.cs b/uthTrip.BLL/Interfaces/IUserService.cs index 3666613..ee3bc5c 100644 --- a/uthTrip.BLL/Interfaces/IUserService.cs +++ b/uthTrip.BLL/Interfaces/IUserService.cs @@ -12,11 +12,17 @@ public interface IUserService { void CreateUser(UserDTO userDto); UserDTO GetById(int? id); +<<<<<<< HEAD <<<<<<< HEAD UserDTO GetByUsernamePassword(string username, string password); ======= UserDTO GetByUsernamePassword(string username, string password); >>>>>>> parent of 3e60396... added unit tests to userservice +======= + UserDTO Get(int userAccountId); + string GetFirstName(int userAccountId); + UserDTO GetByUsernamePassword(string username, string password); +>>>>>>> parent of aa645ae... added unit tests for userservice IEnumerable GetAll(); void Dispose(int id); int FindMaxId(); diff --git a/uthTrip.BLL/Services/UserService.cs b/uthTrip.BLL/Services/UserService.cs index 375871c..f3ce47e 100644 --- a/uthTrip.BLL/Services/UserService.cs +++ b/uthTrip.BLL/Services/UserService.cs @@ -8,15 +8,15 @@ using System.Collections.Generic; <<<<<<< HEAD using System.Linq; +<<<<<<< HEAD using uthTrip.DAL.EF; ======= >>>>>>> parent of 3e60396... added unit tests to userservice +======= +>>>>>>> parent of aa645ae... added unit tests for userservice using AutoMapper; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; - namespace uthTrip.BLL.Services { public class UserService : IUserService @@ -31,7 +31,6 @@ public UserService(IUnitOfWork uow) { Database = uow; } - public void CreateUser(UserDTO userDto) { User user = new User @@ -76,6 +75,46 @@ public void CreateUser(UserDTO userDto) //} >>>>>>> parent of 3e60396... added unit tests to userservice + public string GetFirstName(int userAccountId) + { + var result = GetAllUsers() + .Where(x => x.User_ID == userAccountId) + .Select(x => x.First_Name) + .FirstOrDefault(); + + return result; + } + public UserDTO Get(int userAccountId) + { + var userAccount = GetAllUsers() + .FirstOrDefault(x => x.User_ID == userAccountId); + + return userAccount; + } + //public int Authenticate(string username, string password) + //{ + // if (string.IsNullOrEmpty(username)) + // { + // throw new Exception("Username is empty."); + // } + // else if (string.IsNullOrEmpty(password)) + // { + // throw new Exception("Password is empty."); + // } + + // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); + // if (user == null) + // { + // throw new Exception("User with current name does not exist."); + // } + // else if (!VerifyHash(password, user.Hash)) + // { + // throw new Exception("Invalid password."); + // } + + // return user.Id; + //} + public UserDTO GetById(int? id) { @@ -127,7 +166,44 @@ public UserDTO GetByUsernamePassword(string username, string password) } } <<<<<<< HEAD +<<<<<<< HEAD +======= + private List GetAllUsers() + { + DateTime somedate = new DateTime(2000, 07, 21); + return new List() + { + + +>>>>>>> parent of aa645ae... added unit tests for userservice + new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email= "simongilbert@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "some boy" + + }, + new UserDTO + { + User_ID = 456, + First_Name = "Alexander", + Last_Name = "Hill", + Username = "alexhill", + Email= "alexhill@com", + Password = "1111", + Birthday = somedate, + Photo_Url = "www", + Info = "anpther boy" + }, + }; + } } ======= >>>>>>> parent of 3e60396... added unit tests to userservice diff --git a/uthTrip.BLL/packages.config b/uthTrip.BLL/packages.config index f66e532..f2f5f08 100644 --- a/uthTrip.BLL/packages.config +++ b/uthTrip.BLL/packages.config @@ -1,29 +1,5 @@  - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.BLL/uthTrip.BLL.csproj b/uthTrip.BLL/uthTrip.BLL.csproj index 741c879..e704b66 100644 --- a/uthTrip.BLL/uthTrip.BLL.csproj +++ b/uthTrip.BLL/uthTrip.BLL.csproj @@ -34,84 +34,14 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll - - - ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - diff --git a/uthTrip.DAL/App.config b/uthTrip.DAL/App.config index bac9f49..288b373 100644 --- a/uthTrip.DAL/App.config +++ b/uthTrip.DAL/App.config @@ -12,20 +12,4 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.DAL/EF/uthtripContext.cs b/uthTrip.DAL/EF/uthtripContext.cs index 2090a5e..80e3c4c 100644 --- a/uthTrip.DAL/EF/uthtripContext.cs +++ b/uthTrip.DAL/EF/uthtripContext.cs @@ -1,12 +1,10 @@ namespace uthTrip.DAL.EF { using System; - //using System.Data.Entity; + using System.Data.Entity; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using uthTrip.DAL.Entities; - using Microsoft.EntityFrameworkCore; - public partial class uthtripContext : DbContext { @@ -16,12 +14,10 @@ public uthtripContext(string conString) { connectionString = conString; } - //public uthtripContext() { } - public uthtripContext(DbContextOptions options) : base(options) { } - //public uthtripContext() - // : base("name=uthtripContext") - //{ - //} + public uthtripContext() + : base("name=uthtripContext") + { + } public virtual DbSet Blocked_Users { get; set; } public virtual DbSet Dates_ranges { get; set; } @@ -32,101 +28,101 @@ public uthtripContext(DbContextOptions options) : base(options) public virtual DbSet Trips { get; set; } public virtual DbSet Users { get; set; } - //// protected override void OnModelCreating(DbModelBuilder modelBuilder) - // { - // modelBuilder.Entity() - // .HasMany(e => e.Trips) - // .WithRequired(e => e.Dates_ranges) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .Property(e => e.Country) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.City) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Trips) - // .WithRequired(e => e.Destination) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .Property(e => e.Review1) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Title) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Rights) - // .WithRequired(e => e.Role) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .Property(e => e.Trip_Title) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Description) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Reviews) - // .WithRequired(e => e.Trip) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Rights) - // .WithRequired(e => e.Trip) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .Property(e => e.First_Name) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Last_Name) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Email) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Username) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Password) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Photo_Url) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .Property(e => e.Info) - // .IsUnicode(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Reviews) - // .WithRequired(e => e.User) - // .HasForeignKey(e => e.Writer_ID) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Rights) - // .WithRequired(e => e.User) - // .WillCascadeOnDelete(false); - - // modelBuilder.Entity() - // .HasMany(e => e.Trips) - // .WithRequired(e => e.User) - // .HasForeignKey(e => e.Creator_ID) - // .WillCascadeOnDelete(false); - // } + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasMany(e => e.Trips) + .WithRequired(e => e.Dates_ranges) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .Property(e => e.Country) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.City) + .IsUnicode(false); + + modelBuilder.Entity() + .HasMany(e => e.Trips) + .WithRequired(e => e.Destination) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .Property(e => e.Review1) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Title) + .IsUnicode(false); + + modelBuilder.Entity() + .HasMany(e => e.Rights) + .WithRequired(e => e.Role) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .Property(e => e.Trip_Title) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Description) + .IsUnicode(false); + + modelBuilder.Entity() + .HasMany(e => e.Reviews) + .WithRequired(e => e.Trip) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .HasMany(e => e.Rights) + .WithRequired(e => e.Trip) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .Property(e => e.First_Name) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Last_Name) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Email) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Username) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Password) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Photo_Url) + .IsUnicode(false); + + modelBuilder.Entity() + .Property(e => e.Info) + .IsUnicode(false); + + modelBuilder.Entity() + .HasMany(e => e.Reviews) + .WithRequired(e => e.User) + .HasForeignKey(e => e.Writer_ID) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .HasMany(e => e.Rights) + .WithRequired(e => e.User) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .HasMany(e => e.Trips) + .WithRequired(e => e.User) + .HasForeignKey(e => e.Creator_ID) + .WillCascadeOnDelete(false); + } } } diff --git a/uthTrip.DAL/Repositories/BlockedUserRepository.cs b/uthTrip.DAL/Repositories/BlockedUserRepository.cs index 5790495..21ade9f 100644 --- a/uthTrip.DAL/Repositories/BlockedUserRepository.cs +++ b/uthTrip.DAL/Repositories/BlockedUserRepository.cs @@ -6,8 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -//using System.Data.Entity; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/DateRangeRepository.cs b/uthTrip.DAL/Repositories/DateRangeRepository.cs index 29b8cda..002d381 100644 --- a/uthTrip.DAL/Repositories/DateRangeRepository.cs +++ b/uthTrip.DAL/Repositories/DateRangeRepository.cs @@ -6,8 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; -//using System.Data.Entity; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/DestinationRepository.cs b/uthTrip.DAL/Repositories/DestinationRepository.cs index 8126fdc..0c4ea80 100644 --- a/uthTrip.DAL/Repositories/DestinationRepository.cs +++ b/uthTrip.DAL/Repositories/DestinationRepository.cs @@ -6,8 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -//using System.Data.Entity; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/EFUnitOfWork.cs b/uthTrip.DAL/Repositories/EFUnitOfWork.cs index 015532e..7da1a21 100644 --- a/uthTrip.DAL/Repositories/EFUnitOfWork.cs +++ b/uthTrip.DAL/Repositories/EFUnitOfWork.cs @@ -26,7 +26,6 @@ public EFUnitOfWork(string connectionString) { db = new uthtripContext(connectionString); } - public IRepository Users { get diff --git a/uthTrip.DAL/Repositories/ReviewRepository.cs b/uthTrip.DAL/Repositories/ReviewRepository.cs index 4a4669a..a294fe0 100644 --- a/uthTrip.DAL/Repositories/ReviewRepository.cs +++ b/uthTrip.DAL/Repositories/ReviewRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/RightRepository.cs b/uthTrip.DAL/Repositories/RightRepository.cs index 6b96819..1568729 100644 --- a/uthTrip.DAL/Repositories/RightRepository.cs +++ b/uthTrip.DAL/Repositories/RightRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/RoleRepository.cs b/uthTrip.DAL/Repositories/RoleRepository.cs index 3bbfdb0..785a03e 100644 --- a/uthTrip.DAL/Repositories/RoleRepository.cs +++ b/uthTrip.DAL/Repositories/RoleRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/TripRepository.cs b/uthTrip.DAL/Repositories/TripRepository.cs index 32ccb4b..374a659 100644 --- a/uthTrip.DAL/Repositories/TripRepository.cs +++ b/uthTrip.DAL/Repositories/TripRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/Repositories/UserRepository.cs b/uthTrip.DAL/Repositories/UserRepository.cs index 21af98c..c3f1d5a 100644 --- a/uthTrip.DAL/Repositories/UserRepository.cs +++ b/uthTrip.DAL/Repositories/UserRepository.cs @@ -6,7 +6,7 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; -using Microsoft.EntityFrameworkCore; +using System.Data.Entity; namespace uthTrip.DAL.Repositories { diff --git a/uthTrip.DAL/packages.config b/uthTrip.DAL/packages.config index 3e1a073..2cd2314 100644 --- a/uthTrip.DAL/packages.config +++ b/uthTrip.DAL/packages.config @@ -1,28 +1,4 @@  - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.DAL/uthTrip.DAL.csproj b/uthTrip.DAL/uthTrip.DAL.csproj index 63be2f3..1e26807 100644 --- a/uthTrip.DAL/uthTrip.DAL.csproj +++ b/uthTrip.DAL/uthTrip.DAL.csproj @@ -40,81 +40,11 @@ ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll - - - ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - diff --git a/uthTripProject.sln b/uthTripProject.sln index 17cf497..c357c38 100644 --- a/uthTripProject.sln +++ b/uthTripProject.sln @@ -10,11 +10,14 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.BLL", "uthTrip.BLL\uthTrip.BLL.csproj", "{EDEC0E39-CC42-426B-8773-F9356BA20DF9}" EndProject <<<<<<< HEAD +<<<<<<< HEAD Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{8B8D5CC4-86F5-4793-89EB-296325CA02F9}" ======= Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.Tests", "uthTrip.Tests\uthTrip.Tests.csproj", "{92D1958E-8110-402B-8A96-4C7FE9FFF0EC}" >>>>>>> parent of 3e60396... added unit tests to userservice EndProject +======= +>>>>>>> parent of aa645ae... added unit tests for userservice Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +36,7 @@ Global {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.Build.0 = Release|Any CPU +<<<<<<< HEAD <<<<<<< HEAD {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -44,6 +48,8 @@ Global {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.Build.0 = Release|Any CPU >>>>>>> parent of 3e60396... added unit tests to userservice +======= +>>>>>>> parent of aa645ae... added unit tests for userservice EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index c6f6965..fb6a62d 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -61,12 +61,17 @@ public ActionResult Login() { return View(); } +<<<<<<< HEAD <<<<<<< HEAD //public ActionResult Account(int id) //{ // var userAccount = userService.Get(id); +======= + public ActionResult Account(int id) + { + var userAccount = userService.Get(id); +>>>>>>> parent of aa645ae... added unit tests for userservice -<<<<<<< Updated upstream var viewModel = new UserViewModel { User_ID = userAccount.User_ID, @@ -79,26 +84,17 @@ public ActionResult Login() Photo_Url = userAccount.Photo_Url, Info = userAccount.Info }; -======= - // var viewModel = new UserViewModel - // { - // User_ID = userAccount.User_ID, - // First_Name = userAccount.First_Name, - // Last_Name = userAccount.Last_Name, - // Username = userAccount.Username, - // Email = userAccount.Email, - // Password = userAccount.Password, - // Birthday = userAccount.Birthday, - // Photo_Url = userAccount.Photo_Url, - // Info = userAccount.Info - // }; ->>>>>>> Stashed changes +<<<<<<< HEAD // return View(viewModel); //} ======= >>>>>>> parent of 3e60396... added unit tests to userservice +======= + return View(viewModel); + } +>>>>>>> parent of aa645ae... added unit tests for userservice [HttpPost] public ActionResult Login(UserViewModel userModel) { diff --git a/uthTripProject/UnitTest/Test.cs b/uthTripProject/UnitTest/Test.cs index 1844ca6..f983e55 100644 --- a/uthTripProject/UnitTest/Test.cs +++ b/uthTripProject/UnitTest/Test.cs @@ -43,56 +43,56 @@ public void Index_View_Result() } [Fact] - //public void Account_View_Result_One() - //{ - // // Setup - // var expectedUserAccountId = 123; + public void Account_View_Result_One() + { + // Setup + var expectedUserAccountId = 123; - // var mockUserAccountService = new Mock(); + var mockUserAccountService = new Mock(); - // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - // .Returns(GetTestUserAccountOne()); + mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + .Returns(GetTestUserAccountOne()); - // // Inject - // var homeController = new UserController(mockUserAccountService.Object); + // Inject + var homeController = new UserController(mockUserAccountService.Object); - // // Act - // var result = homeController.Account(expectedUserAccountId); + // Act + var result = homeController.Account(expectedUserAccountId); - // // Assert - // var viewResult = Assert.IsType(result); + // Assert + var viewResult = Assert.IsType(result); - // var viewModel = Assert.IsAssignableFrom( - // viewResult.ViewData.Model); + var viewModel = Assert.IsAssignableFrom( + viewResult.ViewData.Model); - // Assert.Equal(expectedUserAccountId, viewModel.User_ID); - //} + Assert.Equal(expectedUserAccountId, viewModel.User_ID); + } - //[Fact] - //public void Account_View_Result_Two() - //{ - // // Setup - // var expectedUserAccountId = 456; + [Fact] + public void Account_View_Result_Two() + { + // Setup + var expectedUserAccountId = 456; - // var mockUserAccountService = new Mock(); + var mockUserAccountService = new Mock(); - // mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) - // .Returns(GetTestUserAccountTwo()); + mockUserAccountService.Setup(x => x.Get(expectedUserAccountId)) + .Returns(GetTestUserAccountTwo()); - // // Inject - // var homeController = new UserController(mockUserAccountService.Object); + // Inject + var homeController = new UserController(mockUserAccountService.Object); - // // Act - // var result = homeController.Account(expectedUserAccountId); + // Act + var result = homeController.Account(expectedUserAccountId); - // // Assert - // var viewResult = Assert.IsType(result); + // Assert + var viewResult = Assert.IsType(result); - // var viewModel = Assert.IsAssignableFrom( - // viewResult.ViewData.Model); + var viewModel = Assert.IsAssignableFrom( + viewResult.ViewData.Model); - // Assert.Equal(expectedUserAccountId, viewModel.User_ID); - //} + Assert.Equal(expectedUserAccountId, viewModel.User_ID); + } //[Fact] //public void Get_First_Name_Result() diff --git a/uthTripProject/Views/Account/EditData.cshtml b/uthTripProject/Views/Account/EditData.cshtml deleted file mode 100644 index 7cf47ae..0000000 --- a/uthTripProject/Views/Account/EditData.cshtml +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace uthTripProject.Views.Account -{ - interface EditData - { - } -} diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index cef9d1e..d832b55 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -86,18 +86,6 @@ - - - - - - - - - - - - From 10dfef58f1a220b4ea3c58fae3dd2fd0835a2d6c Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sun, 1 Dec 2019 20:31:51 +0200 Subject: [PATCH 07/11] added some validation to registration login and create trip page --- UnitTestProject1/app.config | 104 +++++ uthTrip.BLL/App.config | 250 +++++++++++ uthTrip.DAL/App.config | 147 +++++++ uthTrip.DAL/Entities/Destination.cs | 4 +- uthTrip.DAL/Entities/Right.cs | 2 +- uthTrip.DAL/Entities/Role.cs | 2 +- uthTrip.DAL/Entities/Trip.cs | 12 +- uthTrip.DAL/Entities/User.cs | 17 +- uthTrip.DAL/Repositories/UserRepository.cs | 20 +- uthTrip.DAL/packages.config | 134 ++++++ uthTrip.DAL/uthTrip.DAL.csproj | 412 ++++++++++++++++++- uthTrip.Tests/App.config | 116 ++++++ uthTripProject/Controllers/UserController.cs | 9 + uthTripProject/Web.config | 119 ++++++ 14 files changed, 1332 insertions(+), 16 deletions(-) create mode 100644 UnitTestProject1/app.config diff --git a/UnitTestProject1/app.config b/UnitTestProject1/app.config new file mode 100644 index 0000000..37a0dc9 --- /dev/null +++ b/UnitTestProject1/app.config @@ -0,0 +1,104 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTrip.BLL/App.config b/uthTrip.BLL/App.config index c5c407b..2c06cb9 100644 --- a/uthTrip.BLL/App.config +++ b/uthTrip.BLL/App.config @@ -1,4 +1,254 @@  +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> Stashed changes \ No newline at end of file diff --git a/uthTrip.DAL/App.config b/uthTrip.DAL/App.config index 288b373..d94ae4e 100644 --- a/uthTrip.DAL/App.config +++ b/uthTrip.DAL/App.config @@ -12,4 +12,151 @@ +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> Stashed changes \ No newline at end of file diff --git a/uthTrip.DAL/Entities/Destination.cs b/uthTrip.DAL/Entities/Destination.cs index 0ac2dd8..e3611ec 100644 --- a/uthTrip.DAL/Entities/Destination.cs +++ b/uthTrip.DAL/Entities/Destination.cs @@ -20,10 +20,10 @@ public Destination() public bool Is_Abroad { get; set; } - [StringLength(50)] + [StringLength(50,MinimumLength = 5)] public string Country { get; set; } - [StringLength(100)] + [StringLength(100, MinimumLength = 5)] public string City { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/uthTrip.DAL/Entities/Right.cs b/uthTrip.DAL/Entities/Right.cs index e4b6dee..1812115 100644 --- a/uthTrip.DAL/Entities/Right.cs +++ b/uthTrip.DAL/Entities/Right.cs @@ -11,7 +11,7 @@ public partial class Right [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Rights_ID { get; set; } - + public int User_ID { get; set; } public int Role_ID { get; set; } diff --git a/uthTrip.DAL/Entities/Role.cs b/uthTrip.DAL/Entities/Role.cs index f8ccd73..111a24f 100644 --- a/uthTrip.DAL/Entities/Role.cs +++ b/uthTrip.DAL/Entities/Role.cs @@ -18,7 +18,7 @@ public Role() [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Role_ID { get; set; } - [StringLength(50)] + [StringLength(50,MinimumLength = 5)] public string Title { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/uthTrip.DAL/Entities/Trip.cs b/uthTrip.DAL/Entities/Trip.cs index 02ee8e9..b29e61e 100644 --- a/uthTrip.DAL/Entities/Trip.cs +++ b/uthTrip.DAL/Entities/Trip.cs @@ -19,16 +19,17 @@ public Trip() [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Trip_ID { get; set; } - [StringLength(100)] + [StringLength(100,MinimumLength =10,ErrorMessage = "Title of trip shold have from 10 to 100 symbols")] + [Required] public string Trip_Title { get; set; } - - [StringLength(300)] + [Required] + [StringLength(300, MinimumLength = 10, ErrorMessage = "Write some information about your trip")] public string Description { get; set; } - + [Required] public double Price { get; set; } public int Date_ID { get; set; } - + [Required] public int Number_Of_People { get; set; } public int Destination_ID { get; set; } @@ -36,7 +37,6 @@ public Trip() public int Creator_ID { get; set; } public virtual Dates_ranges Dates_ranges { get; set; } - public virtual Destination Destination { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/uthTrip.DAL/Entities/User.cs b/uthTrip.DAL/Entities/User.cs index ccea0c2..e957bd7 100644 --- a/uthTrip.DAL/Entities/User.cs +++ b/uthTrip.DAL/Entities/User.cs @@ -6,6 +6,7 @@ namespace uthTrip.DAL.Entities using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; + public partial class User { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] @@ -18,30 +19,38 @@ public User() } [Key] + //[DatabaseGenerated(DatabaseGeneratedOption.None)] public int User_ID { get; set; } [Required] - [StringLength(30)] + + [StringLength(30, MinimumLength = 3, ErrorMessage = "Name should be from 3 to 30 symbols")] + public string First_Name { get; set; } [Required] - [StringLength(30)] + [StringLength(30, MinimumLength = 2, ErrorMessage = "Surname should be from 2 to 30 symbols")] public string Last_Name { get; set; } [Required] [StringLength(30)] + [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}", ErrorMessage = "Email is invalid")] public string Email { get; set; } [Required] - [StringLength(30)] + [StringLength(30, MinimumLength = 8, ErrorMessage = "Username should be from 8 to 50 symbols")] public string Username { get; set; } [Required] - [StringLength(30)] + [StringLength(30, MinimumLength = 8, ErrorMessage = "Password should be from 8 to 50 symbols")] + [DataType(DataType.Password)] + public string Password { get; set; } [Column(TypeName = "date")] + [DataType(DataType.Date)] + public DateTime Birthday { get; set; } [Required] diff --git a/uthTrip.DAL/Repositories/UserRepository.cs b/uthTrip.DAL/Repositories/UserRepository.cs index c3f1d5a..4c632dd 100644 --- a/uthTrip.DAL/Repositories/UserRepository.cs +++ b/uthTrip.DAL/Repositories/UserRepository.cs @@ -6,8 +6,15 @@ using uthTrip.DAL.Entities; using uthTrip.DAL.EF; using uthTrip.DAL.Interfaces; +<<<<<<< Updated upstream using System.Data.Entity; +======= +//using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.AspNetCore.Mvc.ModelBinding; +>>>>>>> Stashed changes namespace uthTrip.DAL.Repositories { public class UserRepository : IRepository @@ -29,7 +36,7 @@ public User Get(int id) return db.Users.Find(id); } - public void Create(User user) + public void Create( User user) { db.Users.Add(user); } @@ -52,6 +59,7 @@ public void Delete(int id) } public int MaxId() { +<<<<<<< Updated upstream int max = 0; try { @@ -60,6 +68,16 @@ public int MaxId() catch(System.InvalidOperationException) { max= -1; } return max; +======= + //int max = 0; + //try + //{ + // max = db.Users.Max(a => a.User_ID); + //} + //catch (System.InvalidOperationException) + //{ max = -1; } + return -1; +>>>>>>> Stashed changes } diff --git a/uthTrip.DAL/packages.config b/uthTrip.DAL/packages.config index 2cd2314..49f8b92 100644 --- a/uthTrip.DAL/packages.config +++ b/uthTrip.DAL/packages.config @@ -1,4 +1,138 @@  +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> Stashed changes \ No newline at end of file diff --git a/uthTrip.DAL/uthTrip.DAL.csproj b/uthTrip.DAL/uthTrip.DAL.csproj index 1e26807..d4ae701 100644 --- a/uthTrip.DAL/uthTrip.DAL.csproj +++ b/uthTrip.DAL/uthTrip.DAL.csproj @@ -1,5 +1,8 @@  + + + @@ -40,17 +43,416 @@ ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll +<<<<<<< Updated upstream +======= + + ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll + + + ..\packages\Microsoft.AspNetCore.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll + + + ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll + + + ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll + + + ..\packages\Microsoft.AspNetCore.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ApiExplorer.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ApiExplorer.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.RazorPages.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.TagHelpers.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll + + + ..\packages\Microsoft.AspNetCore.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Language.2.2.0\lib\net46\Microsoft.AspNetCore.Razor.Language.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Runtime.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll + + + ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Routing.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll + + + ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll + + + ..\packages\Microsoft.CodeAnalysis.Common.2.8.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + + + ..\packages\Microsoft.CodeAnalysis.CSharp.2.8.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + + + ..\packages\Microsoft.CodeAnalysis.Razor.2.2.0\lib\net46\Microsoft.CodeAnalysis.Razor.dll + + + ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Composite.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Composite.dll + + + ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll + + + ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll + + + ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll + + + ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll + + + ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll + + + ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll + + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Newtonsoft.Json.Bson.1.0.1\lib\net45\Newtonsoft.Json.Bson.dll + + + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll + + +>>>>>>> Stashed changes + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + True + +<<<<<<< Updated upstream + + +======= + + + ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + True + + + ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + True + True + + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + True + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll + + + + ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + True + True + + + + ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + True + True + +>>>>>>> Stashed changes + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + True + + + ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + True + True + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + True + True + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + True + True + @@ -76,7 +478,10 @@ - + + + + Designer @@ -90,6 +495,11 @@ + + + + + \ No newline at end of file diff --git a/uthTrip.Tests/App.config b/uthTrip.Tests/App.config index a7fe939..5543d1c 100644 --- a/uthTrip.Tests/App.config +++ b/uthTrip.Tests/App.config @@ -47,6 +47,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uthTripProject/Controllers/UserController.cs b/uthTripProject/Controllers/UserController.cs index fb6a62d..580c8a8 100644 --- a/uthTripProject/Controllers/UserController.cs +++ b/uthTripProject/Controllers/UserController.cs @@ -39,11 +39,20 @@ public ActionResult AddOrEdit(UserViewModel userModel) { try { +<<<<<<< Updated upstream userModel.User_ID = userService.FindMaxId() + 1; var userDto = new UserDTO(userModel.User_ID, userModel.First_Name, userModel.Last_Name, userModel.Email, userModel.Username, userModel.Password, userModel.Birthday, userModel.Photo_Url, userModel.Info); userService.CreateUser(userDto); ViewBag.SuccessMessage = "Registration Successful."; +======= + + userModel.User_ID = this.userService.FindMaxId() + 1; + var userDto = new UserDTO(userModel.User_ID, userModel.First_Name, userModel.Last_Name, userModel.Email, userModel.Username, userModel.Password, userModel.Birthday, userModel.Photo_Url, userModel.Info); + this.userService.CreateUser(userDto); + return this.RedirectToAction("StartPage", "Home"); + +>>>>>>> Stashed changes } catch (ValidationException ex) { diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index d832b55..e47cfbe 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -86,6 +86,125 @@ +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> Stashed changes From b73ea823a66c59fb6772495cb9e5bec9e42d9fa5 Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sat, 7 Dec 2019 11:39:04 +0200 Subject: [PATCH 08/11] added tests for userService --- UnitTestProject1/UnitTest1.cs | 97 +++++++++++ UnitTestProject1/UnitTestProject1.csproj | 196 ++++++++++++++++++++++ UnitTestProject1/UserServiceTest.cs | 1 + uthTrip.DAL/EF/uthtripContext.cs | 12 ++ uthTrip.Tests/App.config | 8 + uthTrip.Tests/UserServiceTEst.cs | 197 +++++++++++++++++++++++ uthTrip.Tests/packages.config | 20 +++ uthTrip.Tests/uthTrip.Tests.csproj | 79 ++++++++- uthTripProject.sln | 6 + uthTripProject/Web.config | 7 + 10 files changed, 622 insertions(+), 1 deletion(-) create mode 100644 UnitTestProject1/UnitTest1.cs create mode 100644 UnitTestProject1/UnitTestProject1.csproj create mode 100644 UnitTestProject1/UserServiceTest.cs create mode 100644 uthTrip.Tests/UserServiceTEst.cs diff --git a/UnitTestProject1/UnitTest1.cs b/UnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..ac8b4ef --- /dev/null +++ b/UnitTestProject1/UnitTest1.cs @@ -0,0 +1,97 @@ +namespace UnitTestProject1 +{ + using System; + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + using UthTrip.BLL.DTO; + using UthTrip.BLL.Services; + using UthTrip.DAL.EF; + using UthTrip.DAL.Entities; + using UthTrip.DAL.Repositories; +[TestClass] +public class UserServiceTest +{ + private Mock mockRepository; + private UserService _service; + Mock _mockUnitWork; + List listUser; + + [TestInitialize] + public void Initialize() + { + mockRepository = new Mock(); + _mockUnitWork = new Mock(); + _service = new UserService(_mockUnitWork.Object); + listUser = new List() { + new UserDTO{ + User_ID = 132, + First_Name = "Yaroslav", + Last_Name = "Nolkuchak", + Username = "user2", + Email = "simonnolkuchak@com", + Password = "1178", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "another boy" }, + new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + } + }; + } + + [TestMethod] + public void Country_Get_All() + { + //Arrange + //mockRepository.Setup(x => x.GetAll()).Returns(listUser); + + //Act + List results = _service.GetAll() as List; + + //Assert + + Assert.AreEqual(2, results.Count); + } + + + [TestMethod] + public void Can_Add_Country() + { + //Arrange + int Id = 123; + UserDTO user = new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + }; + + + + //Act + _service.CreateUser(user); + + //Assert + Assert.AreEqual(Id, user.User_ID); + _mockUnitWork.Verify(m => m.Save(), Times.Once); + } + + +} +} \ No newline at end of file diff --git a/UnitTestProject1/UnitTestProject1.csproj b/UnitTestProject1/UnitTestProject1.csproj new file mode 100644 index 0000000..21b4ff5 --- /dev/null +++ b/UnitTestProject1/UnitTestProject1.csproj @@ -0,0 +1,196 @@ + + + + + + + + Debug + AnyCPU + {8B8D5CC4-86F5-4793-89EB-296325CA02F9} + Library + Properties + UnitTestProject1 + UnitTestProject1 + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\packages\EntityFramework.6.4.0-preview3-19553-01\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.0-preview3-19553-01\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll + + + ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.InMemory.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.InMemory.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll + + + + + + ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll + + + + + + + + + + + + + + + + + + {edec0e39-cc42-426b-8773-f9356ba20df9} + uthTrip.BLL + + + {f78c2ccb-0aa4-48f9-8dc1-9f65a5135e05} + uthTrip.DAL + + + {32e72533-0bdc-440a-9540-af7783555306} + UthTripProject + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + \ No newline at end of file diff --git a/UnitTestProject1/UserServiceTest.cs b/UnitTestProject1/UserServiceTest.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/UnitTestProject1/UserServiceTest.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/uthTrip.DAL/EF/uthtripContext.cs b/uthTrip.DAL/EF/uthtripContext.cs index 80e3c4c..c214091 100644 --- a/uthTrip.DAL/EF/uthtripContext.cs +++ b/uthTrip.DAL/EF/uthtripContext.cs @@ -1,12 +1,19 @@ namespace uthTrip.DAL.EF { + using System.Data.Common; + using System.Data; using System; using System.Data.Entity; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +<<<<<<< Updated upstream using uthTrip.DAL.Entities; public partial class uthtripContext : DbContext +======= + using UthTrip.DAL.Entities; + public partial class UthTripContext : DbContext +>>>>>>> Stashed changes { private string connectionString; @@ -18,6 +25,11 @@ public uthtripContext() : base("name=uthtripContext") { } + public UthTripContext(DbConnection connection) + : base(connection, true) + { + Configuration.LazyLoadingEnabled = false; + } public virtual DbSet Blocked_Users { get; set; } public virtual DbSet Dates_ranges { get; set; } diff --git a/uthTrip.Tests/App.config b/uthTrip.Tests/App.config index 5543d1c..b5dfb58 100644 --- a/uthTrip.Tests/App.config +++ b/uthTrip.Tests/App.config @@ -48,6 +48,7 @@ +<<<<<<< Updated upstream @@ -68,6 +69,8 @@ +======= +>>>>>>> Stashed changes @@ -76,6 +79,7 @@ +<<<<<<< Updated upstream @@ -162,6 +166,10 @@ +======= + + +>>>>>>> Stashed changes diff --git a/uthTrip.Tests/UserServiceTEst.cs b/uthTrip.Tests/UserServiceTEst.cs new file mode 100644 index 0000000..aa9a965 --- /dev/null +++ b/uthTrip.Tests/UserServiceTEst.cs @@ -0,0 +1,197 @@ +using System; +using Xunit; +using UthTrip.DAL.EF; +using UthTrip.DAL.Entities; +using System.Collections.Generic; +using UthTrip.DAL.Repositories; +using Moq; +using UthTrip.BLL.DTO; +using System.Data.Entity; +using System.Linq; +using Effort; +using UthTrip.BLL.Services; +using System.Data; +using System.Data.Common; +namespace UnitTestProject1 +{ + + public class UserServiceTest:IDisposable + { + DbConnection connection; + UthTripContext databaseContext; + + UserService CreateUserService() + { + connection = Effort.DbConnectionFactory.CreateTransient(); + databaseContext = new UthTripContext(connection); + return new UserService(new EFUnitOfWork(databaseContext)); + } + + public void Dispose() + { + databaseContext.Dispose(); + + } + [Fact] + public void TestCreateUserMethod() + { + var userService = CreateUserService(); + + + userService.CreateUser(new UserDTO + { + User_ID = 132, + First_Name = "Yaroslav", + Last_Name = "Nolkuchak", + Username = "user2", + Email = "simonnolkuchak@com", + Password = "1178", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "another boy" + }); + userService.CreateUser(new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + }); + + + + int res = userService.GetAll().Count(); + + Assert.Equal(2, res); + + } + + [Fact] + public void TestDeleteUserMethod() + { var userService = CreateUserService(); + + + + userService.CreateUser(new UserDTO + { + User_ID = 132, + First_Name = "Yaroslav", + Last_Name = "Nolkuchak", + Username = "user2", + Email = "simonnolkuchak@com", + Password = "1178", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "another boy" + }); + userService.CreateUser(new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + }); + + + var user = userService.GetAll().FirstOrDefault(); + userService.Dispose(user.User_ID); + int res = userService.GetAll().Count(); + + Assert.Equal(1, res); + + } + [Fact] + public void TestGetByID() + { + + + var userService = CreateUserService(); + userService.CreateUser(new UserDTO + { + User_ID = 132, + First_Name = "Yaroslav", + Last_Name = "Nolkuchak", + Username = "user2", + Email = "simonnolkuchak@com", + Password = "1178", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "another boy" + }); + userService.CreateUser(new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + }); + + var user = userService.GetAll().FirstOrDefault(); + Assert.NotNull(userService.GetById(user.User_ID)); + + + + } + + + +[Fact] +public void TestFindMax_Id() +{ + + var userService = CreateUserService(); + userService.CreateUser(new UserDTO + { + User_ID = 132, + First_Name = "Yaroslav", + Last_Name = "Nolkuchak", + Username = "user2", + Email = "simonnolkuchak@com", + Password = "1178", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "another boy" + }); + userService.CreateUser(new UserDTO + { + User_ID = 123, + First_Name = "Simon", + Last_Name = "Gilbert", + Username = "simongilbert", + Email = "simongilbert@com", + Password = "1111", + Birthday = DateTime.Now, + Photo_Url = "www", + Info = "some boy" + }); + + var user = userService.GetAll().FirstOrDefault(); + + Assert.Equal(2, userService.FindMaxId()); + + + +} + + + + + + + } +} \ No newline at end of file diff --git a/uthTrip.Tests/packages.config b/uthTrip.Tests/packages.config index c6b74cb..8fe87f0 100644 --- a/uthTrip.Tests/packages.config +++ b/uthTrip.Tests/packages.config @@ -1,7 +1,27 @@  +<<<<<<< Updated upstream +======= + + + +>>>>>>> Stashed changes + +<<<<<<< Updated upstream +======= + + + + + + + + + + +>>>>>>> Stashed changes \ No newline at end of file diff --git a/uthTrip.Tests/uthTrip.Tests.csproj b/uthTrip.Tests/uthTrip.Tests.csproj index 19e9a38..d1e6c74 100644 --- a/uthTrip.Tests/uthTrip.Tests.csproj +++ b/uthTrip.Tests/uthTrip.Tests.csproj @@ -1,5 +1,6 @@  + @@ -41,6 +42,15 @@ 4 +<<<<<<< Updated upstream +======= + + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\packages\Effort.EF6.2.2.7\lib\net45\Effort.dll + +>>>>>>> Stashed changes ..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.dll @@ -54,15 +64,70 @@ ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll +<<<<<<< Updated upstream +======= + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + ..\packages\Moq.4.13.1\lib\net45\Moq.dll + + + ..\packages\NMemory.3.1.0\lib\net45\NMemory.dll + +>>>>>>> Stashed changes ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll +<<<<<<< Updated upstream +======= + + + ..\packages\System.Data.Common.4.3.0\lib\net451\System.Data.Common.dll + True + True + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + + ..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + + + ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll + +>>>>>>> Stashed changes - + @@ -83,6 +148,15 @@ uthTripProject +<<<<<<< Updated upstream +======= + + + + + + +>>>>>>> Stashed changes @@ -94,7 +168,10 @@ + + + \ No newline at end of file diff --git a/uthTripProject.sln b/uthTripProject.sln index c357c38..9733290 100644 --- a/uthTripProject.sln +++ b/uthTripProject.sln @@ -9,10 +9,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.DAL", "uthTrip.DAL\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.BLL", "uthTrip.BLL\uthTrip.BLL.csproj", "{EDEC0E39-CC42-426B-8773-F9356BA20DF9}" EndProject +<<<<<<< Updated upstream <<<<<<< HEAD <<<<<<< HEAD Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{8B8D5CC4-86F5-4793-89EB-296325CA02F9}" ======= +======= +>>>>>>> Stashed changes Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uthTrip.Tests", "uthTrip.Tests\uthTrip.Tests.csproj", "{92D1958E-8110-402B-8A96-4C7FE9FFF0EC}" >>>>>>> parent of 3e60396... added unit tests to userservice EndProject @@ -36,6 +39,7 @@ Global {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDEC0E39-CC42-426B-8773-F9356BA20DF9}.Release|Any CPU.Build.0 = Release|Any CPU +<<<<<<< Updated upstream <<<<<<< HEAD <<<<<<< HEAD {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -43,6 +47,8 @@ Global {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {8B8D5CC4-86F5-4793-89EB-296325CA02F9}.Release|Any CPU.Build.0 = Release|Any CPU ======= +======= +>>>>>>> Stashed changes {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {92D1958E-8110-402B-8A96-4C7FE9FFF0EC}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/uthTripProject/Web.config b/uthTripProject/Web.config index e47cfbe..4bddc3b 100644 --- a/uthTripProject/Web.config +++ b/uthTripProject/Web.config @@ -9,8 +9,15 @@
+<<<<<<< Updated upstream +======= + + + + +>>>>>>> Stashed changes From 272a3ec5e33fd3245c3c03687b05c444c00381c0 Mon Sep 17 00:00:00 2001 From: nadiapadalka Date: Sat, 7 Dec 2019 13:06:13 +0200 Subject: [PATCH 09/11] Revert "Merge branch 'master' into nadibranch" This reverts commit 3cb1a579317fab49a26b2752872a4b7b3665532e, reversing changes made to b73ea823a66c59fb6772495cb9e5bec9e42d9fa5. --- Tests/Properties/AssemblyInfo.cs | 20 - Tests/Tests.csproj | 544 ---------- Tests/UnitTest1.cs | 45 - Tests/app.config | 95 -- Tests/packages.config | 154 --- UnitTestProject1/Properties/AssemblyInfo.cs | 20 - UnitTestProject1/UnitTest1.cs | 179 +--- UnitTestProject1/UnitTestProject1.csproj | 2 - UnitTestProject1/app.config | 8 +- UnitTestProject1/packages.config | 41 - UnitTests/Properties/AssemblyInfo.cs | 20 - UnitTests/UnitTest1.cs | 29 - UnitTests/UnitTests.csproj | 84 -- UnitTests/packages.config | 10 - user.css | 3 - uthTrip.BLL/App.config | 9 +- uthTrip.BLL/DTO/BlockedUsersDTO.cs | 33 +- uthTrip.BLL/DTO/DatesRangeDTO.cs | 31 +- uthTrip.BLL/DTO/DestinationDTO.cs | 36 +- uthTrip.BLL/DTO/ReviewDTO.cs | 29 +- uthTrip.BLL/DTO/RightDTO.cs | 31 +- uthTrip.BLL/DTO/RoleDTO.cs | 17 +- uthTrip.BLL/DTO/TripDTO.cs | 52 +- uthTrip.BLL/DTO/UserDTO.cs | 55 +- uthTrip.BLL/Infrastructure/ServiceModule.cs | 26 +- .../Infrastructure/ValidationException.cs | 24 +- uthTrip.BLL/Interfaces/IDateRangeService.cs | 29 +- uthTrip.BLL/Interfaces/IDestinationService.cs | 29 +- uthTrip.BLL/Interfaces/IReviewService.cs | 21 - uthTrip.BLL/Interfaces/IRightsService.cs | 28 - uthTrip.BLL/Interfaces/ITripService.cs | 38 +- uthTrip.BLL/Interfaces/IUserService.cs | 53 +- uthTrip.BLL/Properties/AssemblyInfo.cs | 4 +- uthTrip.BLL/Services/DateRangeService.cs | 118 +-- uthTrip.BLL/Services/DestinationService.cs | 124 ++- uthTrip.BLL/Services/ReviewService.cs | 64 -- uthTrip.BLL/Services/RightsService.cs | 121 --- uthTrip.BLL/Services/TripService.cs | 171 ++-- uthTrip.BLL/Services/UserService.cs | 286 +----- uthTrip.BLL/packages.config | 25 - uthTrip.BLL/stylecop.json | 14 - uthTrip.BLL/uthTrip.BLL.csproj | 79 -- uthTrip.DAL/App.config | 7 +- uthTrip.DAL/Class1.cs | 14 +- uthTrip.DAL/EF/uthtripContext.cs | 29 +- uthTrip.DAL/Entities/Blocked_Users.cs | 2 +- uthTrip.DAL/Entities/Dates_ranges.cs | 8 +- uthTrip.DAL/Entities/Destination.cs | 8 +- uthTrip.DAL/Entities/Review.cs | 2 +- uthTrip.DAL/Entities/Right.cs | 2 +- uthTrip.DAL/Entities/Role.cs | 8 +- uthTrip.DAL/Entities/Trip.cs | 12 +- uthTrip.DAL/Entities/User.cs | 22 +- uthTrip.DAL/Interfaces/IRepository.cs | 26 +- uthTrip.DAL/Interfaces/IUnitOfWork.cs | 24 +- uthTrip.DAL/Properties/AssemblyInfo.cs | 4 +- .../Repositories/BlockedUserRepository.cs | 62 +- .../Repositories/DateRangeRepository.cs | 59 +- .../Repositories/DestinationRepository.cs | 60 +- uthTrip.DAL/Repositories/EFUnitOfWork.cs | 142 +-- uthTrip.DAL/Repositories/ReviewRepository.cs | 61 +- uthTrip.DAL/Repositories/RightRepository.cs | 58 +- uthTrip.DAL/Repositories/RoleRepository.cs | 58 +- uthTrip.DAL/Repositories/TripRepository.cs | 61 +- uthTrip.DAL/Repositories/UserRepository.cs | 54 +- uthTrip.DAL/packages.config | 23 +- uthTrip.DAL/uthTrip.DAL.csproj | 79 +- uthTrip.Tests/Properties/AssemblyInfo.cs | 4 +- uthTrip.Tests/UnitTest1.cs | 279 +++-- uthTrip.Tests/packages.config | 17 +- uthTrip.Tests/uthTrip.Tests.csproj | 34 +- uthTripProject.sln | 31 +- uthTripProject/App_Start/BundleConfig.cs | 13 +- uthTripProject/App_Start/FilterConfig.cs | 8 +- uthTripProject/App_Start/IdentityConfig.cs | 197 ++-- uthTripProject/App_Start/RouteConfig.cs | 19 +- uthTripProject/App_Start/Startup.Auth.cs | 88 +- uthTripProject/Content/Site.css | 9 +- uthTripProject/Content/createTrip.css | 97 -- uthTripProject/Content/home.css | 187 ---- uthTripProject/Content/layout.css | 18 - uthTripProject/Content/login.css | 66 -- uthTripProject/Content/myTrips.css | 121 --- uthTripProject/Content/registration.css | 65 -- uthTripProject/Content/tripDetail.css | 62 -- .../Controllers/AccountController.cs | 967 +++++++++--------- .../Controllers/ChooseTripController.cs | 46 - uthTripProject/Controllers/FaqController.cs | 28 - uthTripProject/Controllers/HelloController.cs | 57 +- uthTripProject/Controllers/Helper.cs | 61 -- uthTripProject/Controllers/HomeController.cs | 185 ++-- .../Controllers/ManageController.cs | 775 +++++++------- .../Controllers/ReviewController.cs | 59 -- uthTripProject/Controllers/TripController.cs | 86 +- .../Controllers/TripDetailController.cs | 95 -- uthTripProject/Controllers/UserController.cs | 235 ++--- uthTripProject/Global.asax | 2 +- uthTripProject/Global.asax.cs | 44 +- uthTripProject/Models/ReviewViewModel.cs | 36 - uthTripProject/Models/TripViewModel.cs | 87 +- uthTripProject/Models/UserBlockedModel.cs | 50 - uthTripProject/Models/UserViewModel.cs | 52 +- uthTripProject/Properties/AssemblyInfo.cs | 4 +- uthTripProject/Startup.cs | 7 +- uthTripProject/Util/DateRangesModule.cs | 20 +- uthTripProject/Util/DestinationModule.cs | 20 +- uthTripProject/Util/TripModule.cs | 27 +- uthTripProject/Util/UserModule.cs | 20 +- uthTripProject/Views/Account/EditData.cshtml | 12 - .../Account/ExternalLoginConfirmation.cshtml | 2 +- .../Views/Account/ForgotPassword.cshtml | 2 +- uthTripProject/Views/Account/Login.cshtml | 4 +- uthTripProject/Views/Account/Register.cshtml | 2 +- .../Views/Account/ResetPassword.cshtml | 2 +- uthTripProject/Views/Account/SendCode.cshtml | 2 +- .../Views/Account/VerifyCode.cshtml | 2 +- .../Account/_ExternalLoginsListPartial.cshtml | 2 +- .../Views/ChooseTrip/ChooseTrip.cshtml | 7 - uthTripProject/Views/Hello/HelloPage.cshtml | 2 +- uthTripProject/Views/Home/About.cshtml | 1 - uthTripProject/Views/Home/Created.cshtml | 96 -- uthTripProject/Views/Home/MyTrips.cshtml | 139 --- uthTripProject/Views/Home/StartPage.cshtml | 182 ++-- .../Views/Manage/AddPhoneNumber.cshtml | 2 +- .../Views/Manage/ChangePassword.cshtml | 2 +- uthTripProject/Views/Manage/Index.cshtml | 2 +- .../Views/Manage/ManageLogins.cshtml | 2 +- .../Views/Manage/SetPassword.cshtml | 2 +- .../Views/Manage/VerifyPhoneNumber.cshtml | 2 +- .../Views/Review/WriteReview.cshtml | 112 -- uthTripProject/Views/Shared/_Layout.cshtml | 10 +- uthTripProject/Views/Trip/Create.cshtml | 272 +++-- .../Views/TripDetail/TripDetail.cshtml | 118 --- uthTripProject/Views/TripDetail/myphoto.png | Bin 297787 -> 0 bytes uthTripProject/Views/User/AddOrEdit.cshtml | 125 +++ uthTripProject/Views/User/AllUsers.cshtml | 157 --- uthTripProject/Views/User/LogOut.cshtml | 7 - uthTripProject/Views/User/Login.cshtml | 93 +- uthTripProject/Views/User/Register.cshtml | 126 --- uthTripProject/Views/User/UserHome.cshtml | 2 +- uthTripProject/Views/User/UserProfile.cshtml | 124 --- uthTripProject/Views/Web.config | 2 +- uthTripProject/Views/photoes/logo2.jfif | Bin 29575 -> 0 bytes uthTripProject/Web.config | 273 +---- uthTripProject/packages.config | 16 +- uthTripProject/uthTripProject.csproj | 75 +- 146 files changed, 2753 insertions(+), 7192 deletions(-) delete mode 100644 Tests/Properties/AssemblyInfo.cs delete mode 100644 Tests/Tests.csproj delete mode 100644 Tests/UnitTest1.cs delete mode 100644 Tests/app.config delete mode 100644 Tests/packages.config delete mode 100644 UnitTestProject1/Properties/AssemblyInfo.cs delete mode 100644 UnitTestProject1/packages.config delete mode 100644 UnitTests/Properties/AssemblyInfo.cs delete mode 100644 UnitTests/UnitTest1.cs delete mode 100644 UnitTests/UnitTests.csproj delete mode 100644 UnitTests/packages.config delete mode 100644 user.css delete mode 100644 uthTrip.BLL/Interfaces/IReviewService.cs delete mode 100644 uthTrip.BLL/Interfaces/IRightsService.cs delete mode 100644 uthTrip.BLL/Services/ReviewService.cs delete mode 100644 uthTrip.BLL/Services/RightsService.cs delete mode 100644 uthTrip.BLL/stylecop.json delete mode 100644 uthTripProject/Content/createTrip.css delete mode 100644 uthTripProject/Content/home.css delete mode 100644 uthTripProject/Content/layout.css delete mode 100644 uthTripProject/Content/login.css delete mode 100644 uthTripProject/Content/myTrips.css delete mode 100644 uthTripProject/Content/registration.css delete mode 100644 uthTripProject/Content/tripDetail.css delete mode 100644 uthTripProject/Controllers/ChooseTripController.cs delete mode 100644 uthTripProject/Controllers/FaqController.cs delete mode 100644 uthTripProject/Controllers/Helper.cs delete mode 100644 uthTripProject/Controllers/ReviewController.cs delete mode 100644 uthTripProject/Controllers/TripDetailController.cs delete mode 100644 uthTripProject/Models/ReviewViewModel.cs delete mode 100644 uthTripProject/Models/UserBlockedModel.cs delete mode 100644 uthTripProject/Views/Account/EditData.cshtml delete mode 100644 uthTripProject/Views/ChooseTrip/ChooseTrip.cshtml delete mode 100644 uthTripProject/Views/Home/Created.cshtml delete mode 100644 uthTripProject/Views/Home/MyTrips.cshtml delete mode 100644 uthTripProject/Views/Review/WriteReview.cshtml delete mode 100644 uthTripProject/Views/TripDetail/TripDetail.cshtml delete mode 100644 uthTripProject/Views/TripDetail/myphoto.png create mode 100644 uthTripProject/Views/User/AddOrEdit.cshtml delete mode 100644 uthTripProject/Views/User/AllUsers.cshtml delete mode 100644 uthTripProject/Views/User/LogOut.cshtml delete mode 100644 uthTripProject/Views/User/Register.cshtml delete mode 100644 uthTripProject/Views/User/UserProfile.cshtml delete mode 100644 uthTripProject/Views/photoes/logo2.jfif diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e6f8c..0000000 --- a/Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("ddc86d49-c599-4782-b3e4-d66167bac90f")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj deleted file mode 100644 index ce0f36a..0000000 --- a/Tests/Tests.csproj +++ /dev/null @@ -1,544 +0,0 @@ - - - - - - - - - - - Debug - AnyCPU - {DDC86D49-C599-4782-B3E4-D66167BAC90F} - Library - Properties - Tests - Tests - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll - - - ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll - - - ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll - - - ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll - - - ..\packages\Microsoft.AspNetCore.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cors.dll - - - ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll - - - ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll - - - ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Http.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll - - - ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll - - - ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll - - - ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll - - - ..\packages\Microsoft.AspNetCore.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.ApiExplorer.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ApiExplorer.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Cors.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.RazorPages.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.TagHelpers.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll - - - ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll - - - ..\packages\Microsoft.AspNetCore.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll - - - ..\packages\Microsoft.AspNetCore.Razor.Language.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Language.dll - - - ..\packages\Microsoft.AspNetCore.Razor.Runtime.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll - - - ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.Routing.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll - - - ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll - - - ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll - - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview2.19523.17\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\Microsoft.CodeAnalysis.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.dll - - - ..\packages\Microsoft.CodeAnalysis.CSharp.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll - - - ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll - - - ..\packages\Microsoft.CodeAnalysis.Razor.3.1.0-preview2.19528.1\lib\netstandard2.0\Microsoft.CodeAnalysis.Razor.dll - - - ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.4.0-beta2-final\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll - - - - ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview2.19525.4\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview2.19525.4\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll - - - ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll - - - ..\packages\Microsoft.Extensions.FileProviders.Composite.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Composite.dll - - - ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll - - - ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll - - - ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll - - - ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Contracts.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Core.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Core.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Templating.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Templating.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGeneration.Utils.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGeneration.Utils.dll - - - ..\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.3.1.0-preview2.19553.1\lib\netstandard2.0\Microsoft.VisualStudio.Web.CodeGenerators.Mvc.dll - - - ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Newtonsoft.Json.Bson.1.0.1\lib\net45\Newtonsoft.Json.Bson.dll - - - ..\packages\NuGet.Frameworks.4.7.0\lib\net46\NuGet.Frameworks.dll - - - - ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll - True - True - - - ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll - - - ..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll - - - ..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll - - - ..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll - - - ..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll - - - - ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll - True - True - - - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll - True - True - - - ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll - True - True - - - - ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll - True - True - - - ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll - True - True - - - ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll - True - True - - - ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll - True - True - - - ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll - True - True - - - ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll - True - True - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll - True - True - - - ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll - - - ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll - True - True - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll - True - True - - - ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll - True - True - - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - True - - - - ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll - - - ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll - True - True - - - ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - True - True - - - ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - True - True - - - ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll - True - True - - - ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll - - - ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll - - - ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll - - - - ..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll - - - ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll - True - True - - - - ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll - True - True - - - - - ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll - True - True - - - ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll - True - True - - - ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll - True - True - - - ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll - True - True - - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - - - - - - - - - - - - - - - - - - {edec0e39-cc42-426b-8773-f9356ba20df9} - uthTrip.BLL - - - {f78c2ccb-0aa4-48f9-8dc1-9f65a5135e05} - uthTrip.DAL - - - {32e72533-0bdc-440a-9540-af7783555306} - uthTripProject - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs deleted file mode 100644 index 7c33807..0000000 --- a/Tests/UnitTest1.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; -using System.Linq; -//using Microsoft.AspNetCore.Mvc; -using uthTrip.BLL.Services; -using uthTrip.DAL.Interfaces; -using uthTrip.BLL.Interfaces; -using Moq; -using Xunit; -using uthTripProject.Controllers; -using System.Web; -namespace Tests -{ - - public class UnitTest1 - { - [Fact] - public void Index_View_Result() - { - // Setup - var expectedUserAccountCount = 2; - - var mockUserAccountService = new Mock(); - - mockUserAccountService.Setup(x => x.GetAll()) - .Returns(GetTestUserAccounts()); - - // Inject - var homeController = new UserController(mockUserAccountService.Object); - - // Act - var result = homeController.Index(); - - // Assert - var viewResult = Assert.IsType(result); - - var model = Assert.IsAssignableFrom>( - viewResult.ViewData.Model); - - Assert.Equal(expectedUserAccountCount, model.Count()); - } - - } -} diff --git a/Tests/app.config b/Tests/app.config deleted file mode 100644 index 9ccae07..0000000 --- a/Tests/app.config +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/packages.config b/Tests/packages.config deleted file mode 100644 index 4a68283..0000000 --- a/Tests/packages.config +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTestProject1/Properties/AssemblyInfo.cs b/UnitTestProject1/Properties/AssemblyInfo.cs deleted file mode 100644 index 5780228..0000000 --- a/UnitTestProject1/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("UnitTestProject1")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UnitTestProject1")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("8b8d5cc4-86f5-4793-89eb-296325ca02f9")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTestProject1/UnitTest1.cs b/UnitTestProject1/UnitTest1.cs index 91a65b4..ac8b4ef 100644 --- a/UnitTestProject1/UnitTest1.cs +++ b/UnitTestProject1/UnitTest1.cs @@ -1,12 +1,8 @@ namespace UnitTestProject1 { using System; - using System.Collections.Generic + using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Data.Entity; - using System.Linq; - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.InMemory; using Moq; using UthTrip.BLL.DTO; using UthTrip.BLL.Services; @@ -29,134 +25,6 @@ public void Initialize() _service = new UserService(_mockUnitWork.Object); listUser = new List() { new UserDTO{ - - using Xunit; - - public class UnitTest1 : IDisposable - { - public void Dispose() - { - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "UserDatabase").Options; - - var context = new UthTripContext(options); - context.Users.RemoveRange(context.Users); - context.SaveChanges(); - } - - [Fact] - public void TestCreateUserMethod() - { - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "UserDatabase").Options; - var userService = this.CreateUserService(); - - userService.CreateUser(new UserDTO - { - User_ID = 132, - First_Name = "Yaroslav", - Last_Name = "Nolkuchak", - Username = "user2", - Email = "simonnolkuchak@com", - Password = "1178", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "another boy", - }); - userService.CreateUser(new UserDTO - { - User_ID = 123, - First_Name = "Simon", - Last_Name = "Gilbert", - Username = "simongilbert", - Email = "simongilbert@com", - Password = "1111", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "some boy", - }); - // Use a clean instance of the context to run the test - int res = userService.GetAll().Count(); - - Assert.Equal(2, res); - } - - [Fact] - public void TestDeleteUserMethod() - { - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "UsersDatabase").Options; - var userService = this.CreateUserService(); - - userService.CreateUser(new UserDTO - { - User_ID = 132, - First_Name = "Yaroslav", - Last_Name = "Nolkuchak", - Username = "user2", - Email = "simonnolkuchak@com", - Password = "1178", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "another boy", - }); - userService.CreateUser(new UserDTO - { - User_ID = 123, - First_Name = "Simon", - Last_Name = "Gilbert", - Username = "simongilbert", - Email = "simongilbert@com", - Password = "1111", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "some boy", - }); - userService.Dispose(123); - int res = userService.GetAll().Count(); - - Assert.Equal(1, res); - } - - [Fact] - public void TestGetByID() - { - var userService = this.CreateUserService(); - userService.CreateUser(new UserDTO - { - User_ID = 132, - First_Name = "Yaroslav", - Last_Name = "Nolkuchak", - Username = "user2", - Email = "simonnolkuchak@com", - Password = "1178", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "another boy", - }); - userService.CreateUser(new UserDTO - { - User_ID = 123, - First_Name = "Simon", - Last_Name = "Gilbert", - Username = "simongilbert", - Email = "simongilbert@com", - Password = "1111", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "some boy", - }); - - var user = userService.GetAll().FirstOrDefault(); - Assert.NotNull(userService.GetById(user.User_ID)); - } - - [Fact] - public void TestGetUserName_Password() - { - var userService = this.CreateUserService(); - userService.CreateUser(new UserDTO - { User_ID = 132, First_Name = "Yaroslav", Last_Name = "Nolkuchak", @@ -167,9 +35,6 @@ public void TestGetUserName_Password() Photo_Url = "www", Info = "another boy" }, new UserDTO - Info = "another boy", - }); - userService.CreateUser(new UserDTO { User_ID = 123, First_Name = "Simon", @@ -205,31 +70,6 @@ public void Can_Add_Country() //Arrange int Id = 123; UserDTO user = new UserDTO - - Info = "some boy", - }); - - var user = userService.GetAll().FirstOrDefault(); - Assert.NotNull(userService.GetByUsernamePassword("simongilbert", "1111")); - } - - [Fact] - public void TestFindMax_Id() - { - var userService = this.CreateUserService(); - userService.CreateUser(new UserDTO - { - User_ID = 132, - First_Name = "Yaroslav", - Last_Name = "Nolkuchak", - Username = "user2", - Email = "simonnolkuchak@com", - Password = "1178", - Birthday = DateTime.Now, - Photo_Url = "www", - Info = "another boy", - }); - userService.CreateUser(new UserDTO { User_ID = 123, First_Name = "Simon", @@ -254,21 +94,4 @@ public void TestFindMax_Id() } - - Info = "some boy", - }); - - var user = userService.GetAll().FirstOrDefault(); - Assert.Equal(132, userService.FindMaxId()); - } - - private UserService CreateUserService() - { - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "UserDatabase").Options; - return new UserService( - new EFUnitOfWork( - new UthTripContext(options))); - } - } } \ No newline at end of file diff --git a/UnitTestProject1/UnitTestProject1.csproj b/UnitTestProject1/UnitTestProject1.csproj index 34a354f..21b4ff5 100644 --- a/UnitTestProject1/UnitTestProject1.csproj +++ b/UnitTestProject1/UnitTestProject1.csproj @@ -153,8 +153,6 @@ - - diff --git a/UnitTestProject1/app.config b/UnitTestProject1/app.config index 890c397..37a0dc9 100644 --- a/UnitTestProject1/app.config +++ b/UnitTestProject1/app.config @@ -1,6 +1,7 @@  +
@@ -53,7 +54,6 @@ -<<<<<< nadibranch @@ -94,7 +94,6 @@ - @@ -102,7 +101,4 @@ - - - - + \ No newline at end of file diff --git a/UnitTestProject1/packages.config b/UnitTestProject1/packages.config deleted file mode 100644 index adc88d6..0000000 --- a/UnitTestProject1/packages.config +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index bffcdc5..0000000 --- a/UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("UnitTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UnitTests")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("4a5a0491-90e9-42ef-9f0d-cf980a763af7")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTests/UnitTest1.cs b/UnitTests/UnitTest1.cs deleted file mode 100644 index 1368e4e..0000000 --- a/UnitTests/UnitTest1.cs +++ /dev/null @@ -1,29 +0,0 @@ -//using System; -//using Microsoft.VisualStudio.TestTools.UnitTesting; -//using System.Web.Mvc; -//using Moq; -//namespace UnitTests -//{ -// [TestClass] -// public class UnitTest1 -// { -// [TestMethod] -// public void Sum_Products_Correctly() -// { -// // Arrange (добавляем имитированный объект) -// Mock mock = new Mock(); -// mock.Setup(m => m.GetAll()); - -// UserController controller = new UserController(mock.Object); -// string expected = "В базе данных 1 объект"; - -// // Act -// controller.Index(); -// ViewResult result = controller.Index() as ViewResult; -// string actual = result.ViewBag.Message as string; - -// // Assert -// Assert.AreEqual(expected, actual); -// } -// } -//} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj deleted file mode 100644 index 259885b..0000000 --- a/UnitTests/UnitTests.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - Debug - AnyCPU - {4A5A0491-90E9-42EF-9F0D-CF980A763AF7} - Library - Properties - UnitTests - UnitTests - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.Web.Mvc.Extensions.1.1.1.2\lib\net45\System.Web.Mvc.Extensions.dll - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/UnitTests/packages.config b/UnitTests/packages.config deleted file mode 100644 index ac38aa6..0000000 --- a/UnitTests/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/user.css b/user.css deleted file mode 100644 index 0e36810..0000000 --- a/user.css +++ /dev/null @@ -1,3 +0,0 @@ -body -{ -} \ No newline at end of file diff --git a/uthTrip.BLL/App.config b/uthTrip.BLL/App.config index 711ef89..2c06cb9 100644 --- a/uthTrip.BLL/App.config +++ b/uthTrip.BLL/App.config @@ -1,6 +1,8 @@  - + +<<<<<<< Updated upstream +======= @@ -248,8 +250,5 @@ - - - - +>>>>>>> Stashed changes \ No newline at end of file diff --git a/uthTrip.BLL/DTO/BlockedUsersDTO.cs b/uthTrip.BLL/DTO/BlockedUsersDTO.cs index b5134b7..cdbd1ed 100644 --- a/uthTrip.BLL/DTO/BlockedUsersDTO.cs +++ b/uthTrip.BLL/DTO/BlockedUsersDTO.cs @@ -1,31 +1,14 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; - public class BlockedUsersDTO +namespace uthTrip.BLL.DTO +{ + class BlockedUsersDTO { - public BlockedUsersDTO() - { - - } - - public BlockedUsersDTO(int blocked_ID, int? user_ID) - { - Blocked_ID = blocked_ID; - User_ID = user_ID; - } - - public BlockedUsersDTO(int? user_ID) - { - User_ID = user_ID; - } - public int Blocked_ID { get; set; } - public int? User_ID { get; set; } } } diff --git a/uthTrip.BLL/DTO/DatesRangeDTO.cs b/uthTrip.BLL/DTO/DatesRangeDTO.cs index f3f096e..2a47272 100644 --- a/uthTrip.BLL/DTO/DatesRangeDTO.cs +++ b/uthTrip.BLL/DTO/DatesRangeDTO.cs @@ -1,28 +1,25 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace uthTrip.BLL.DTO +{ public class DatesRangeDTO { + public int Date_ID { get; set; } + public DateTime? Start_date { get; set; } + public DateTime? End_date { get; set; } public DatesRangeDTO() { - } + } public DatesRangeDTO(int date_ID, DateTime? start_date, DateTime? end_date) { - this.Date_ID = date_ID; - this.Start_date = start_date; - this.End_date = end_date; + Date_ID = date_ID; + Start_date = start_date; + End_date = end_date; } - - public int Date_ID { get; set; } - - public DateTime? Start_date { get; set; } - - public DateTime? End_date { get; set; } } } diff --git a/uthTrip.BLL/DTO/DestinationDTO.cs b/uthTrip.BLL/DTO/DestinationDTO.cs index 0e65b18..20ecfda 100644 --- a/uthTrip.BLL/DTO/DestinationDTO.cs +++ b/uthTrip.BLL/DTO/DestinationDTO.cs @@ -1,31 +1,27 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace uthTrip.BLL.DTO +{ public class DestinationDTO { + public int Destination_ID { get; set; } + public bool Is_Abroad { get; set; } + public string Country { get; set; } + public string City { get; set; } public DestinationDTO() { - } + } public DestinationDTO(int destination_ID, bool is_Abroad, string country, string city) { - this.Destination_ID = destination_ID; - this.Is_Abroad = is_Abroad; - this.Country = country; - this.City = city; + Destination_ID = destination_ID; + Is_Abroad = is_Abroad; + Country = country; + City = city; } - - public int Destination_ID { get; set; } - - public bool Is_Abroad { get; set; } - - public string Country { get; set; } - - public string City { get; set; } } } diff --git a/uthTrip.BLL/DTO/ReviewDTO.cs b/uthTrip.BLL/DTO/ReviewDTO.cs index ddb6048..05f8804 100644 --- a/uthTrip.BLL/DTO/ReviewDTO.cs +++ b/uthTrip.BLL/DTO/ReviewDTO.cs @@ -1,30 +1,17 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; - public class ReviewDTO +namespace uthTrip.BLL.DTO +{ + class ReviewDTO { - public ReviewDTO(int review_ID, int writer_ID, int trip_ID, string review1, int? mark) - { - Review_ID = review_ID; - Writer_ID = writer_ID; - Trip_ID = trip_ID; - Review1 = review1; - Mark = mark; - } - public int Review_ID { get; set; } - public int Writer_ID { get; set; } - public int Trip_ID { get; set; } - public string Review1 { get; set; } - public int? Mark { get; set; } } } diff --git a/uthTrip.BLL/DTO/RightDTO.cs b/uthTrip.BLL/DTO/RightDTO.cs index 9007976..928e1e1 100644 --- a/uthTrip.BLL/DTO/RightDTO.cs +++ b/uthTrip.BLL/DTO/RightDTO.cs @@ -1,31 +1,16 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; - public class RightDTO +namespace uthTrip.BLL.DTO +{ + class RightDTO { public int Rights_ID { get; set; } - public int User_ID { get; set; } - public int Role_ID { get; set; } - public int Trip_ID { get; set; } - - public RightDTO() - { - } - - public RightDTO(int rights_ID, int user_ID, int role_ID, int trip_ID) - { - this.Rights_ID = rights_ID; - this.User_ID = user_ID; - this.Role_ID = role_ID; - this.Trip_ID = trip_ID; - } } } diff --git a/uthTrip.BLL/DTO/RoleDTO.cs b/uthTrip.BLL/DTO/RoleDTO.cs index 7e76289..076bf5a 100644 --- a/uthTrip.BLL/DTO/RoleDTO.cs +++ b/uthTrip.BLL/DTO/RoleDTO.cs @@ -1,15 +1,14 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; - public class RoleDTO +namespace uthTrip.BLL.DTO +{ + class RoleDTO { public int Role_ID { get; set; } - public string Title { get; set; } } } diff --git a/uthTrip.BLL/DTO/TripDTO.cs b/uthTrip.BLL/DTO/TripDTO.cs index 07e386c..38cd829 100644 --- a/uthTrip.BLL/DTO/TripDTO.cs +++ b/uthTrip.BLL/DTO/TripDTO.cs @@ -1,43 +1,35 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace uthTrip.BLL.DTO +{ public class TripDTO { - public TripDTO() - { - } - - public TripDTO(int trip_ID, string trip_Title, string description, double price, int date_ID, int number_Of_People, int destination_ID, int creator_ID) - { - this.Trip_ID = trip_ID; - this.Trip_Title = trip_Title; - this.Description = description; - this.Price = price; - this.Date_ID = date_ID; - this.Number_Of_People = number_Of_People; - this.Destination_ID = destination_ID; - this.Creator_ID = creator_ID; - } - public int Trip_ID { get; set; } - public string Trip_Title { get; set; } - public string Description { get; set; } - public double Price { get; set; } - public int Date_ID { get; set; } - public int Number_Of_People { get; set; } - public int Destination_ID { get; set; } - public int Creator_ID { get; set; } + public TripDTO() + { + + } + public TripDTO(int trip_ID, string trip_Title, string description, double price, int date_ID, int number_Of_People, int destination_ID, int creator_ID) + { + Trip_ID = trip_ID; + Trip_Title = trip_Title; + Description = description; + Price = price; + Date_ID = date_ID; + Number_Of_People = number_Of_People; + Destination_ID = destination_ID; + Creator_ID = creator_ID; + } } } diff --git a/uthTrip.BLL/DTO/UserDTO.cs b/uthTrip.BLL/DTO/UserDTO.cs index 8a924ed..c777d27 100644 --- a/uthTrip.BLL/DTO/UserDTO.cs +++ b/uthTrip.BLL/DTO/UserDTO.cs @@ -1,46 +1,37 @@ -namespace UthTrip.BLL.DTO -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using System.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace uthTrip.BLL.DTO +{ public class UserDTO { - public UserDTO() - { - } - - public UserDTO(int user_ID, string first_Name, string last_Name, string email, string username, string password, DateTime birthday, string photo_Url, string info) - { - this.User_ID = user_ID; - this.First_Name = first_Name; - this.Last_Name = last_Name; - this.Email = email; - this.Username = username; - this.Password = password; - this.Birthday = birthday; - this.Photo_Url = photo_Url; - this.Info = info; - } - public int User_ID { get; set; } - public string First_Name { get; set; } - public string Last_Name { get; set; } - public string Email { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public DateTime Birthday { get; set; } - public string Photo_Url { get; set; } - public string Info { get; set; } + public UserDTO() + { + + } + public UserDTO(int user_ID, string first_Name, string last_Name, string email, string username, string password, DateTime birthday, string photo_Url, string info) + { + User_ID = user_ID; + First_Name = first_Name; + Last_Name = last_Name; + Email = email; + Username = username; + Password = password; + Birthday = birthday; + Photo_Url = photo_Url; + Info = info; + } } } diff --git a/uthTrip.BLL/Infrastructure/ServiceModule.cs b/uthTrip.BLL/Infrastructure/ServiceModule.cs index 874f4e1..bab74d6 100644 --- a/uthTrip.BLL/Infrastructure/ServiceModule.cs +++ b/uthTrip.BLL/Infrastructure/ServiceModule.cs @@ -1,26 +1,24 @@ -namespace UthTrip.BLL.Infrastructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using Ninject.Modules; - using UthTrip.DAL.Interfaces; - using UthTrip.DAL.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Ninject.Modules; +using uthTrip.DAL.Interfaces; +using uthTrip.DAL.Repositories; +namespace uthTrip.BLL.Infrastructure +{ public class ServiceModule : NinjectModule { private string connectionString; - public ServiceModule(string connection) { - this.connectionString = connection; + connectionString = connection; } - public override void Load() { - this.Bind().To().WithConstructorArgument(this.connectionString); + Bind().To().WithConstructorArgument(connectionString); } } } diff --git a/uthTrip.BLL/Infrastructure/ValidationException.cs b/uthTrip.BLL/Infrastructure/ValidationException.cs index 84fb932..1509aca 100644 --- a/uthTrip.BLL/Infrastructure/ValidationException.cs +++ b/uthTrip.BLL/Infrastructure/ValidationException.cs @@ -1,19 +1,17 @@ -namespace UthTrip.BLL.Infrastructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace uthTrip.BLL.Infrastructure +{ public class ValidationException : Exception { - public ValidationException(string message, string prop) - : base(message) + public string Property { get; protected set; } + public ValidationException(string message, string prop) : base(message) { - this.Property = prop; + Property = prop; } - - public string Property { get; protected set; } - } + } } diff --git a/uthTrip.BLL/Interfaces/IDateRangeService.cs b/uthTrip.BLL/Interfaces/IDateRangeService.cs index d0f6d39..d9d09e4 100644 --- a/uthTrip.BLL/Interfaces/IDateRangeService.cs +++ b/uthTrip.BLL/Interfaces/IDateRangeService.cs @@ -1,26 +1,23 @@ -namespace UthTrip.BLL.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; + +namespace uthTrip.BLL.Interfaces +{ public interface IDateRangeService { void CreateDateRange(DatesRangeDTO dateRangeDto); - DatesRangeDTO GetById(int? id); - IEnumerable GetAll(); - void Dispose(int id); - int FindMaxId(); - ////int Authenticate(string username, string password); - //// void Update(User user, string password = null); - ////void Create(string username, string password); + //int Authenticate(string username, string password); + // void Update(User user, string password = null); + //void Create(string username, string password); } } diff --git a/uthTrip.BLL/Interfaces/IDestinationService.cs b/uthTrip.BLL/Interfaces/IDestinationService.cs index e71429a..f2722b1 100644 --- a/uthTrip.BLL/Interfaces/IDestinationService.cs +++ b/uthTrip.BLL/Interfaces/IDestinationService.cs @@ -1,26 +1,23 @@ -namespace UthTrip.BLL.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; + +namespace uthTrip.BLL.Interfaces +{ public interface IDestinationService { void CreateDestination(DestinationDTO destinationDto); - DestinationDTO GetById(int? id); - IEnumerable GetAll(); - void Dispose(int id); - int FindMaxId(); - ////int Authenticate(string username, string password); - //// void Update(User user, string password = null); - ////void Create(string username, string password); + //int Authenticate(string username, string password); + // void Update(User user, string password = null); + //void Create(string username, string password); } } diff --git a/uthTrip.BLL/Interfaces/IReviewService.cs b/uthTrip.BLL/Interfaces/IReviewService.cs deleted file mode 100644 index e42a421..0000000 --- a/uthTrip.BLL/Interfaces/IReviewService.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace UthTrip.BLL.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; - - public interface IReviewService - { - void CreateReview(ReviewDTO reviewDTO); - - IEnumerable GetAll(); - - IEnumerable GetAllTrips(); - - int FindMaxId(); - } -} diff --git a/uthTrip.BLL/Interfaces/IRightsService.cs b/uthTrip.BLL/Interfaces/IRightsService.cs deleted file mode 100644 index b53cd2c..0000000 --- a/uthTrip.BLL/Interfaces/IRightsService.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace UthTrip.BLL.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; - - public interface IRightsService - { - void CreateRights(RightDTO rightDto); - - RightDTO GetById(int? id); - - IEnumerable GetAll(); - - void Dispose(int id); - - int FindMaxId(); - - IEnumerable GetAllRoles(); - ////int Authenticate(string username, string password); - //// void Update(User user, string password = null); - ////void Create(string username, string password); - } -} diff --git a/uthTrip.BLL/Interfaces/ITripService.cs b/uthTrip.BLL/Interfaces/ITripService.cs index 0f1927d..f421327 100644 --- a/uthTrip.BLL/Interfaces/ITripService.cs +++ b/uthTrip.BLL/Interfaces/ITripService.cs @@ -1,40 +1,28 @@ -namespace UthTrip.BLL.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; + +namespace uthTrip.BLL.Interfaces +{ public interface ITripService { void CreateTrip(TripDTO tripDto, DestinationDTO destinationDTO, DatesRangeDTO datesRangeDTO); - TripDTO GetById(int? id); - IEnumerable GetAll(); - IEnumerable GetAllDist(); - IEnumerable GetAllDateRanges(); - IEnumerable GetAllRights(); - - IEnumerable GetAllUsers(); - - void Dispose(int id); - int FindMaxId(); - int FindMaxIdDestination(); - int FindMaxIdDateRange(); - - ////int Authenticate(string username, string password); - //// void Update(User user, string password = null); - ////void Create(string username, string password); + //int Authenticate(string username, string password); + // void Update(User user, string password = null); + //void Create(string username, string password); } } diff --git a/uthTrip.BLL/Interfaces/IUserService.cs b/uthTrip.BLL/Interfaces/IUserService.cs index fd82bcc..ee3bc5c 100644 --- a/uthTrip.BLL/Interfaces/IUserService.cs +++ b/uthTrip.BLL/Interfaces/IUserService.cs @@ -1,46 +1,33 @@ -namespace UthTrip.BLL.Interfaces +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.Interfaces; +using uthTrip.BLL.DTO; + +namespace uthTrip.BLL.Interfaces { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Interfaces; - public interface IUserService { void CreateUser(UserDTO userDto); - - void CreateBlocked(BlockedUsersDTO userDto); - UserDTO GetById(int? id); - - - UserDTO Get(int userAccountId); - string GetFirstName(int userAccountId); +<<<<<<< HEAD +<<<<<<< HEAD + UserDTO GetByUsernamePassword(string username, string password); +======= UserDTO GetByUsernamePassword(string username, string password); - +>>>>>>> parent of 3e60396... added unit tests to userservice +======= UserDTO Get(int userAccountId); - - UserDTO GetByUsernamePassword(string username, string password); - string GetFirstName(int userAccountId); - + UserDTO GetByUsernamePassword(string username, string password); +>>>>>>> parent of aa645ae... added unit tests for userservice IEnumerable GetAll(); - - IEnumerable GetAllReviews(); - - IEnumerable GetAllTrips(); - - IEnumerable GetAllBlocked(); - void Dispose(int id); - void DisposeBlocked(int id); - - int FindMaxId(); - - int FindMaxIdBl(); + //int Authenticate(string username, string password); + // void Update(User user, string password = null); + //void Create(string username, string password); } } diff --git a/uthTrip.BLL/Properties/AssemblyInfo.cs b/uthTrip.BLL/Properties/AssemblyInfo.cs index 338c0d0..36d5916 100644 --- a/uthTrip.BLL/Properties/AssemblyInfo.cs +++ b/uthTrip.BLL/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("UthTrip.BLL")] +[assembly: AssemblyTitle("uthTrip.BLL")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UthTrip.BLL")] +[assembly: AssemblyProduct("uthTrip.BLL")] [assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/uthTrip.BLL/Services/DateRangeService.cs b/uthTrip.BLL/Services/DateRangeService.cs index 740c6a6..10b0fc8 100644 --- a/uthTrip.BLL/Services/DateRangeService.cs +++ b/uthTrip.BLL/Services/DateRangeService.cs @@ -1,32 +1,30 @@ -namespace UthTrip.BLL.Services -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.Entities; - ////using UthTrip.BLL.BusinessModels; - using UthTrip.DAL.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.DTO; +using uthTrip.DAL.Entities; +//using uthTrip.BLL.BusinessModels; +using uthTrip.DAL.Interfaces; +using uthTrip.BLL.Infrastructure; +using uthTrip.BLL.Interfaces; +using AutoMapper; +namespace uthTrip.BLL.Services +{ public class DateRangeService : IDateRangeService { - public DateRangeService(IUnitOfWork uow) - { - this.Database = uow; - } - - private IUnitOfWork Database { get; set; } - + IUnitOfWork Database { get; set; } public int FindMaxId() { - int max = this.Database.Dates_ranges.MaxId(); + int max = Database.Dates_ranges.MaxId(); return max; } + public DateRangeService(IUnitOfWork uow) + { + Database = uow; + } public void CreateDateRange(DatesRangeDTO dateRangeDto) { @@ -34,71 +32,67 @@ public void CreateDateRange(DatesRangeDTO dateRangeDto) { Date_ID = dateRangeDto.Date_ID, Start_date = dateRangeDto.Start_date, - End_date = dateRangeDto.End_date, + End_date = dateRangeDto.End_date }; - this.Database.Dates_ranges.Create(dateRange); - this.Database.Save(); + Database.Dates_ranges.Create(dateRange); + Database.Save(); } - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } + //public int Authenticate(string username, string password) + //{ + // if (string.IsNullOrEmpty(username)) + // { + // throw new Exception("Username is empty."); + // } + // else if (string.IsNullOrEmpty(password)) + // { + // throw new Exception("Password is empty."); + // } - //// return user.Id; - ////} + // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); + // if (user == null) + // { + // throw new Exception("User with current name does not exist."); + // } + // else if (!VerifyHash(password, user.Hash)) + // { + // throw new Exception("Invalid password."); + // } + + // return user.Id; + //} DatesRangeDTO IDateRangeService.GetById(int? id) { if (id == null) - { - throw new ValidationException("ID not set.", string.Empty); - } - - var dateRange = this.Database.Dates_ranges.Get(id.Value); + throw new ValidationException("ID not set.", ""); + var dateRange = Database.Dates_ranges.Get(id.Value); if (dateRange == null) - { - throw new ValidationException("dateRange with this ID was not found", string.Empty); - } + throw new ValidationException("dateRange with this ID was not found", ""); return new DatesRangeDTO { Date_ID = dateRange.Date_ID, Start_date = dateRange.Start_date, - End_date = dateRange.End_date, + End_date = dateRange.End_date }; } - + public IEnumerable GetAll() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Dates_ranges.GetAll()); + return mapper.Map, List>(Database.Dates_ranges.GetAll()); } - public void Dispose(int id) { - var dateRange = this.Database.Dates_ranges.Get(id); + var dateRange = Database.Dates_ranges.Get(id); if (dateRange != null) { - this.Database.Dates_ranges.Delete(id); - this.Database.Save(); + Database.Dates_ranges.Delete(id); + Database.Save(); } } } -} \ No newline at end of file +} + diff --git a/uthTrip.BLL/Services/DestinationService.cs b/uthTrip.BLL/Services/DestinationService.cs index 412a563..85e6225 100644 --- a/uthTrip.BLL/Services/DestinationService.cs +++ b/uthTrip.BLL/Services/DestinationService.cs @@ -1,105 +1,97 @@ -namespace UthTrip.BLL.Services -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.Entities; - ////using UthTrip.BLL.BusinessModels; - using UthTrip.DAL.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.DTO; +using uthTrip.DAL.Entities; +//using uthTrip.BLL.BusinessModels; +using uthTrip.DAL.Interfaces; +using uthTrip.BLL.Infrastructure; +using uthTrip.BLL.Interfaces; +using AutoMapper; - public class DestinationService : IDestinationService +namespace uthTrip.BLL.Services +{ + public class DestinationService:IDestinationService { - public DestinationService(IUnitOfWork uow) - { - this.Database = uow; - } - - private IUnitOfWork Database { get; set; } - + IUnitOfWork Database { get; set; } public int FindMaxId() { - int max = this.Database.Destinations.MaxId(); + int max = Database.Destinations.MaxId(); return max; } - + public DestinationService(IUnitOfWork uow) + { + Database = uow; + } public void CreateDestination(DestinationDTO destinationDto) { Destination destination = new Destination { - Destination_ID = destinationDto.Destination_ID, - Is_Abroad = destinationDto.Is_Abroad, - Country = destinationDto.Country, - City = destinationDto.City, + Destination_ID= destinationDto.Destination_ID, + Is_Abroad=destinationDto.Is_Abroad, + Country=destinationDto.Country, + City=destinationDto.City }; - this.Database.Destinations.Create(destination); - this.Database.Save(); + Database.Destinations.Create(destination); + Database.Save(); } - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } + //public int Authenticate(string username, string password) + //{ + // if (string.IsNullOrEmpty(username)) + // { + // throw new Exception("Username is empty."); + // } + // else if (string.IsNullOrEmpty(password)) + // { + // throw new Exception("Password is empty."); + // } + + // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); + // if (user == null) + // { + // throw new Exception("User with current name does not exist."); + // } + // else if (!VerifyHash(password, user.Hash)) + // { + // throw new Exception("Invalid password."); + // } - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } + // return user.Id; + //} - //// return user.Id; - ////} public DestinationDTO GetById(int? id) { if (id == null) - { - throw new ValidationException("ID not set.", string.Empty); - } - - var destination = this.Database.Destinations.Get(id.Value); + throw new ValidationException("ID not set.", ""); + var destination = Database.Destinations.Get(id.Value); if (destination == null) - { - throw new ValidationException("Destination with this ID was not found", string.Empty); - } + throw new ValidationException("Destination with this ID was not found", ""); return new DestinationDTO { Destination_ID = destination.Destination_ID, Is_Abroad = destination.Is_Abroad, Country = destination.Country, - City = destination.City, + City = destination.City }; } - public IEnumerable GetAll() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Destinations.GetAll()); + return mapper.Map, List>(Database.Destinations.GetAll()); } - public void Dispose(int id) { - var trip = this.Database.Destinations.Get(id); + var trip = Database.Destinations.Get(id); if (trip != null) { - this.Database.Destinations.Delete(id); - this.Database.Save(); + Database.Destinations.Delete(id); + Database.Save(); } } + } } diff --git a/uthTrip.BLL/Services/ReviewService.cs b/uthTrip.BLL/Services/ReviewService.cs deleted file mode 100644 index 01b7012..0000000 --- a/uthTrip.BLL/Services/ReviewService.cs +++ /dev/null @@ -1,64 +0,0 @@ -////using Microsoft.EntityFrameworkCore; -namespace UthTrip.BLL.Services -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Security.Cryptography; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.EF; - using UthTrip.DAL.Entities; - ////using UthTrip.BLL.BusinessModels; - using UthTrip.DAL.Interfaces; - - public class ReviewService : IReviewService - { - public ReviewService(IUnitOfWork uow) - { - this.Database = uow; - } - - public IUnitOfWork Database { get; set; } - - public int FindMaxId() - { - int max = this.Database.Reviews.MaxId(); - return max; - } - - public void CreateReview(ReviewDTO reviewDTO) - { - Review review = new Review - { - Review_ID = reviewDTO.Review_ID, - Writer_ID = reviewDTO.Writer_ID, - Trip_ID = reviewDTO.Trip_ID, - Review1 = reviewDTO.Review1, - Mark = reviewDTO.Mark, - - }; - - this.Database.Reviews.Create(review); - this.Database.Save(); - } - - public IEnumerable GetAll() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Reviews.GetAll()); - } - - public IEnumerable GetAllTrips() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Trips.GetAll()); - } - - } -} \ No newline at end of file diff --git a/uthTrip.BLL/Services/RightsService.cs b/uthTrip.BLL/Services/RightsService.cs deleted file mode 100644 index d089518..0000000 --- a/uthTrip.BLL/Services/RightsService.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace UthTrip.BLL.Services -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.Entities; - ////using UthTrip.BLL.BusinessModels; - using UthTrip.DAL.Interfaces; - - public class RightsService : IRightsService - { - public RightsService(IUnitOfWork uow) - { - this.Database = uow; - } - - private IUnitOfWork Database { get; set; } - - public int FindMaxId() - { - int max = this.Database.Rights.MaxId(); - return max; - } - - public void CreateRights(RightDTO rightsDto) - { - Right rights = new Right - { - Rights_ID = rightsDto.Rights_ID, - Role_ID = rightsDto.Role_ID, - Trip_ID = rightsDto.Trip_ID, - User_ID = rightsDto.User_ID, - - }; - try - { - this.Database.Rights.GetAll().Where(e => e.Role_ID == rights.Role_ID && e.Trip_ID == rights.Trip_ID && e.User_ID == rights.User_ID).First(); - throw new ArgumentNullException(); - } - catch (System.InvalidOperationException) - { - this.Database.Rights.Create(rights); - this.Database.Save(); - } - } - - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } - - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } - - //// return user.Id; - ////} - - RightDTO IRightsService.GetById(int? id) - { - if (id == null) - { - throw new ValidationException("ID not set.", string.Empty); - } - - var rights = this.Database.Rights.Get(id.Value); - if (rights == null) - { - throw new ValidationException("rights with this ID was not found", string.Empty); - } - - return new RightDTO - { - Rights_ID = rights.Rights_ID, - Role_ID = rights.Role_ID, - User_ID = rights.User_ID, - Trip_ID = rights.Trip_ID, - }; - } - - public IEnumerable GetAll() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Rights.GetAll()); - } - - public void Dispose(int id) - { - var rights = this.Database.Rights.Get(id); - if (rights != null) - { - this.Database.Rights.Delete(id); - this.Database.Save(); - } - } - - public IEnumerable GetAllRoles() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Roles.GetAll()); - } - } -} \ No newline at end of file diff --git a/uthTrip.BLL/Services/TripService.cs b/uthTrip.BLL/Services/TripService.cs index 7dc6e7b..79309c4 100644 --- a/uthTrip.BLL/Services/TripService.cs +++ b/uthTrip.BLL/Services/TripService.cs @@ -1,112 +1,100 @@ -namespace UthTrip.BLL.Services +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uthTrip.BLL.DTO; +using uthTrip.DAL.Entities; +//using uthTrip.BLL.BusinessModels; +using uthTrip.DAL.Interfaces; +using uthTrip.BLL.Infrastructure; +using uthTrip.BLL.Interfaces; +using AutoMapper; + +namespace uthTrip.BLL.Services { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - ////using UthTrip.BLL.BusinessModels; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.Entities; - using UthTrip.DAL.Interfaces; - public class TripService : ITripService { - public TripService() + IUnitOfWork Database { get; set; } + public int FindMaxId() { + int max = Database.Trips.MaxId(); + return max; } - - public TripService(IUnitOfWork uow) + public TripService() { - this.Database = uow; - } - private IUnitOfWork Database { get; set; } - - public int FindMaxId() + } + public TripService(IUnitOfWork uow) { - int max = this.Database.Trips.MaxId(); - return max; + Database = uow; } - public void CreateTrip(TripDTO tripDto, DestinationDTO destinationDTO, DatesRangeDTO datesRangeDTO) { Trip trip = new Trip { Trip_ID = tripDto.Trip_ID, - Trip_Title = tripDto.Trip_Title, - Description = tripDto.Description, - Price = tripDto.Price, - Date_ID = tripDto.Date_ID, - Number_Of_People = tripDto.Number_Of_People, - Destination_ID = tripDto.Destination_ID, - Creator_ID = tripDto.Creator_ID, + Trip_Title=tripDto.Trip_Title, + Description=tripDto.Description, + Price=tripDto.Price, + Date_ID=tripDto.Date_ID, + Number_Of_People=tripDto.Number_Of_People, + Destination_ID=tripDto.Destination_ID, + Creator_ID =tripDto.Creator_ID }; Destination destination = new Destination { Destination_ID = destinationDTO.Destination_ID, Is_Abroad = destinationDTO.Is_Abroad, Country = destinationDTO.Country, - City = destinationDTO.City, + City = destinationDTO.City }; Dates_ranges dates_Ranges = new Dates_ranges { Date_ID = datesRangeDTO.Date_ID, Start_date = datesRangeDTO.Start_date, - End_date = datesRangeDTO.End_date, + End_date = datesRangeDTO.End_date }; - try - { - this.Database.Trips.GetAll().Where(e => e.Trip_Title == trip.Trip_Title).First(); - throw new ArgumentNullException(); - } - catch (System.InvalidOperationException) - { - this.Database.Destinations.Create(destination); - this.Database.Dates_ranges.Create(dates_Ranges); - this.Database.Trips.Create(trip); - this.Database.Save(); - } + Database.Destinations.Create(destination); + Database.Save(); + Database.Dates_ranges.Create(dates_Ranges); + Database.Save(); + Database.Trips.Create(trip); + Database.Save(); + } - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } + //public int Authenticate(string username, string password) + //{ + // if (string.IsNullOrEmpty(username)) + // { + // throw new Exception("Username is empty."); + // } + // else if (string.IsNullOrEmpty(password)) + // { + // throw new Exception("Password is empty."); + // } + + // var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); + // if (user == null) + // { + // throw new Exception("User with current name does not exist."); + // } + // else if (!VerifyHash(password, user.Hash)) + // { + // throw new Exception("Invalid password."); + // } + + // return user.Id; + //} - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } - - //// return user.Id; - ////} public TripDTO GetById(int? id) { if (id == null) - { - throw new ValidationException("ID not set.", string.Empty); - } - - var trip = this.Database.Trips.Get(id.Value); + throw new ValidationException("ID not set.", ""); + var trip = Database.Trips.Get(id.Value); if (trip == null) - { - throw new ValidationException("Trip with this ID was not found", string.Empty); - } + throw new ValidationException("Trip with this ID was not found", ""); return new TripDTO { @@ -117,59 +105,46 @@ public TripDTO GetById(int? id) Date_ID = trip.Date_ID, Number_Of_People = trip.Number_Of_People, Destination_ID = trip.Destination_ID, - Creator_ID = trip.Creator_ID, + Creator_ID = trip.Creator_ID }; } - public IEnumerable GetAll() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Trips.GetAll()); + return mapper.Map, List>(Database.Trips.GetAll()); } - public void Dispose(int id) { - var trip = this.Database.Trips.Get(id); + var trip = Database.Trips.Get(id); if (trip != null) { - this.Database.Trips.Delete(id); - this.Database.Save(); + Database.Trips.Delete(id); + Database.Save(); } } public int FindMaxIdDestination() { - int max = this.Database.Destinations.MaxId(); + int max = Database.Destinations.MaxId(); return max; } public int FindMaxIdDateRange() { - int max = this.Database.Dates_ranges.MaxId(); + int max = Database.Dates_ranges.MaxId(); return max; } public IEnumerable GetAllDist() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Destinations.GetAll()); + return mapper.Map, List>(Database.Destinations.GetAll()); } public IEnumerable GetAllDateRanges() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Dates_ranges.GetAll()); - } - public IEnumerable GetAllRights() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Rights.GetAll()); - } - - public IEnumerable GetAllUsers() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Users.GetAll()); + return mapper.Map, List>(Database.Dates_ranges.GetAll()); } } } diff --git a/uthTrip.BLL/Services/UserService.cs b/uthTrip.BLL/Services/UserService.cs index aee15bf..f3ce47e 100644 --- a/uthTrip.BLL/Services/UserService.cs +++ b/uthTrip.BLL/Services/UserService.cs @@ -1,72 +1,55 @@ using System; using uthTrip.BLL.DTO; using uthTrip.DAL.Entities; +//using uthTrip.BLL.BusinessModels; using uthTrip.DAL.Interfaces; using uthTrip.BLL.Infrastructure; using uthTrip.BLL.Interfaces; using System.Collections.Generic; +<<<<<<< HEAD using System.Linq; +<<<<<<< HEAD using uthTrip.DAL.EF; +======= +>>>>>>> parent of 3e60396... added unit tests to userservice +======= +>>>>>>> parent of aa645ae... added unit tests for userservice using AutoMapper; - -namespace UthTrip.BLL.Services +namespace uthTrip.BLL.Services { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Security.Cryptography; - using System.Text; - using System.Threading.Tasks; - using AutoMapper; - using UthTrip.BLL.DTO; - using UthTrip.BLL.Infrastructure; - using UthTrip.BLL.Interfaces; - using UthTrip.DAL.EF; - using UthTrip.DAL.Entities; - using UthTrip.DAL.Interfaces; - public class UserService : IUserService { - public UserService(IUnitOfWork uow) - { - this.Database = uow; - } - public IUnitOfWork Database { get; set; } - public int FindMaxId() { - int max = this.Database.Users.MaxId(); + int max = Database.Users.MaxId(); return max; } - - public int FindMaxIdBl() + public UserService(IUnitOfWork uow) { - int max = this.Database.Blocked_Users.MaxId(); - return max; + Database = uow; } - public void CreateUser(UserDTO userDto) { User user = new User { - User_ID = userDto.User_ID, + User_ID=userDto.User_ID, First_Name = userDto.First_Name, - Last_Name = userDto.Last_Name, - Email = userDto.Email, - Username = userDto.Username, - Password = userDto.Password, - Birthday = userDto.Birthday, - Photo_Url = userDto.Photo_Url, - Info = userDto.Info, + Last_Name=userDto.Last_Name, + Email=userDto.Email, + Username=userDto.Username, + Password=userDto.Password, + Birthday=userDto.Birthday, + Photo_Url=userDto.Photo_Url, + Info=userDto.Info }; Database.Users.Create(user); Database.Save(); } - +<<<<<<< HEAD +======= //public int Authenticate(string username, string password) //{ // if (string.IsNullOrEmpty(username)) @@ -90,60 +73,11 @@ public void CreateUser(UserDTO userDto) // return user.Id; //} +>>>>>>> parent of 3e60396... added unit tests to userservice public string GetFirstName(int userAccountId) { var result = GetAllUsers() - - try - { - this.Database.Users.GetAll().Where(e => e.Username == user.Username).First(); - throw new ArgumentNullException(); - } - catch (System.InvalidOperationException) - { - this.Database.Users.Create(user); - this.Database.Save(); - } - } - public void CreateBlocked(BlockedUsersDTO userDto) - { - Blocked_Users user = new Blocked_Users - { - User_ID = userDto.User_ID, - Blocked_ID = userDto.Blocked_ID, - }; - this.Database.Blocked_Users.Create(user); - this.Database.Save(); - } - - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } - - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } - - //// return user.Id; - ////} - - public string GetFirstName(int userAccountId) - { - var result = this.GetAllUsers() .Where(x => x.User_ID == userAccountId) .Select(x => x.First_Name) .FirstOrDefault(); @@ -153,11 +87,6 @@ public string GetFirstName(int userAccountId) public UserDTO Get(int userAccountId) { var userAccount = GetAllUsers() - - - public UserDTO Get(int userAccountId) - { - var userAccount = this.GetAllUsers() .FirstOrDefault(x => x.User_ID == userAccountId); return userAccount; @@ -187,151 +116,37 @@ public UserDTO Get(int userAccountId) //} - ////public int Authenticate(string username, string password) - ////{ - //// if (string.IsNullOrEmpty(username)) - //// { - //// throw new Exception("Username is empty."); - //// } - //// else if (string.IsNullOrEmpty(password)) - //// { - //// throw new Exception("Password is empty."); - //// } - - //// var user = Database.Users.Find(u => u.Username == username).SingleOrDefault(); - //// if (user == null) - //// { - //// throw new Exception("User with current name does not exist."); - //// } - //// else if (!VerifyHash(password, user.Hash)) - //// { - //// throw new Exception("Invalid password."); - //// } - - //// return user.Id; - ////} - public UserDTO GetById(int? id) { if (id == null) - { - throw new ValidationException("ID not set.", string.Empty); - } - - var user = this.Database.Users.Get(id.Value); + throw new ValidationException("ID not set.", ""); + var user = Database.Users.Get(id.Value); if (user == null) - { - throw new ValidationException("User with this ID was not found", string.Empty); - } + throw new ValidationException("User with this ID was not found", ""); - return new UserDTO - { - User_ID = user.User_ID, - First_Name = user.First_Name, - Last_Name = user.Last_Name, - Email = user.Email, - Username = user.Username, - Password = user.Password, - Info = user.Info, - Birthday = user.Birthday, - Photo_Url = user.Photo_Url, - }; + return new UserDTO { User_ID=user.User_ID, First_Name = user.First_Name,Last_Name=user.Last_Name, + Email=user.Email, Username=user.Username, Password=user.Password,Info=user.Info, Birthday=user.Birthday, Photo_Url=user.Photo_Url}; } - public IEnumerable GetAll() { var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Users.GetAll()); - } - - public IEnumerable GetAllReviews() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Reviews.GetAll()); - } - - public IEnumerable GetAllTrips() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Trips.GetAll()); + return mapper.Map, List>(Database.Users.GetAll()); } - - public IEnumerable GetAllBlocked() - { - var mapper = new MapperConfiguration(cfg => cfg.CreateMap()).CreateMapper(); - return mapper.Map, List>(this.Database.Blocked_Users.GetAll()); - } - public void Dispose(int id) { - var user = this.Database.Users.Get(id); + var user = Database.Users.Get(id); if (user != null) { - this.Database.Users.Delete(id); - this.Database.Save(); + Database.Users.Delete(id); + Database.Save(); } } - public void DisposeBlocked(int id) - { - var user = this.Database.Blocked_Users.Get(id); - if (user != null) - { - this.Database.Blocked_Users.Delete(id); - this.Database.Save(); - } - } - - public static string strKey = "U2A9/R*41FD412+4-123"; - - public static string Encrypt(string strData) - { - string strValue = " "; - if (!string.IsNullOrEmpty(strKey)) - { - if (strKey.Length < 16) - { - char c = "XXXXXXXXXXXXXXXX"[16]; - strKey = strKey + strKey.Substring(0, 16 - strKey.Length); - } - - if (strKey.Length > 16) - { - strKey = strKey.Substring(0, 16); - } - - // create encryption keys - byte[] byteKey = Encoding.UTF8.GetBytes(strKey.Substring(0, 8)); - byte[] byteVector = Encoding.UTF8.GetBytes(strKey.Substring(strKey.Length - 8, 8)); - - // convert data to byte array - byte[] byteData = Encoding.UTF8.GetBytes(strData); - - // encrypt - DESCryptoServiceProvider objDES = new DESCryptoServiceProvider(); - MemoryStream objMemoryStream = new MemoryStream(); - CryptoStream objCryptoStream = new CryptoStream(objMemoryStream, objDES.CreateEncryptor(byteKey, byteVector), CryptoStreamMode.Write); - objCryptoStream.Write(byteData, 0, byteData.Length); - objCryptoStream.FlushFinalBlock(); - - // convert to string and Base64 encode - strValue = Convert.ToBase64String(objMemoryStream.ToArray()); - } - else - { - strValue = strData; - } - - return strValue; - } - - - public UserDTO GetByUsernamePassword(string username, string password) { try { - var user = this.Database.Users.GetbyPass(username, Encrypt(password)); + var user = Database.Users.GetbyPass(username, password); return new UserDTO { User_ID = user.User_ID, @@ -342,7 +157,7 @@ public UserDTO GetByUsernamePassword(string username, string password) Password = user.Password, Info = user.Info, Birthday = user.Birthday, - Photo_Url = user.Photo_Url, + Photo_Url = user.Photo_Url }; } catch (System.NullReferenceException) @@ -350,8 +165,9 @@ public UserDTO GetByUsernamePassword(string username, string password) return null; } } - - +<<<<<<< HEAD +<<<<<<< HEAD +======= private List GetAllUsers() { DateTime somedate = new DateTime(2000, 07, 21); @@ -359,14 +175,8 @@ private List GetAllUsers() { +>>>>>>> parent of aa645ae... added unit tests for userservice - - - private List GetAllUsers() - { - DateTime somedate = new DateTime(2000, 07, 21); - return new List() - { new UserDTO { User_ID = 123, @@ -381,20 +191,11 @@ private List GetAllUsers() }, new UserDTO - - Email = "simongilbert@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "some boy", - }, - new UserDTO { User_ID = 456, First_Name = "Alexander", Last_Name = "Hill", Username = "alexhill", - Email= "alexhill@com", Password = "1111", Birthday = somedate, @@ -404,14 +205,7 @@ private List GetAllUsers() }; } } - - Email = "alexhill@com", - Password = "1111", - Birthday = somedate, - Photo_Url = "www", - Info = "anpther boy", - }, - }; - } +======= +>>>>>>> parent of 3e60396... added unit tests to userservice } -} \ No newline at end of file +} diff --git a/uthTrip.BLL/packages.config b/uthTrip.BLL/packages.config index be2127f..f2f5f08 100644 --- a/uthTrip.BLL/packages.config +++ b/uthTrip.BLL/packages.config @@ -1,30 +1,5 @@  - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/uthTrip.BLL/stylecop.json b/uthTrip.BLL/stylecop.json deleted file mode 100644 index 42fb1f8..0000000 --- a/uthTrip.BLL/stylecop.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // ACTION REQUIRED: This file was automatically added to your project, but it - // will not take effect until additional steps are taken to enable it. See the - // following page for additional information: - // - // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md - - "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", - "settings": { - "documentationRules": { - "companyName": "PlaceholderCompany" - } - } -} diff --git a/uthTrip.BLL/uthTrip.BLL.csproj b/uthTrip.BLL/uthTrip.BLL.csproj index 8249bad..e704b66 100644 --- a/uthTrip.BLL/uthTrip.BLL.csproj +++ b/uthTrip.BLL/uthTrip.BLL.csproj @@ -34,84 +34,14 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\Microsoft.Bcl.HashCode.1.1.0-preview3.19551.4\lib\net461\Microsoft.Bcl.HashCode.dll - - - ..\packages\Microsoft.EntityFrameworkCore.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.3.1.0-preview3.19554.8\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.0-preview3.19553.2\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.3.1.0-preview3.19553.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.7.0-preview3.19551.4\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.7.0-preview3.19551.4\lib\net461\System.ComponentModel.Annotations.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.7.0-preview3.19551.4\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - @@ -131,17 +61,13 @@ - - - - @@ -156,11 +82,6 @@ - - - - - \ No newline at end of file diff --git a/uthTrip.DAL/App.config b/uthTrip.DAL/App.config index 55d339f..d94ae4e 100644 --- a/uthTrip.DAL/App.config +++ b/uthTrip.DAL/App.config @@ -10,9 +10,10 @@ - + - +<<<<<<< Updated upstream +======= - + @@ -35,254 +45,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -331,7 +93,8 @@ - +<<<<<<< Updated upstream +======= @@ -448,7 +211,7 @@ - +>>>>>>> Stashed changes @@ -463,4 +226,4 @@ - + \ No newline at end of file diff --git a/uthTripProject/packages.config b/uthTripProject/packages.config index 2dc4047..3d8b573 100644 --- a/uthTripProject/packages.config +++ b/uthTripProject/packages.config @@ -3,7 +3,6 @@ - @@ -25,28 +24,17 @@ - - + + - - - - - - - - - - - \ No newline at end of file diff --git a/uthTripProject/uthTripProject.csproj b/uthTripProject/uthTripProject.csproj index 01c8f82..3dd27ed 100644 --- a/uthTripProject/uthTripProject.csproj +++ b/uthTripProject/uthTripProject.csproj @@ -1,7 +1,7 @@  - - + + @@ -51,16 +51,7 @@ ..\packages\AutoMapper.9.0.0\lib\net461\AutoMapper.dll - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\Microsoft.VisualStudio.UnitTesting.11.0.50727.1\lib\net45\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll - - - ..\packages\Moq.4.13.1\lib\net45\Moq.dll - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -73,6 +64,9 @@ ..\packages\Ninject.MVC5.3.3.0\lib\net45\Ninject.Web.Mvc.dll + + ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + ..\packages\PagedList.1.17.0.0\lib\net40\PagedList.dll @@ -83,14 +77,8 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - @@ -150,18 +138,6 @@ True ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - @@ -220,26 +196,18 @@ - - - - - Global.asax - - - @@ -250,15 +218,8 @@ - - - - - - - @@ -278,7 +239,6 @@ - Web.config @@ -313,21 +273,13 @@ - + - - - - - - - - @@ -347,7 +299,6 @@ - @@ -355,18 +306,10 @@ uthTrip.BLL - - - - - 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Models\ReviewViewModel.cs - @@ -396,11 +339,9 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + -