From 5bdb5af3b5da4a3c01b22215548f1f2329c539cb Mon Sep 17 00:00:00 2001 From: SandRock Date: Fri, 10 Mar 2023 10:35:45 +0100 Subject: [PATCH] migrate csproj to sdk version, move files around, migrate code, comment non-migrated code... #20 --- .../TwitterUsernameAttributeTests.cs | 167 -------- .../SrkDateTimeExtensionsTests.cs | 363 ------------------ .../Modules/CrawlerGhostingModule.cs | 35 -- .../NSTD.SrkToolkit.AspNetCore.csproj | 46 +-- ...{SrkToolkit.VS15.sln => SrkToolkit-v2.sln} | 272 ++++++++----- .../ChangeCurrentCulture.cs | 0 .../DecimalModelBinderTests.cs | 31 +- .../IntegerModelBinderTests.cs | 0 .../OpenGraphNameTests.cs | 0 .../OpenGraphNamespaceTests.cs | 0 .../OpenGraphObjectTests.cs | 0 .../OpenGraphTagTests.cs | 0 .../PageInfoTests.cs | 0 .../SrkHtmlExtensionsTests.cs | 0 .../SrkHttpContextExtensionsTests.cs | 184 ++++----- .../SrkMvcCollectionExtensionsTests.cs | 0 .../SrkRequestExtensionsTests.cs | 0 .../SrkToolkit.AspNetCore2.UnitTests.csproj | 39 ++ .../SrkUrlHelperExtensionsTests.cs | 0 .../WebDependenciesTests.cs | 0 .../SrkToolkit.Common.CoreUnitTests.csproj | 99 +++++ .../SrkToolkit.Common.FxUnitTests/App.config | 58 +++ .../AssertTests.cs | 149 ++++--- .../CompositeDisposableTests.cs | 21 +- .../CultureInfoHelperTests.cs | 37 +- .../CultureInfoAttributeTests.cs | 43 +-- .../EmailAddressExAttributeTests.cs | 103 +++-- .../PhoneNumberAttributeTests.cs | 87 +++-- .../DataAnnotations/TimezoneAttributeTests.cs | 33 +- .../TwitterUsernameAttributeTests.cs | 163 ++++++++ .../DateRangeAttributeTests.cs | 139 ++++--- .../DictionaryWrapperTests.cs | 58 +-- .../DisaposableOnceTests.cs | 20 +- .../EmailAddressAttributeTests.cs | 82 ++-- .../EmailAddressTests.cs | 233 +++++------ .../EnumStrings.Designer.cs | 3 +- .../EnumStrings.fr.resx | 0 .../EnumStrings.resx | 0 .../EnumToolsTests.cs | 44 +-- .../ObservableCollectionExtensionsTests.cs | 54 +-- .../Properties/AssemblyInfo.cs | 35 ++ .../RetryLogicTests.NET4.cs | 11 +- .../SrkArrayExtensionsTests.cs | 118 +++--- .../SrkDateTimeExtensionsTests.cs | 356 +++++++++++++++++ .../SrkIDictionaryExtensionsTests.cs | 137 ++++--- .../SrkIListExtensionsTests.cs | 142 +++---- .../SrkNameValueCollectionExtensions.cs | 26 +- .../SrkStringExtensionsTests.cs | 124 +++--- .../SrkStringTransformer.cs | 348 ++++++++--------- .../SrkTimeZoneInfoExtensionsTests.cs | 168 ++++---- .../SrkToolkit.Common.FxUnitTests.csproj | 99 +++++ .../StringReplacerTests.cs | 59 ++- .../ValidateTEsts.cs | 83 ++-- .../Collections/DictionaryWrapper.cs | 0 .../CompositeDisposable.cs | 0 .../DataAnnotations/CultureInfoAttribute.cs | 3 + .../DataAnnotations/DateRangeAttribute.cs | 3 + .../DataAnnotations/Dummy.cs | 12 + .../DataAnnotations/EmailAddressAttribute.cs | 32 +- .../DataAnnotations/PhoneNumberAttribute.cs | 3 + .../DataAnnotations/TimezoneAttribute.cs | 3 + .../TwitterUsernameAttribute.cs | 3 + .../DisposableOnce.cs | 0 .../EnumTools.cs | 0 .../Globalization/CultureInfoHelper.cs | 0 Sources/SrkToolkit.Common/IO/Dummy.cs | 12 + .../IO/RecursiveDelete.cs | 3 + .../Internals/Nothing.cs | 0 .../Internals/RetryLogicState.cs | 0 .../Resources/Strings.Designer.cs | 3 +- .../Resources/Strings.fr.resx | 0 .../Resources/Strings.resx | 0 .../RetryIntervalStrategy.cs | 0 .../RetryLogic.cs | 0 .../SrkToolkit.Common.csproj | 37 ++ .../StringComparerEx.cs | 0 .../StringReplacer.cs | 0 .../SrkIDictionaryExtensions.cs | 0 .../SrkIListExtensions.cs | 0 .../SrkObservableCollectionExtensions.cs | 0 .../SrkNameValueCollectionExtensions.cs | 0 .../SrkIDictionaryExtensions.cs | 0 .../System.Diagnostics/StopwatchExtensions.cs | 0 .../System.Linq/SrkEnumerable.cs | 0 .../System/DateTimePrecision.cs | 0 .../System/SrkArrayExtensions.cs | 0 .../System/SrkDateTimeExtensions.cs | 0 .../System/SrkExceptionExtensions.cs | 0 .../System/SrkStringExtensions.cs | 0 .../System/SrkTimeZoneInfoExtensions.cs | 0 .../System/StringTransformer.Urls.cs | 0 .../System/StringTransformer.cs | 0 .../Testing/Assert.cs | 0 .../Threading.Tasks/TaskEx.cs | 0 .../Validation/EmailAddressUtility.cs | 0 .../Validation/Validate.cs | 0 .../MessageDisplayMode.cs | 0 .../SrkDomainControllerExtensions.cs | 4 +- .../SrkToolkit.Domain.AspNetCore2.csproj | 38 ++ .../BaseRequestTests.cs | 24 +- .../BaseResultTests.cs | 164 ++++---- .../BasicResultTests.cs | 10 +- .../ResultErrorExtensionsTests.cs | 85 ++-- .../ResultErrorTests.cs | 74 ++-- .../SrkToolkit.Domain.CoreUnitTests.csproj | 35 ++ .../Strings.Designer.cs | 3 +- .../Strings.resx | 0 .../BaseRequest.cs | 0 .../BaseResult.cs | 0 .../BasicResult.TResultCode.Payload.cs | 0 .../BasicResult.TResultCode.cs | 0 .../BasicResult.cs | 0 .../BasicResultError.cs | 0 .../BasicResultExtensions.cs | 0 .../IBaseResult.cs | 0 .../IResultError.cs | 0 .../Internals/Names.cs | 0 .../ResultError.cs | 0 .../ResultErrorExtensions.cs | 0 .../SrkToolkit.Domain.csproj | 33 ++ .../NavigationLine.cs | 2 +- .../NavigationLineEntry.cs | 2 +- .../Open/OpenGraphName.cs | 0 .../Open/OpenGraphNamespace.cs | 0 .../Open/OpenGraphObject.cs | 0 .../Open/OpenGraphTag.cs | 0 .../Open/PageInfo.cs | 5 + .../Open/PageInfoItem.cs | 0 .../Open/PageInfoObject.cs | 15 +- .../Open/SrkOpenGraphHtmlExtensions.cs | 8 + .../SrkRequestExtensions.cs | 0 .../SrkToolkit.Web.AspMvc5.csproj | 26 ++ .../Fakes/BasicHttpContext.cs | 0 .../Fakes/BasicHttpRequest.cs | 0 .../Fakes/BasicHttpSessionState.cs | 0 .../Filters/AuthorizeAttribute.cs | 0 .../HttpErrors/BaseErrorController.cs | 0 .../HttpErrors/BasicHttpErrorResponse.cs | 0 .../HttpErrors/ErrorControllerHandler.cs | 0 .../HttpErrors/IErrorController.cs | 0 .../SrkToolkit.Web.AspNetCore2/Internals.cs | 9 + .../JsonNetResult.cs | 3 +- .../Models/HttpErrorModel.cs | 0 .../Models/TempMessage.cs | 0 .../Mvc/DecimalModelBinder.cs | 2 + .../SrkToolkit.Web.AspNetCore2/Mvc/Dummy.cs | 12 + .../Mvc/IntegerModelBinder.cs | 0 .../Services/BaseSessionService.cs | 1 - .../DictionarySessionServiceSource.cs | 0 .../Services/HttpBaseSessionServiceSource.cs | 0 .../Services/IResultService.cs | 2 +- .../Services/ISessionServiceSource.cs | 0 .../Services/ResultService.cs | 0 .../Services/ResultServiceBase.cs | 11 +- .../SrkControllerExtensions.cs | 17 +- .../SrkHtmlExtensions.cs | 247 ++++++------ .../SrkHttpApplication.cs | 0 .../SrkHttpApplication.tt | 0 .../SrkHttpApplication.tt.cs | 0 .../SrkHttpContextExtensions.cs | 43 ++- .../SrkHttpRequestExtensions.cs | 48 +++ .../SrkTempDataDictionaryExtensions.cs | 4 +- .../SrkToolkit.Web.AspNetCore2.csproj | 131 +++++++ .../SrkMvcCollectionExtensions.cs | 2 +- .../System.Web.Mvc/SrkTagBuilderExtensions.cs | 7 +- .../System.Web.Mvc/SrkUrlHelperExtensions.cs | 1 + .../System.Web.Mvc/SrkViewExtensions.cs | 2 +- .../WebDependencies.cs | 15 +- .../WebDependenciesExtensions.cs | 1 - .../WebDependency.cs | 0 .../WebDependencyFile.cs | 0 171 files changed, 3164 insertions(+), 2305 deletions(-) delete mode 100644 Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TwitterUsernameAttributeTests.cs delete mode 100644 Sources/NET4.SrkToolkit.Common.Tests/SrkDateTimeExtensionsTests.cs delete mode 100644 Sources/NET4.SrkToolkit.Web/Modules/CrawlerGhostingModule.cs rename Sources/{SrkToolkit.VS15.sln => SrkToolkit-v2.sln} (65%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/ChangeCurrentCulture.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/DecimalModelBinderTests.cs (94%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/IntegerModelBinderTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/OpenGraphNameTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/OpenGraphNamespaceTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/OpenGraphObjectTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/OpenGraphTagTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/PageInfoTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/SrkHtmlExtensionsTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/SrkHttpContextExtensionsTests.cs (97%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/SrkMvcCollectionExtensionsTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/SrkRequestExtensionsTests.cs (100%) create mode 100644 Sources/SrkToolkit.AspNetCore2.UnitTests/SrkToolkit.AspNetCore2.UnitTests.csproj rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/SrkUrlHelperExtensionsTests.cs (100%) rename Sources/{NET4.SrkToolkit.Web.Tests => SrkToolkit.AspNetCore2.UnitTests}/WebDependenciesTests.cs (100%) create mode 100644 Sources/SrkToolkit.Common.CoreUnitTests/SrkToolkit.Common.CoreUnitTests.csproj create mode 100644 Sources/SrkToolkit.Common.FxUnitTests/App.config rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/AssertTests.cs (69%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/CompositeDisposableTests.cs (86%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/CultureInfoHelperTests.cs (66%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DataAnnotations/CultureInfoAttributeTests.cs (72%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DataAnnotations/EmailAddressExAttributeTests.cs (79%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DataAnnotations/PhoneNumberAttributeTests.cs (64%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DataAnnotations/TimezoneAttributeTests.cs (72%) create mode 100644 Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TwitterUsernameAttributeTests.cs rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DateRangeAttributeTests.cs (77%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DictionaryWrapperTests.cs (64%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/DisaposableOnceTests.cs (74%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EmailAddressAttributeTests.cs (74%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EmailAddressTests.cs (68%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EnumStrings.Designer.cs (95%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EnumStrings.fr.resx (100%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EnumStrings.resx (100%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/EnumToolsTests.cs (78%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/ObservableCollectionExtensionsTests.cs (66%) create mode 100644 Sources/SrkToolkit.Common.FxUnitTests/Properties/AssemblyInfo.cs rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/RetryLogicTests.NET4.cs (96%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkArrayExtensionsTests.cs (51%) create mode 100644 Sources/SrkToolkit.Common.FxUnitTests/SrkDateTimeExtensionsTests.cs rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkIDictionaryExtensionsTests.cs (67%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkIListExtensionsTests.cs (64%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkNameValueCollectionExtensions.cs (64%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkStringExtensionsTests.cs (63%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkStringTransformer.cs (77%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/SrkTimeZoneInfoExtensionsTests.cs (50%) create mode 100644 Sources/SrkToolkit.Common.FxUnitTests/SrkToolkit.Common.FxUnitTests.csproj rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/StringReplacerTests.cs (86%) rename Sources/{NET4.SrkToolkit.Common.Tests => SrkToolkit.Common.FxUnitTests}/ValidateTEsts.cs (72%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Collections/DictionaryWrapper.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/CompositeDisposable.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/CultureInfoAttribute.cs (95%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/DateRangeAttribute.cs (96%) create mode 100644 Sources/SrkToolkit.Common/DataAnnotations/Dummy.cs rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/EmailAddressAttribute.cs (93%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/PhoneNumberAttribute.cs (96%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/TimezoneAttribute.cs (95%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DataAnnotations/TwitterUsernameAttribute.cs (96%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/DisposableOnce.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/EnumTools.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Globalization/CultureInfoHelper.cs (100%) create mode 100644 Sources/SrkToolkit.Common/IO/Dummy.cs rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/IO/RecursiveDelete.cs (96%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Internals/Nothing.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Internals/RetryLogicState.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Resources/Strings.Designer.cs (96%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Resources/Strings.fr.resx (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Resources/Strings.resx (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/RetryIntervalStrategy.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/RetryLogic.cs (100%) create mode 100644 Sources/SrkToolkit.Common/SrkToolkit.Common.csproj rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/StringComparerEx.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/StringReplacer.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Collections.Generic/SrkIDictionaryExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Collections.Generic/SrkIListExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Collections.ObjectModel/SrkObservableCollectionExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Collections.Specialized/SrkNameValueCollectionExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Collections/SrkIDictionaryExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Diagnostics/StopwatchExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System.Linq/SrkEnumerable.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/DateTimePrecision.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/SrkArrayExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/SrkDateTimeExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/SrkExceptionExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/SrkStringExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/SrkTimeZoneInfoExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/StringTransformer.Urls.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/System/StringTransformer.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Testing/Assert.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Threading.Tasks/TaskEx.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Validation/EmailAddressUtility.cs (100%) rename Sources/{NET4.SrkToolkit.Common => SrkToolkit.Common}/Validation/Validate.cs (100%) rename Sources/{NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web => SrkToolkit.Domain.AspNetCore2}/MessageDisplayMode.cs (100%) rename Sources/{NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web => SrkToolkit.Domain.AspNetCore2}/SrkDomainControllerExtensions.cs (96%) create mode 100644 Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/BaseRequestTests.cs (79%) rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/BaseResultTests.cs (75%) rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/BasicResultTests.cs (86%) rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/ResultErrorExtensionsTests.cs (60%) rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/ResultErrorTests.cs (73%) create mode 100644 Sources/SrkToolkit.Domain.CoreUnitTests/SrkToolkit.Domain.CoreUnitTests.csproj rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/Strings.Designer.cs (95%) rename Sources/{NET4.SrkToolkit.Domain.Tests => SrkToolkit.Domain.CoreUnitTests}/Strings.resx (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BaseRequest.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BaseResult.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BasicResult.TResultCode.Payload.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BasicResult.TResultCode.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BasicResult.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BasicResultError.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/BasicResultExtensions.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/IBaseResult.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/IResultError.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/Internals/Names.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/ResultError.cs (100%) rename Sources/{NET4.SrkToolkit.Domain => SrkToolkit.Domain}/ResultErrorExtensions.cs (100%) create mode 100644 Sources/SrkToolkit.Domain/SrkToolkit.Domain.csproj rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/NavigationLine.cs (94%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/NavigationLineEntry.cs (94%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/OpenGraphName.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/OpenGraphNamespace.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/OpenGraphObject.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/OpenGraphTag.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/PageInfo.cs (96%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/PageInfoItem.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/PageInfoObject.cs (93%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/Open/SrkOpenGraphHtmlExtensions.cs (90%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspMvc5}/SrkRequestExtensions.cs (100%) create mode 100644 Sources/SrkToolkit.Web.AspMvc5/SrkToolkit.Web.AspMvc5.csproj rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Fakes/BasicHttpContext.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Fakes/BasicHttpRequest.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Fakes/BasicHttpSessionState.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Filters/AuthorizeAttribute.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/HttpErrors/BaseErrorController.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/HttpErrors/BasicHttpErrorResponse.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/HttpErrors/ErrorControllerHandler.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/HttpErrors/IErrorController.cs (100%) create mode 100644 Sources/SrkToolkit.Web.AspNetCore2/Internals.cs rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/JsonNetResult.cs (94%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Models/HttpErrorModel.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Models/TempMessage.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Mvc/DecimalModelBinder.cs (96%) create mode 100644 Sources/SrkToolkit.Web.AspNetCore2/Mvc/Dummy.cs rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Mvc/IntegerModelBinder.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/BaseSessionService.cs (96%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/DictionarySessionServiceSource.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/HttpBaseSessionServiceSource.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/IResultService.cs (96%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/ISessionServiceSource.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/ResultService.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/Services/ResultServiceBase.cs (94%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkControllerExtensions.cs (95%) rename Sources/{NET4.SrkToolkit.Web/System.Web.Mvc => SrkToolkit.Web.AspNetCore2}/SrkHtmlExtensions.cs (82%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkHttpApplication.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkHttpApplication.tt (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkHttpApplication.tt.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkHttpContextExtensions.cs (96%) create mode 100644 Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/SrkTempDataDictionaryExtensions.cs (96%) create mode 100644 Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/System.Web.Mvc/SrkMvcCollectionExtensions.cs (95%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/System.Web.Mvc/SrkTagBuilderExtensions.cs (79%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/System.Web.Mvc/SrkUrlHelperExtensions.cs (97%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/System.Web.Mvc/SrkViewExtensions.cs (96%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/WebDependencies.cs (93%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/WebDependenciesExtensions.cs (96%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/WebDependency.cs (100%) rename Sources/{NET4.SrkToolkit.Web => SrkToolkit.Web.AspNetCore2}/WebDependencyFile.cs (100%) diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TwitterUsernameAttributeTests.cs b/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TwitterUsernameAttributeTests.cs deleted file mode 100644 index 6fa9391..0000000 --- a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TwitterUsernameAttributeTests.cs +++ /dev/null @@ -1,167 +0,0 @@ - -namespace Sparkle.UnitTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.Linq; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading.Tasks; - - [TestClass] - public class TwitterUsernameAttributeTests - { - [TestClass] - public class RegexTests - { - private Regex TwitterRegex; - - [TestInitialize] - public void Initialize() - { - this.TwitterRegex = new Regex(TwitterUsernameAttribute.TwitterRegex, RegexOptions.Compiled); - } - - [TestMethod] - public void TwitterUsernameNoMatch() - { - Assert.IsFalse(this.TwitterRegex.IsMatch("é'çà&=")); - Assert.IsFalse(this.TwitterRegex.IsMatch("user@name")); - Assert.IsFalse(this.TwitterRegex.IsMatch("usernamereallytoolong")); - } - - [TestMethod] - public void TwitterUsernameMatch() - { - Assert.IsTrue(this.TwitterRegex.IsMatch("username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("user_name")); - Assert.IsTrue(this.TwitterRegex.IsMatch("@username")); - } - - [TestMethod] - public void TwitterWeirdUrlMatch() - { - Assert.IsTrue(this.TwitterRegex.IsMatch("twitter/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("twitter/@username")); - } - - [TestMethod] - public void TwitterUrlWithoutProtocolMatch() - { - Assert.IsTrue(this.TwitterRegex.IsMatch("twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("twitter.com/@username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("www.twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("www.twitter.com/@username")); - } - - [TestMethod] - public void TwitterUrlWithProtocolMatch() - { - Assert.IsTrue(this.TwitterRegex.IsMatch("http://twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("https://twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("http://twitter.com/@username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("https://twitter.com/@username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("http://www.twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("https://www.twitter.com/username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("http://www.twitter.com/@username")); - Assert.IsTrue(this.TwitterRegex.IsMatch("https://www.twitter.com/@username")); - } - } - - [TestClass] - public class GetUsernameMethod - { - [TestMethod] - public void TwitterGetUsernameFail() - { - string username = null; - - Assert.IsFalse(TwitterUsernameAttribute.GetUsername("é'çà&=", out username)); - Assert.IsNull(username); - Assert.IsFalse(TwitterUsernameAttribute.GetUsername("user@name", out username)); - Assert.IsNull(username); - Assert.IsFalse(TwitterUsernameAttribute.GetUsername("usernamereallytoolong", out username)); - Assert.IsNull(username); - } - - [TestMethod] - public void TwitterGetUsernameSuccess() - { - string username = null; - - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("user_name", out username)); - Assert.AreEqual("user_name", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("@username", out username)); - Assert.AreEqual("username", username); - } - - [TestMethod] - public void TwitterGetUsernameFromWeirdUrl() - { - string username = null; - - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("twitter/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("twitter/@username", out username)); - Assert.AreEqual("username", username); - } - - [TestMethod] - public void TwitterGetUsernameFromUrlWithoutProtocol() - { - string username = null; - - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("twitter.com/@username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("www.twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("www.twitter.com/@username", out username)); - Assert.AreEqual("username", username); - } - - [TestMethod] - public void TwitterGetUsernameFromUrlWithProtocol() - { - string username = null; - - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("http://twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("http://twitter.com/@username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("http://www.twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("http://www.twitter.com/@username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("https://twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("https://twitter.com/@username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("https://www.twitter.com/username", out username)); - Assert.AreEqual("username", username); - Assert.IsTrue(TwitterUsernameAttribute.GetUsername("https://www.twitter.com/@username", out username)); - Assert.AreEqual("username", username); - } - } - - [TestMethod] - public void ObviousInvalid() - { - var attr = new TwitterUsernameAttribute(); - string value = "foo bar", name = "Twitter"; - var context = new ValidationContext(new object(), null, null); - context.MemberName = name; - var result = attr.GetValidationResult(value, context); - Assert.IsNotNull(result); - Assert.AreEqual(@"Invalid Twitter username. You must provide the username or the url to your account.", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); - } - } -} diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkDateTimeExtensionsTests.cs b/Sources/NET4.SrkToolkit.Common.Tests/SrkDateTimeExtensionsTests.cs deleted file mode 100644 index a38c113..0000000 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkDateTimeExtensionsTests.cs +++ /dev/null @@ -1,363 +0,0 @@ -// ----------------------------------------------------------------------- -// -// TODO: Update copyright text. -// -// ----------------------------------------------------------------------- - -namespace SrkToolkit.Common.Tests -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - public class SrkDateTimeExtensionsTests - { - [TestClass] - public class GetDateMethod - { - [TestMethod] - public void WorksForNow() - { - var date = DateTime.Now; - - var result = date.GetDate(); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void WorksForUtcNow() - { - var date = DateTime.UtcNow; - - var result = date.GetDate(); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void Works1() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 111, DateTimeKind.Unspecified); - - var result = date.GetDate(); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - } - - [TestClass] - public class ToPrecisionMethod - { - [TestMethod] - public void ToMillisecond() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Millisecond); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToSecond() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Second); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToMinute() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Minute); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToHour() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Hour); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToDay() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Day); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToMonth() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Month); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(1, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - - [TestMethod] - public void ToYear() - { - var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date.ToPrecision(DateTimePrecision.Year); - - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(1, result.Month); - Assert.AreEqual(1, result.Day); - Assert.AreEqual(0, result.Hour); - Assert.AreEqual(0, result.Minute); - Assert.AreEqual(0, result.Second); - Assert.AreEqual(0, result.Millisecond); - Assert.AreEqual(date.Kind, result.Kind); - } - } - - [TestClass] - public class IsEqualToMethod - { - [TestMethod] - public void CompareMillisecondDifference() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 2, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Millisecond); - Assert.IsFalse(result); - } - - [TestMethod] - public void CompareMillisecondEquality() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Millisecond); - Assert.IsTrue(result); - } - - [TestMethod] - public void CompareSecondDifference() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Second); - Assert.IsFalse(result); - } - - [TestMethod] - public void CompareSecondDifference_MsDifferent() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 2, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Second); - Assert.IsFalse(result); - } - - [TestMethod] - public void CompareSecondEquality() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Second); - Assert.IsTrue(result); - } - - [TestMethod] - public void CompareSecondEquality_MsDifferent() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 2, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Second); - Assert.IsTrue(result); - } - - [TestMethod] - public void CompareMinuteDifference() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 4, 2, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); - Assert.IsFalse(result); - } - - [TestMethod] - public void CompareMinuteDifference_SecondDifferent() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 4, 3, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); - Assert.IsFalse(result); - } - - [TestMethod] - public void CompareMinuteEquality() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); - Assert.IsTrue(result); - } - - [TestMethod] - public void CompareMinuteEquality_SecondDifferent() - { - var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); - var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 2, DateTimeKind.Utc); - var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); - Assert.IsTrue(result); - } - } - - [TestClass] - public class AsLocalMethod - { - [TestMethod] - public void SameValues() - { - // prepare - var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Unspecified); - var result = SrkDateTimeExtensions.AsLocal(date); - - // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(date.Ticks, result.Ticks); - Assert.AreEqual(DateTimeKind.Local, result.Kind); - } - } - - [TestClass] - public class AsUtcMethod - { - [TestMethod] - public void SameValues() - { - // prepare - var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Unspecified); - var result = SrkDateTimeExtensions.AsUtc(date); - - // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(date.Ticks, result.Ticks); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); - } - } - - [TestClass] - public class AsUnspecifiedMethod - { - [TestMethod] - public void SameValues() - { - // prepare - var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Local); - var result = SrkDateTimeExtensions.AsUnspecified(date); - - // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(date.Ticks, result.Ticks); - Assert.AreEqual(DateTimeKind.Unspecified, result.Kind); - } - } - - [TestClass] - public class ToUnixTimeMethod - { - [TestMethod] - public void UtcTime() - { - DateTime time = new DateTime(2013, 1, 29, 13, 28, 21, 1, DateTimeKind.Utc); - long result = time.ToUnixTime(); - Assert.AreEqual(1359466101, result); - } - } - } -} diff --git a/Sources/NET4.SrkToolkit.Web/Modules/CrawlerGhostingModule.cs b/Sources/NET4.SrkToolkit.Web/Modules/CrawlerGhostingModule.cs deleted file mode 100644 index 2c4df2c..0000000 --- a/Sources/NET4.SrkToolkit.Web/Modules/CrawlerGhostingModule.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright 2014 SandRock -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace SrkToolkit.Web.Modules -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Web; - - public class CrawlerGhostingModule : IHttpModule - { - public void Dispose() - { - } - - public void Init(HttpApplication context) - { - } - } -} diff --git a/Sources/NSTD.SrkToolkit.AspNetCore/NSTD.SrkToolkit.AspNetCore.csproj b/Sources/NSTD.SrkToolkit.AspNetCore/NSTD.SrkToolkit.AspNetCore.csproj index bd3f317..56674fd 100644 --- a/Sources/NSTD.SrkToolkit.AspNetCore/NSTD.SrkToolkit.AspNetCore.csproj +++ b/Sources/NSTD.SrkToolkit.AspNetCore/NSTD.SrkToolkit.AspNetCore.csproj @@ -1,22 +1,24 @@ - - - - netstandard2.0 - 1.2.0-beta1 - true - SrkToolkit - - - SrkToolkit.AspNetCore - - - - - - - - - - - - + + + + netstandard2.0 + 1.2.0-beta1 + true + SrkToolkit + + + SrkToolkit.AspNetCore + + + + + + + + + + + + + + diff --git a/Sources/SrkToolkit.VS15.sln b/Sources/SrkToolkit-v2.sln similarity index 65% rename from Sources/SrkToolkit.VS15.sln rename to Sources/SrkToolkit-v2.sln index b017f7f..5695f3f 100644 --- a/Sources/SrkToolkit.VS15.sln +++ b/Sources/SrkToolkit-v2.sln @@ -20,22 +20,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "30 Domain", "30 Domain", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "40 Common", "40 Common", "{C3406DF1-E92C-4100-BEF9-B49F616E77C5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "50 Web", "50 Web", "{B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF4.SrkToolkit.Mvvm", "WPF4.SrkToolkit.Mvvm\WPF4.SrkToolkit.Mvvm.csproj", "{A842E52E-4001-4BD8-BDCD-C95630D984D4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF4.SrkToolkit.Xaml", "WPF4.SrkToolkit.Xaml\WPF4.SrkToolkit.Xaml.csproj", "{09A84445-2AA3-4D99-89F7-007CA3EF91A3}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "50 AspNet", "50 AspNet", "{B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET4.SrkToolkit.Services", "NET4.SrkToolkit.Services\NET4.SrkToolkit.Services.csproj", "{CFDFCEA2-BAFB-455E-BEF4-40343DE968CF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET4.SrkToolkit.Services.Tests", "NET4.SrkToolkit.Services.Tests\NET4.SrkToolkit.Services.Tests.csproj", "{7E6D5FC5-4ED0-433C-A92C-D4A0C0146CCB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET4.SrkToolkit.Mvvm.Tests", "NET4.SrkToolkit.Mvvm.Tests\NET4.SrkToolkit.Mvvm.Tests.csproj", "{9C42B357-7E5D-4192-850D-190EAEC0416A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF45.SrkToolkit.Xaml", "WPF45.SrkToolkit.Xaml\WPF45.SrkToolkit.Xaml.csproj", "{A6D741FB-B974-491A-A2CE-DE7F491FD66D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF45.SrkToolkit.Mvvm", "WPF45.SrkToolkit.Mvvm\WPF45.SrkToolkit.Mvvm.csproj", "{175B67BE-9042-45EE-A8DF-D96FE8B75561}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET4.SrkToolkit.Domain", "NET4.SrkToolkit.Domain\NET4.SrkToolkit.Domain.csproj", "{893A7FD4-62E6-4F7A-8FF9-EA502ADA88FA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET4.SrkToolkit.Common", "NET4.SrkToolkit.Common\NET4.SrkToolkit.Common.csproj", "{19495A45-67A8-460D-806C-CF158B96BBE9}" @@ -62,18 +52,34 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET45.SrkToolkit.Domain.Asp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET45.SrkToolkit.Common.Tests", "NET45.SrkToolkit.Common.Tests\NET45.SrkToolkit.Common.Tests.csproj", "{50AF7833-C345-4F6C-9FB1-36EB176D68E1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWP461.SrkToolkit.Mvvm", "UWP461.SrkToolkit.Mvvm\UWP461.SrkToolkit.Mvvm.csproj", "{1B365EA8-743C-4105-B86D-FF412DAD0DAF}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSTD.SrkToolkit.Common", "NSTD.SrkToolkit.Common\NSTD.SrkToolkit.Common.csproj", "{868FFFF9-365D-4F74-881D-68577D8D2BB0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSTD.SrkToolkit.Web", "NSTD.SrkToolkit.Web\NSTD.SrkToolkit.Web.csproj", "{D490BE59-2AC5-4816-AF5F-1BF89F46D680}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSTD.SrkToolkit.AspNetCore", "NSTD.SrkToolkit.AspNetCore\NSTD.SrkToolkit.AspNetCore.csproj", "{8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NET45.SrkToolkit.Web.Tests", "NET4.SrkToolkit.Web.Tests\NET45.SrkToolkit.Web.Tests.csproj", "{80B716DA-2C58-4F77-8AC4-2F0180D44A39}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSTD.SrkToolkit.Domain", "NSTD.SrkToolkit.Domain\NSTD.SrkToolkit.Domain.csproj", "{ED951C8A-9CD9-40B8-989F-E231A38EAF90}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Web.AspNetCore2", "SrkToolkit.Web.AspNetCore2\SrkToolkit.Web.AspNetCore2.csproj", "{38BDABA1-D402-45B7-ADEC-E36DC7D2E327}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.AspNetCore2.UnitTests", "SrkToolkit.AspNetCore2.UnitTests\SrkToolkit.AspNetCore2.UnitTests.csproj", "{6697A04B-FCE0-479B-A11D-CACEAC2C56FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Web.AspMvc5", "SrkToolkit.Web.AspMvc5\SrkToolkit.Web.AspMvc5.csproj", "{1C28C6A0-23B2-43ED-B62C-C586F2976473}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Common", "SrkToolkit.Common\SrkToolkit.Common.csproj", "{9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Common.FxUnitTests", "SrkToolkit.Common.FxUnitTests\SrkToolkit.Common.FxUnitTests.csproj", "{00457CE3-FE08-4AF2-972E-4C2EDD36F38D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Common.CoreUnitTests", "SrkToolkit.Common.CoreUnitTests\SrkToolkit.Common.CoreUnitTests.csproj", "{6616E666-2C77-401A-B131-6FC8E9146B23}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Domain", "SrkToolkit.Domain\SrkToolkit.Domain.csproj", "{411A61F7-37B3-493F-9C70-4DCF569311B8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Domain.CoreUnitTests", "SrkToolkit.Domain.CoreUnitTests\SrkToolkit.Domain.CoreUnitTests.csproj", "{25B95F36-5B87-4ACD-86EC-015F32D8EAF3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "51 AspNetCore", "51 AspNetCore", "{6CE6544E-C1DC-4EA2-BDEB-97C7E71A5C35}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrkToolkit.Domain.AspNetCore2", "SrkToolkit.Domain.AspNetCore2\SrkToolkit.Domain.AspNetCore2.csproj", "{C1D52195-641B-4DC8-A0F9-364715A3B34A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,26 +92,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Debug|ARM.ActiveCfg = Debug|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Debug|x64.ActiveCfg = Debug|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Debug|x86.ActiveCfg = Debug|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Release|Any CPU.Build.0 = Release|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Release|ARM.ActiveCfg = Release|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Release|x64.ActiveCfg = Release|Any CPU - {A842E52E-4001-4BD8-BDCD-C95630D984D4}.Release|x86.ActiveCfg = Release|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Debug|ARM.ActiveCfg = Debug|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Debug|x64.ActiveCfg = Debug|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Debug|x86.ActiveCfg = Debug|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Release|Any CPU.Build.0 = Release|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Release|ARM.ActiveCfg = Release|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Release|x64.ActiveCfg = Release|Any CPU - {09A84445-2AA3-4D99-89F7-007CA3EF91A3}.Release|x86.ActiveCfg = Release|Any CPU {CFDFCEA2-BAFB-455E-BEF4-40343DE968CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFDFCEA2-BAFB-455E-BEF4-40343DE968CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {CFDFCEA2-BAFB-455E-BEF4-40343DE968CF}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -126,36 +112,6 @@ Global {7E6D5FC5-4ED0-433C-A92C-D4A0C0146CCB}.Release|ARM.ActiveCfg = Release|Any CPU {7E6D5FC5-4ED0-433C-A92C-D4A0C0146CCB}.Release|x64.ActiveCfg = Release|Any CPU {7E6D5FC5-4ED0-433C-A92C-D4A0C0146CCB}.Release|x86.ActiveCfg = Release|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Debug|ARM.ActiveCfg = Debug|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Debug|x64.ActiveCfg = Debug|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Debug|x86.ActiveCfg = Debug|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Release|Any CPU.Build.0 = Release|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Release|ARM.ActiveCfg = Release|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Release|x64.ActiveCfg = Release|Any CPU - {9C42B357-7E5D-4192-850D-190EAEC0416A}.Release|x86.ActiveCfg = Release|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Debug|ARM.ActiveCfg = Debug|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Debug|x64.ActiveCfg = Debug|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Debug|x86.ActiveCfg = Debug|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Release|Any CPU.Build.0 = Release|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Release|ARM.ActiveCfg = Release|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Release|x64.ActiveCfg = Release|Any CPU - {A6D741FB-B974-491A-A2CE-DE7F491FD66D}.Release|x86.ActiveCfg = Release|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Debug|Any CPU.Build.0 = Debug|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Debug|ARM.ActiveCfg = Debug|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Debug|x64.ActiveCfg = Debug|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Debug|x86.ActiveCfg = Debug|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Release|Any CPU.ActiveCfg = Release|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Release|Any CPU.Build.0 = Release|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Release|ARM.ActiveCfg = Release|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Release|x64.ActiveCfg = Release|Any CPU - {175B67BE-9042-45EE-A8DF-D96FE8B75561}.Release|x86.ActiveCfg = Release|Any CPU {893A7FD4-62E6-4F7A-8FF9-EA502ADA88FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {893A7FD4-62E6-4F7A-8FF9-EA502ADA88FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {893A7FD4-62E6-4F7A-8FF9-EA502ADA88FA}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -286,16 +242,6 @@ Global {50AF7833-C345-4F6C-9FB1-36EB176D68E1}.Release|ARM.ActiveCfg = Release|Any CPU {50AF7833-C345-4F6C-9FB1-36EB176D68E1}.Release|x64.ActiveCfg = Release|Any CPU {50AF7833-C345-4F6C-9FB1-36EB176D68E1}.Release|x86.ActiveCfg = Release|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Debug|ARM.ActiveCfg = Debug|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Debug|x64.ActiveCfg = Debug|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Debug|x86.ActiveCfg = Debug|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Release|Any CPU.Build.0 = Release|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Release|ARM.ActiveCfg = Release|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Release|x64.ActiveCfg = Release|Any CPU - {1B365EA8-743C-4105-B86D-FF412DAD0DAF}.Release|x86.ActiveCfg = Release|Any CPU {868FFFF9-365D-4F74-881D-68577D8D2BB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {868FFFF9-365D-4F74-881D-68577D8D2BB0}.Debug|Any CPU.Build.0 = Debug|Any CPU {868FFFF9-365D-4F74-881D-68577D8D2BB0}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -328,22 +274,6 @@ Global {D490BE59-2AC5-4816-AF5F-1BF89F46D680}.Release|x64.Build.0 = Release|Any CPU {D490BE59-2AC5-4816-AF5F-1BF89F46D680}.Release|x86.ActiveCfg = Release|Any CPU {D490BE59-2AC5-4816-AF5F-1BF89F46D680}.Release|x86.Build.0 = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|ARM.ActiveCfg = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|ARM.Build.0 = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|x64.ActiveCfg = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|x64.Build.0 = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|x86.ActiveCfg = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Debug|x86.Build.0 = Debug|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|Any CPU.Build.0 = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|ARM.ActiveCfg = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|ARM.Build.0 = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|x64.ActiveCfg = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|x64.Build.0 = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|x86.ActiveCfg = Release|Any CPU - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA}.Release|x86.Build.0 = Release|Any CPU {80B716DA-2C58-4F77-8AC4-2F0180D44A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {80B716DA-2C58-4F77-8AC4-2F0180D44A39}.Debug|Any CPU.Build.0 = Debug|Any CPU {80B716DA-2C58-4F77-8AC4-2F0180D44A39}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -376,18 +306,157 @@ Global {ED951C8A-9CD9-40B8-989F-E231A38EAF90}.Release|x64.Build.0 = Release|Any CPU {ED951C8A-9CD9-40B8-989F-E231A38EAF90}.Release|x86.ActiveCfg = Release|Any CPU {ED951C8A-9CD9-40B8-989F-E231A38EAF90}.Release|x86.Build.0 = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|ARM.ActiveCfg = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|ARM.Build.0 = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|x64.ActiveCfg = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|x64.Build.0 = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|x86.ActiveCfg = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Debug|x86.Build.0 = Debug|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|Any CPU.Build.0 = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|ARM.ActiveCfg = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|ARM.Build.0 = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|x64.ActiveCfg = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|x64.Build.0 = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|x86.ActiveCfg = Release|Any CPU + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327}.Release|x86.Build.0 = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|ARM.Build.0 = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|x64.Build.0 = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|x86.ActiveCfg = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Debug|x86.Build.0 = Debug|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|Any CPU.Build.0 = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|ARM.ActiveCfg = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|ARM.Build.0 = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|x64.ActiveCfg = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|x64.Build.0 = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|x86.ActiveCfg = Release|Any CPU + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC}.Release|x86.Build.0 = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|ARM.ActiveCfg = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|ARM.Build.0 = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|x64.ActiveCfg = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|x64.Build.0 = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Debug|x86.Build.0 = Debug|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|Any CPU.Build.0 = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|ARM.ActiveCfg = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|ARM.Build.0 = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|x64.ActiveCfg = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|x64.Build.0 = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|x86.ActiveCfg = Release|Any CPU + {1C28C6A0-23B2-43ED-B62C-C586F2976473}.Release|x86.Build.0 = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|ARM.ActiveCfg = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|ARM.Build.0 = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|x64.ActiveCfg = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|x64.Build.0 = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|x86.ActiveCfg = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Debug|x86.Build.0 = Debug|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|Any CPU.Build.0 = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|ARM.ActiveCfg = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|ARM.Build.0 = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|x64.ActiveCfg = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|x64.Build.0 = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|x86.ActiveCfg = Release|Any CPU + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E}.Release|x86.Build.0 = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|ARM.ActiveCfg = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|ARM.Build.0 = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|x64.ActiveCfg = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|x64.Build.0 = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|x86.ActiveCfg = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Debug|x86.Build.0 = Debug|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|Any CPU.Build.0 = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|ARM.ActiveCfg = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|ARM.Build.0 = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|x64.ActiveCfg = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|x64.Build.0 = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|x86.ActiveCfg = Release|Any CPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D}.Release|x86.Build.0 = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|ARM.Build.0 = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|x64.ActiveCfg = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|x64.Build.0 = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|x86.ActiveCfg = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Debug|x86.Build.0 = Debug|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|Any CPU.Build.0 = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|ARM.ActiveCfg = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|ARM.Build.0 = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|x64.ActiveCfg = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|x64.Build.0 = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|x86.ActiveCfg = Release|Any CPU + {6616E666-2C77-401A-B131-6FC8E9146B23}.Release|x86.Build.0 = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|ARM.ActiveCfg = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|ARM.Build.0 = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|x64.ActiveCfg = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|x64.Build.0 = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|x86.ActiveCfg = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Debug|x86.Build.0 = Debug|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|Any CPU.Build.0 = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|ARM.ActiveCfg = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|ARM.Build.0 = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|x64.ActiveCfg = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|x64.Build.0 = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|x86.ActiveCfg = Release|Any CPU + {411A61F7-37B3-493F-9C70-4DCF569311B8}.Release|x86.Build.0 = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|ARM.ActiveCfg = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|ARM.Build.0 = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|x64.ActiveCfg = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|x64.Build.0 = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|x86.ActiveCfg = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Debug|x86.Build.0 = Debug|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|Any CPU.Build.0 = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|ARM.ActiveCfg = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|ARM.Build.0 = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|x64.ActiveCfg = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|x64.Build.0 = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|x86.ActiveCfg = Release|Any CPU + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3}.Release|x86.Build.0 = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|ARM.Build.0 = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|x64.ActiveCfg = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|x64.Build.0 = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|x86.ActiveCfg = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Debug|x86.Build.0 = Debug|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|Any CPU.Build.0 = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|ARM.ActiveCfg = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|ARM.Build.0 = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|x64.ActiveCfg = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|x64.Build.0 = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|x86.ActiveCfg = Release|Any CPU + {C1D52195-641B-4DC8-A0F9-364715A3B34A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {A842E52E-4001-4BD8-BDCD-C95630D984D4} = {D6B06B88-8371-4360-B47E-8A772B92323A} - {09A84445-2AA3-4D99-89F7-007CA3EF91A3} = {A3324369-1E2D-495C-8E96-109B6F98F003} {CFDFCEA2-BAFB-455E-BEF4-40343DE968CF} = {B70211DF-4DB4-4D29-842C-1CE527BD1EFC} {7E6D5FC5-4ED0-433C-A92C-D4A0C0146CCB} = {B70211DF-4DB4-4D29-842C-1CE527BD1EFC} - {9C42B357-7E5D-4192-850D-190EAEC0416A} = {D6B06B88-8371-4360-B47E-8A772B92323A} - {A6D741FB-B974-491A-A2CE-DE7F491FD66D} = {A3324369-1E2D-495C-8E96-109B6F98F003} - {175B67BE-9042-45EE-A8DF-D96FE8B75561} = {D6B06B88-8371-4360-B47E-8A772B92323A} {893A7FD4-62E6-4F7A-8FF9-EA502ADA88FA} = {559DC157-DDC9-44BA-B25D-0A18E286D1CC} {19495A45-67A8-460D-806C-CF158B96BBE9} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} {19727F77-249A-4AC9-859C-8441E5BD41C4} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} @@ -401,12 +470,19 @@ Global {55341205-ACB8-4E7D-8E39-0629AA8C2C32} = {B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866} {F354D8B6-F293-45ED-AF9B-B746E1232C17} = {559DC157-DDC9-44BA-B25D-0A18E286D1CC} {50AF7833-C345-4F6C-9FB1-36EB176D68E1} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} - {1B365EA8-743C-4105-B86D-FF412DAD0DAF} = {D6B06B88-8371-4360-B47E-8A772B92323A} {868FFFF9-365D-4F74-881D-68577D8D2BB0} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} {D490BE59-2AC5-4816-AF5F-1BF89F46D680} = {B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866} - {8E6E3B12-A2CB-4C2D-A871-1F2BE7FE77EA} = {B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866} {80B716DA-2C58-4F77-8AC4-2F0180D44A39} = {B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866} {ED951C8A-9CD9-40B8-989F-E231A38EAF90} = {559DC157-DDC9-44BA-B25D-0A18E286D1CC} + {1C28C6A0-23B2-43ED-B62C-C586F2976473} = {B9ACA570-A4AC-4AC9-95E2-A95BCEDBD866} + {9442B344-FC0D-4A0B-BE0E-D317C72F2A8E} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} + {6616E666-2C77-401A-B131-6FC8E9146B23} = {C3406DF1-E92C-4100-BEF9-B49F616E77C5} + {411A61F7-37B3-493F-9C70-4DCF569311B8} = {559DC157-DDC9-44BA-B25D-0A18E286D1CC} + {25B95F36-5B87-4ACD-86EC-015F32D8EAF3} = {559DC157-DDC9-44BA-B25D-0A18E286D1CC} + {38BDABA1-D402-45B7-ADEC-E36DC7D2E327} = {6CE6544E-C1DC-4EA2-BDEB-97C7E71A5C35} + {6697A04B-FCE0-479B-A11D-CACEAC2C56FC} = {6CE6544E-C1DC-4EA2-BDEB-97C7E71A5C35} + {C1D52195-641B-4DC8-A0F9-364715A3B34A} = {6CE6544E-C1DC-4EA2-BDEB-97C7E71A5C35} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2EE63A79-DD96-484C-9FBF-348067F95F0F} diff --git a/Sources/NET4.SrkToolkit.Web.Tests/ChangeCurrentCulture.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/ChangeCurrentCulture.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/ChangeCurrentCulture.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/ChangeCurrentCulture.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/DecimalModelBinderTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/DecimalModelBinderTests.cs similarity index 94% rename from Sources/NET4.SrkToolkit.Web.Tests/DecimalModelBinderTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/DecimalModelBinderTests.cs index d1652c1..0661b0f 100644 --- a/Sources/NET4.SrkToolkit.Web.Tests/DecimalModelBinderTests.cs +++ b/Sources/SrkToolkit.AspNetCore2.UnitTests/DecimalModelBinderTests.cs @@ -20,14 +20,12 @@ namespace SrkToolkit.Web.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Globalization; using SrkToolkit.Web.Mvc; - using System.Web.Mvc; + using Xunit; public class DecimalModelBinderTests { - [TestClass] public class ConvertFrenchStyleDecimals { static List> doubleExpectations; @@ -81,7 +79,7 @@ public static CultureInfo C(string name) return new CultureInfo(name); } - [TestMethod] + [Fact] public void DoubleNotFrenchStyle() { var target = new DecimalModelBinder(); @@ -94,7 +92,7 @@ public void DoubleNotFrenchStyle() } } - [TestMethod] + [Fact] public void DoubleIsFrenchStyle() { var target = new DecimalModelBinder(); @@ -107,7 +105,7 @@ public void DoubleIsFrenchStyle() } } - [TestMethod] + [Fact] public void DoubleBug1() { // typical bug we don't want to see @@ -123,7 +121,7 @@ public void DoubleBug1() Assert.AreEqual(0, result.Errors.Count); } - [TestMethod] + [Fact] public void DoubleNotNullable() { // typical bug we don't want to see @@ -138,7 +136,7 @@ public void DoubleNotNullable() Assert.AreEqual(1, result.Errors.Count); } - [TestMethod] + [Fact] public void DoubleIsNullable() { // typical bug we don't want to see @@ -154,7 +152,7 @@ public void DoubleIsNullable() Assert.AreEqual(0, result.Errors.Count); } - [TestMethod] + [Fact] public void DecimalNotFrenchStyle() { var target = new DecimalModelBinder(); @@ -168,7 +166,7 @@ public void DecimalNotFrenchStyle() } } - [TestMethod] + [Fact] public void DecimalIsFrenchStyle() { var target = new DecimalModelBinder(); @@ -182,7 +180,7 @@ public void DecimalIsFrenchStyle() } } - [TestMethod] + [Fact] public void DecimalBug1() { // typical bug we don't want to see @@ -198,7 +196,7 @@ public void DecimalBug1() Assert.AreEqual(0, result.Errors.Count); } - [TestMethod] + [Fact] public void DecimalNotNullable() { // typical bug we don't want to see @@ -213,7 +211,7 @@ public void DecimalNotNullable() Assert.AreEqual(1, result.Errors.Count); } - [TestMethod] + [Fact] public void DecimalIsNullable() { // typical bug we don't want to see @@ -229,7 +227,7 @@ public void DecimalIsNullable() Assert.AreEqual(0, result.Errors.Count); } - [TestMethod] + [Fact] public void DecimalIsNullableNull() { // typical bug we don't want to see @@ -245,7 +243,7 @@ public void DecimalIsNullableNull() Assert.AreEqual(0, result.Errors.Count); } - [TestMethod] + [Fact] public void Bug1() { string input = "123.45"; @@ -261,10 +259,9 @@ public void Bug1() } } - [TestClass] public class RegisterMethod { - [TestMethod] + [Fact] public void Works() { var binders = new ModelBinderDictionary(); diff --git a/Sources/NET4.SrkToolkit.Web.Tests/IntegerModelBinderTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/IntegerModelBinderTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/IntegerModelBinderTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/IntegerModelBinderTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/OpenGraphNameTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphNameTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/OpenGraphNameTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphNameTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/OpenGraphNamespaceTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphNamespaceTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/OpenGraphNamespaceTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphNamespaceTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/OpenGraphObjectTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphObjectTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/OpenGraphObjectTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphObjectTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/OpenGraphTagTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphTagTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/OpenGraphTagTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/OpenGraphTagTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/PageInfoTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/PageInfoTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/PageInfoTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/PageInfoTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/SrkHtmlExtensionsTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkHtmlExtensionsTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/SrkHtmlExtensionsTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/SrkHtmlExtensionsTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/SrkHttpContextExtensionsTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkHttpContextExtensionsTests.cs similarity index 97% rename from Sources/NET4.SrkToolkit.Web.Tests/SrkHttpContextExtensionsTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/SrkHttpContextExtensionsTests.cs index b13113b..a323d78 100644 --- a/Sources/NET4.SrkToolkit.Web.Tests/SrkHttpContextExtensionsTests.cs +++ b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkHttpContextExtensionsTests.cs @@ -1,92 +1,92 @@ -// -// Copyright 2014 SandRock -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace SrkToolkit.Web.Tests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Web.Fakes; - using System; - using System.Collections.Generic; - using System.Linq; - - [TestClass] - public class SrkHttpContextExtensionsTests - { - [TestClass] - public class SetTimezoneMethod - { - [TestMethod] - public void WorksWithTzObject() - { - var tz = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tz); - - Assert.IsNotNull(http.Items["Timezone"]); - Assert.AreEqual(tz, http.Items["Timezone"]); - } - - [TestMethod] - public void WorksWithTzName() - { - var tzName = "Romance Standard Time"; - var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName); - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tzName); - - Assert.IsNotNull(http.Items["Timezone"]); - Assert.AreEqual(tz, http.Items["Timezone"]); - } - - [TestMethod, ExpectedException(typeof(ArgumentException))] - public void NullTzName() - { - string tzName = null; - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tzName); - } - - [TestMethod, ExpectedException(typeof(ArgumentException))] - public void EmptyTzName() - { - string tzName = string.Empty; - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tzName); - } - - [TestMethod, ExpectedException(typeof(TimeZoneNotFoundException))] - public void InvalidTzName() - { - string tzName = "Lunar Standard Time"; - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tzName); - } - - [TestMethod] - public void GetterWorks() - { - var tzName = "Romance Standard Time"; - var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName); - var http = new BasicHttpContext(); - SrkHttpContextExtensions.SetTimezone(http, tzName); - var result = SrkHttpContextExtensions.GetTimezone(http); - - Assert.IsNotNull(result); - Assert.AreEqual(tz, result); - } - } - } -} +// +// Copyright 2014 SandRock +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace SrkToolkit.Web.Tests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SrkToolkit.Web.Fakes; + using System; + using System.Collections.Generic; + using System.Linq; + + [TestClass] + public class SrkHttpContextExtensionsTests + { + [TestClass] + public class SetTimezoneMethod + { + [TestMethod] + public void WorksWithTzObject() + { + var tz = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tz); + + Assert.IsNotNull(http.Items["Timezone"]); + Assert.AreEqual(tz, http.Items["Timezone"]); + } + + [TestMethod] + public void WorksWithTzName() + { + var tzName = "Romance Standard Time"; + var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName); + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tzName); + + Assert.IsNotNull(http.Items["Timezone"]); + Assert.AreEqual(tz, http.Items["Timezone"]); + } + + [TestMethod, ExpectedException(typeof(ArgumentException))] + public void NullTzName() + { + string tzName = null; + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tzName); + } + + [TestMethod, ExpectedException(typeof(ArgumentException))] + public void EmptyTzName() + { + string tzName = string.Empty; + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tzName); + } + + [TestMethod, ExpectedException(typeof(TimeZoneNotFoundException))] + public void InvalidTzName() + { + string tzName = "Lunar Standard Time"; + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tzName); + } + + [TestMethod] + public void GetterWorks() + { + var tzName = "Romance Standard Time"; + var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName); + var http = new BasicHttpContext(); + SrkHttpContextExtensions.SetTimezone(http, tzName); + var result = SrkHttpContextExtensions.GetTimezone(http); + + Assert.IsNotNull(result); + Assert.AreEqual(tz, result); + } + } + } +} diff --git a/Sources/NET4.SrkToolkit.Web.Tests/SrkMvcCollectionExtensionsTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkMvcCollectionExtensionsTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/SrkMvcCollectionExtensionsTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/SrkMvcCollectionExtensionsTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/SrkRequestExtensionsTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkRequestExtensionsTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/SrkRequestExtensionsTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/SrkRequestExtensionsTests.cs diff --git a/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkToolkit.AspNetCore2.UnitTests.csproj b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkToolkit.AspNetCore2.UnitTests.csproj new file mode 100644 index 0000000..9ed2389 --- /dev/null +++ b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkToolkit.AspNetCore2.UnitTests.csproj @@ -0,0 +1,39 @@ + + + + net7.0 + disable + disable + + false + + SrkToolkit.AspNetCore.UnitTests + + + + TRACE;ASPMVCCORE + + + + TRACE;ASPMVCCORE + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/Sources/NET4.SrkToolkit.Web.Tests/SrkUrlHelperExtensionsTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/SrkUrlHelperExtensionsTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/SrkUrlHelperExtensionsTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/SrkUrlHelperExtensionsTests.cs diff --git a/Sources/NET4.SrkToolkit.Web.Tests/WebDependenciesTests.cs b/Sources/SrkToolkit.AspNetCore2.UnitTests/WebDependenciesTests.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web.Tests/WebDependenciesTests.cs rename to Sources/SrkToolkit.AspNetCore2.UnitTests/WebDependenciesTests.cs diff --git a/Sources/SrkToolkit.Common.CoreUnitTests/SrkToolkit.Common.CoreUnitTests.csproj b/Sources/SrkToolkit.Common.CoreUnitTests/SrkToolkit.Common.CoreUnitTests.csproj new file mode 100644 index 0000000..7b3ccd0 --- /dev/null +++ b/Sources/SrkToolkit.Common.CoreUnitTests/SrkToolkit.Common.CoreUnitTests.csproj @@ -0,0 +1,99 @@ + + + + net7.0 + disable + disable + + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + AssertTests.cs + + + CompositeDisposableTests.cs + + + CultureInfoHelperTests.cs + + + DictionaryWrapperTests.cs + + + DisaposableOnceTests.cs + + + EmailAddressTests.cs + + + EnumStrings.Designer.cs + + + EnumToolsTests.cs + + + ObservableCollectionExtensionsTests.cs + + + SrkArrayExtensionsTests.cs + + + SrkDateTimeExtensionsTests.cs + + + SrkIDictionaryExtensionsTests.cs + + + SrkIListExtensionsTests.cs + + + SrkNameValueCollectionExtensions.cs + + + SrkStringExtensionsTests.cs + + + SrkStringTransformer.cs + + + SrkTimeZoneInfoExtensionsTests.cs + + + StringReplacerTests.cs + + + ValidateTEsts.cs + + + + + + EnumStrings.fr.resx + + + EnumStrings.resx + PublicResXFileCodeGenerator + + + + diff --git a/Sources/SrkToolkit.Common.FxUnitTests/App.config b/Sources/SrkToolkit.Common.FxUnitTests/App.config new file mode 100644 index 0000000..edb3ee9 --- /dev/null +++ b/Sources/SrkToolkit.Common.FxUnitTests/App.config @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/NET4.SrkToolkit.Common.Tests/AssertTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/AssertTests.cs similarity index 69% rename from Sources/NET4.SrkToolkit.Common.Tests/AssertTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/AssertTests.cs index 1ef44ca..eec1c43 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/AssertTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/AssertTests.cs @@ -5,14 +5,13 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; public class AssertTests { - [TestClass] public class AreEqualMethod { - [TestMethod] + [Fact] public void BothNull_Ok() { string expected = null; @@ -20,7 +19,7 @@ public void BothNull_Ok() SrkToolkit.Testing.Assert.AreEqual(expected, actual); } - [TestMethod] + [Fact] public void BothEmpty_Ok() { string expected = ""; @@ -28,23 +27,29 @@ public void BothEmpty_Ok() SrkToolkit.Testing.Assert.AreEqual(expected, actual); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void NullVsEmpty_Throws() { string expected = null; string actual = ""; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyVsNull_Throws() { string expected = ""; string actual = null; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod] + [Fact] public void SameString_Ok() { string expected = "Tyuhn/*"; @@ -52,83 +57,109 @@ public void SameString_Ok() SrkToolkit.Testing.Assert.AreEqual(expected, actual); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void ShorterResult_Ok() { string expected = "Tyuhn/*"; string actual = "Tyuhn/"; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void LongerResult_Ok() { string expected = "Tyuhn/*"; string actual = "Tyuhn/*-"; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void DiffAt0_Ok() { string expected = "Tyuhn/*"; string actual = "7yuhn/*"; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void DiffAt1_Ok() { string expected = "Tyuhn/*"; string actual = "T0uhn/*"; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void LongDiffAt15_Ok() { string expected = "aaaaaaaaaaaaaaaTyuhn/*"; string actual = "aaaaaaaaaaaaaaa7yuhn/*"; - SrkToolkit.Testing.Assert.AreEqual(expected, actual); + Assert.Throws(() => + { + SrkToolkit.Testing.Assert.AreEqual(expected, actual); + }); } } - [TestClass] public class ContainsMethod { - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void BothNull_Throws() { string expected = null; string actual = null; + Assert.Throws(() => + { SrkToolkit.Testing.Assert.Contains(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void BothEmpty_Throws() { string expected = ""; string actual = ""; + Assert.Throws(() => + { SrkToolkit.Testing.Assert.Contains(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void NullVsEmpty_Throws() { string expected = null; string actual = ""; + Assert.Throws(() => + { SrkToolkit.Testing.Assert.Contains(expected, actual); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyVsNull_Throws() { string expected = ""; string actual = null; + Assert.Throws(() => + { SrkToolkit.Testing.Assert.Contains(expected, actual); + }); } - [TestMethod] + [Fact] public void SameString_Ok() { string expected = "Tyuhn/*"; @@ -136,7 +167,7 @@ public void SameString_Ok() SrkToolkit.Testing.Assert.Contains(expected, actual); } - [TestMethod] + [Fact] public void Contains_Ok() { string expected = "Tyuhn/*"; @@ -144,7 +175,7 @@ public void Contains_Ok() SrkToolkit.Testing.Assert.Contains(expected, actual); } - [TestMethod] + [Fact] public void DoesNotContain_Ok() { string expected = "ioioioi"; @@ -152,15 +183,15 @@ public void DoesNotContain_Ok() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual("Searched string <"+expected+"> was not found.", ex.Message); + Assert.Equal("Searched string <"+expected+"> was not found.", ex.Message); } } - [TestMethod] + [Fact] public void PartialContains2In3_Longer_Throws() { string expected = "rty"; @@ -168,15 +199,15 @@ public void PartialContains2In3_Longer_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual("Searched string was not found. Best partial match:\r\nV> ert_______\r\nS> -rty\r\n ^^", ex.Message); + Assert.Equal("Searched string was not found. Best partial match:\r\nV> ert_______\r\nS> -rty\r\n ^^", ex.Message); } } - [TestMethod] + [Fact] public void PartialContains2In3_Shorter_Throws() { string expected = "rty"; @@ -185,15 +216,15 @@ public void PartialContains2In3_Shorter_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains2In3Prefixed_Shorter_Throws() { string expected = "rty"; @@ -202,15 +233,15 @@ public void PartialContains2In3Prefixed_Shorter_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains2In3Prefixed_Longer_Throws() { string expected = "rty"; @@ -219,15 +250,15 @@ public void PartialContains2In3Prefixed_Longer_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains2In3Prefixed_MuchLonger_Throws() { string expected = "rty"; @@ -236,15 +267,15 @@ public void PartialContains2In3Prefixed_MuchLonger_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains3In4_Longer_Throws() { string expected = "rtyu"; @@ -253,15 +284,15 @@ public void PartialContains3In4_Longer_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains3In4_Shorter_Throws() { string expected = "rtyu"; @@ -270,15 +301,15 @@ public void PartialContains3In4_Shorter_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains3In4Prefixed_Shorter_Throws() { string expected = "rtyu"; @@ -287,15 +318,15 @@ public void PartialContains3In4Prefixed_Shorter_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains3In4Prefixed_Longer_Throws() { string expected = "rtyu"; @@ -304,15 +335,15 @@ public void PartialContains3In4Prefixed_Longer_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } - [TestMethod] + [Fact] public void PartialContains3In4Prefixed_MuchLonger_Throws() { string expected = "rtyu"; @@ -321,11 +352,11 @@ public void PartialContains3In4Prefixed_MuchLonger_Throws() try { SrkToolkit.Testing.Assert.Contains(expected, actual); - Assert.Fail("Expected exception"); + throw new InvalidOperationException("Expected exception"); } catch (ArgumentException ex) { - Assert.AreEqual(expectedMessage, ex.Message); + Assert.Equal(expectedMessage, ex.Message); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/CompositeDisposableTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/CompositeDisposableTests.cs similarity index 86% rename from Sources/NET4.SrkToolkit.Common.Tests/CompositeDisposableTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/CompositeDisposableTests.cs index 9edb21b..146a492 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/CompositeDisposableTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/CompositeDisposableTests.cs @@ -3,17 +3,16 @@ namespace SrkToolkit.Common.Tests { using System; using System.Collections.Generic; + using System.Diagnostics; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Diagnostics; + using Xunit; public class CompositeDisposableTests { - [TestClass] public class AddMethod { - [TestMethod] + [Fact] public void IsFluent() { // prepare @@ -25,10 +24,10 @@ public void IsFluent() object actual = target.Add(disposable); // verify - Assert.AreSame(expected, actual); + Assert.Same(expected, actual); } - [TestMethod] + [Fact] public void DisposesChildren() { // prepare @@ -40,10 +39,10 @@ public void DisposesChildren() target.Dispose(); // verify - Assert.IsTrue(disposable.IsDisposed); + Assert.True(disposable.IsDisposed); } - [TestMethod] + [Fact] public void MultipleDisposeDoNotThrow() { // prepare @@ -57,7 +56,7 @@ public void MultipleDisposeDoNotThrow() target.Dispose(); } - [TestMethod] + [Fact] public void DisposeAndForget() { // prepare @@ -73,10 +72,10 @@ public void DisposeAndForget() target.Dispose(); // verify - Assert.IsFalse(disposable.IsDisposed); + Assert.False(disposable.IsDisposed); } - [TestMethod] + [Fact] public void IgnoresExceptions() { // prepare diff --git a/Sources/NET4.SrkToolkit.Common.Tests/CultureInfoHelperTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/CultureInfoHelperTests.cs similarity index 66% rename from Sources/NET4.SrkToolkit.Common.Tests/CultureInfoHelperTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/CultureInfoHelperTests.cs index 22583a6..4ee9beb 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/CultureInfoHelperTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/CultureInfoHelperTests.cs @@ -1,67 +1,66 @@  namespace SrkToolkit.Common.Tests { + using SrkToolkit.Globalization; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Globalization; + using Xunit; public class CultureInfoHelperTests { - [TestClass] public class GetCountriesMethod { static IList countries = CultureInfoHelper.GetCountries(); - [TestMethod] + [Fact] public void HasUK() { string nativeName = "United Kingdom"; string englishName = "United Kingdom"; var match = countries.SingleOrDefault(c => c.NativeName == nativeName); - Assert.IsNotNull(match); - Assert.AreEqual(englishName, match.EnglishName); - Assert.AreEqual(nativeName, match.NativeName); + Assert.NotNull(match); + Assert.Equal(englishName, match.EnglishName); + Assert.Equal(nativeName, match.NativeName); } - [TestMethod] + [Fact] public void HasUSA() { string nativeName = "United States"; string englishName = "United States"; var match = countries.SingleOrDefault(c => c.NativeName == nativeName); - Assert.IsNotNull(match); - Assert.AreEqual(englishName, match.EnglishName); - Assert.AreEqual(nativeName, match.NativeName); + Assert.NotNull(match); + Assert.Equal(englishName, match.EnglishName); + Assert.Equal(nativeName, match.NativeName); } - [TestMethod] + [Fact] public void HasFrance() { string nativeName = "France"; string englishName = "France"; var match = countries.SingleOrDefault(c => c.NativeName == nativeName); - Assert.IsNotNull(match); - Assert.AreEqual(englishName, match.EnglishName); - Assert.AreEqual(nativeName, match.NativeName); + Assert.NotNull(match); + Assert.Equal(englishName, match.EnglishName); + Assert.Equal(nativeName, match.NativeName); } - [TestMethod] // something is wrong + [Fact] // something is wrong public void HasChina() { string englishName = "China"; var match = countries.SingleOrDefault(c => c.EnglishName == englishName); - Assert.IsNotNull(match); + Assert.NotNull(match); } - [TestMethod] // something is wrong + [Fact] // something is wrong public void HasChina2() { string nativeName = "ཀྲུང་ཧྭ་མི་དམངས་སྤྱི་མཐུན་རྒྱལ་ཁབ"; @@ -69,7 +68,7 @@ public void HasChina2() string cultureName = "zh-CN"; var match = countries.SingleOrDefault(c => c.EnglishName == englishName); - Assert.IsNotNull(match); + Assert.NotNull(match); } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/CultureInfoAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/CultureInfoAttributeTests.cs similarity index 72% rename from Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/CultureInfoAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/CultureInfoAttributeTests.cs index 80a0be1..ad6f4f1 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/CultureInfoAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/CultureInfoAttributeTests.cs @@ -1,49 +1,48 @@  namespace SrkToolkit.Common.Tests.DataAnnotations { + using SrkToolkit.DataAnnotations; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; using System.ComponentModel.DataAnnotations; + using Xunit; - [TestClass] public class CultureInfoAttributeTests { - [TestMethod] + [Fact] public void ReturnsTrueWithEmptyValue() { var attr = new CultureInfoAttribute(); string value = string.Empty; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ReturnsTrueWithNullValue() { var attr = new CultureInfoAttribute(); string value = null; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ReturnsTrueWithValidValue() { var attr = new CultureInfoAttribute(); string value = "fr-FR"; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AllowNeutral_ReturnsTrueWithNeutral() { var attr = new CultureInfoAttribute(); @@ -51,10 +50,10 @@ public void AllowNeutral_ReturnsTrueWithNeutral() string value = "fr"; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AllowNeutral_ReturnsTrueWithNonNeutral() { var attr = new CultureInfoAttribute(); @@ -62,10 +61,10 @@ public void AllowNeutral_ReturnsTrueWithNonNeutral() string value = "fr-CA"; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void DisallowNeutral_ReturnsFalseWithNeutral() { var attr = new CultureInfoAttribute(); @@ -74,13 +73,13 @@ public void DisallowNeutral_ReturnsFalseWithNeutral() var context = new ValidationContext(new object(), null, null); context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNotNull(result); - Assert.AreEqual("The culture is not valid.", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); + Assert.NotNull(result); + Assert.Equal("The culture is not valid.", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); } - [TestMethod] + [Fact] public void DisallowNeutral_ReturnsTrueWithNonNeutral() { var attr = new CultureInfoAttribute(); @@ -88,14 +87,14 @@ public void DisallowNeutral_ReturnsTrueWithNonNeutral() string value = "fr-CA"; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void DoNotAllowNeutralByDefault() { var attr = new CultureInfoAttribute(); - Assert.IsFalse(attr.AllowNeutralCulture); + Assert.False(attr.AllowNeutralCulture); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/EmailAddressExAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/EmailAddressExAttributeTests.cs similarity index 79% rename from Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/EmailAddressExAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/EmailAddressExAttributeTests.cs index 1bf649f..1060d63 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/EmailAddressExAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/EmailAddressExAttributeTests.cs @@ -1,21 +1,20 @@  namespace SrkToolkit.Common.Tests.DataAnnotations { - using Microsoft.VisualStudio.TestTools.UnitTesting; using SrkToolkit.DataAnnotations; using System; using System.Collections.Generic; using System.Linq; using System.Text; + using Xunit; - [TestClass] public class EmailAddressExAttributeTests { -#if NET40 +#if NET40 || NETFRAMEWORK #else #endif -#if NET40 +#if NET40 || NETFRAMEWORK private static EmailAddressAttribute GetTarget() { return new EmailAddressAttribute(); @@ -27,175 +26,175 @@ private static EmailAddressExAttribute GetTarget() } #endif - [TestMethod] + [Fact] public void AllowOne_NullValue_Pass() { string input = null; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_EmptyValue_Pass() { string input = string.Empty; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_WhiteValue_Pass() { string input = " "; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_BasicAddress_Pass() { string input = "michel.salamander@yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_BasicAddressWithTag_Pass() { string input = "michel.salamander+hello-world@yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_BasicAddressWithDiacritics_Pass() { string input = "michél.salamânder@yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowOne_InvalidAddress1_Fail() { string input = "michél salamânder@yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowOne_InvalidAddress2_Fail() { string input = "michel salamander@yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowOne_InvalidAddress3_Fail() { string input = "michel.salamander.yahoooo.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowOne_InvalidAddress4_Fail() { string input = "hello"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowOne_InvalidAddress5_Fail() { string input = ".@test.com"; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowOne_BasicAddressUntrimmed_Fail() { string input = " michel.salamander@yahoooo.com "; var target = GetTarget(); var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowMultiple_NullValue_Pass() { string input = null; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_EmptyValue_Pass() { string input = string.Empty; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_WhiteValue_Pass() { string input = " "; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_BasicAddress1_Pass() { string input = "michel.salamander@yahoooo.com"; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_BasicAddress2_Pass() { string input = "michel.salamander@yahoooo.com michel.salamander@yahoooo.com"; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_BasicAddress2Untrimmed_Pass() { string input = " michel.salamander@yahoooo.com \r\nmichel.salamander@yahoooo.com "; var target = GetTarget(); target.AllowMultiple = true; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_BelowMinimum_Fail() { string input = "michel.salamander@yahoooo.com"; @@ -203,10 +202,10 @@ public void AllowMultiple_BelowMinimum_Fail() target.AllowMultiple = true; target.MinimumAddresses = 2; var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowMultiple_AtMinimum_Pass() { string input = " michel.salamander@yahoooo.com \r\nmichel.salamander@yahoooo.com "; @@ -214,10 +213,10 @@ public void AllowMultiple_AtMinimum_Pass() target.AllowMultiple = true; target.MinimumAddresses = 2; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_AboveMinimum_Pass() { string input = " michel.salamander@yahoooo.com \r\nmichel.salamander@yahoooo.com test@test.com"; @@ -225,10 +224,10 @@ public void AllowMultiple_AboveMinimum_Pass() target.AllowMultiple = true; target.MinimumAddresses = 2; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_AboveMaximum_Fail() { string input = " michel.salamander@yahoooo.com \r\nmichel.salamander@yahoooo.com test@test.com"; @@ -236,10 +235,10 @@ public void AllowMultiple_AboveMaximum_Fail() target.AllowMultiple = true; target.MaximumAddresses = 2; var result = target.IsValid(input); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void AllowMultiple_AtMaximum_Pass() { string input = " michel.salamander@yahoooo.com \r\nmichel.salamander@yahoooo.com "; @@ -247,10 +246,10 @@ public void AllowMultiple_AtMaximum_Pass() target.AllowMultiple = true; target.MaximumAddresses = 2; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void AllowMultiple_BelowMaximum_Pass() { string input = "michel.salamander@yahoooo.com"; @@ -258,7 +257,7 @@ public void AllowMultiple_BelowMaximum_Pass() target.AllowMultiple = true; target.MaximumAddresses = 2; var result = target.IsValid(input); - Assert.IsTrue(result); + Assert.True(result); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/PhoneNumberAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/PhoneNumberAttributeTests.cs similarity index 64% rename from Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/PhoneNumberAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/PhoneNumberAttributeTests.cs index 348efc1..ad02b71 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/PhoneNumberAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/PhoneNumberAttributeTests.cs @@ -1,23 +1,21 @@  namespace SrkToolkit.Common.Tests.DataAnnotations { + using SrkToolkit.DataAnnotations; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Text.RegularExpressions; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; using System.ComponentModel.DataAnnotations; + using Xunit; - [TestClass] public class PhoneNumberAttributeTests { - [TestClass] public class RegexTests { - [TestMethod] + [Fact] public void StupidInputFails() { // prepare @@ -29,10 +27,10 @@ public void StupidInputFails() result = target.IsMatch(input); // verify - Assert.IsFalse(result, "Should not allow stupid input"); + Assert.False(result, "Should not allow stupid input"); } - [TestMethod] + [Fact] public void LocalNumberFails() { // prepare @@ -44,10 +42,10 @@ public void LocalNumberFails() result = target.IsMatch(input); // verify - Assert.IsFalse(result, "Should not allow local numbers"); + Assert.False(result, "Should not allow local numbers"); } - [TestMethod] + [Fact] public void ValidNumberAreAllowed() { // prepare @@ -59,10 +57,10 @@ public void ValidNumberAreAllowed() result = target.IsMatch(input); // verify - Assert.IsTrue(result, "Valid numbers should pass"); + Assert.True(result, "Valid numbers should pass"); } - [TestMethod] + [Fact] public void SeparatorsAreAllowed() { // prepare @@ -74,99 +72,104 @@ public void SeparatorsAreAllowed() result = target.IsMatch(input); // verify - Assert.IsTrue(result, "Separators should pass validation"); + Assert.True(result, "Separators should pass validation"); } } - [TestClass] public class ConvertNationalToInternationalMethod { - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyIsInvalid() { string input = "", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsFalse(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.IsNull(output); + Assert.Throws(() => + { + Assert.False(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Null(output); + }); } - [TestMethod] + [Fact] public void InternationalBasicWorks() { string input = "+33123456789", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsTrue(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.AreEqual(input, output); + Assert.True(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Equal(input, output); } - [TestMethod] + [Fact] public void InternationalSpacedWorks() { string input = "+33 123 456 789", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsTrue(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.AreEqual(input, output); + Assert.True(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Equal(input, output); } - [TestMethod] + [Fact] public void InternationalDashedWorks() { string input = "+33-123-456-789", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsTrue(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.AreEqual(input, output); + Assert.True(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Equal(input, output); } - [TestMethod] + [Fact] public void InternationalDottedWorks() { string input = "+33.123.456.789", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsTrue(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.AreEqual(input, output); + Assert.True(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Equal(input, output); } - [TestMethod, ExpectedException(typeof(InvalidOperationException))] + [Fact] public void NationalInvariantFails() { string input = "123.456.789", output = null; CultureInfo culture = CultureInfo.InvariantCulture; - Assert.IsFalse(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); - Assert.IsNull(output); + Assert.Throws(() => + { + Assert.False(PhoneNumberAttribute.ConvertNationalToInternational(input, culture, out output)); + Assert.Null(output); + }); } } - [TestMethod] + [Fact] public void ReturnsTrueWithEmptyValue() { var attr = new PhoneNumberAttribute(); string value = string.Empty; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ReturnsTrueWithNullValue() { var attr = new PhoneNumberAttribute(); string value = null; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ReturnsTrueWithValidValue() { var attr = new PhoneNumberAttribute(); string value = "+33123456798"; bool expected = true; bool result = attr.IsValid(value); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ReturnsFalseWithObviousInvalid() { var attr = new PhoneNumberAttribute(); @@ -174,10 +177,10 @@ public void ReturnsFalseWithObviousInvalid() var context = new ValidationContext(new object(), null, null); context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNotNull(result); - Assert.AreEqual("Use the international phone number format (+xxyyyyyyyyyy).", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); + Assert.NotNull(result); + Assert.Equal("Use the international phone number format (+xxyyyyyyyyyy).", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TimezoneAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TimezoneAttributeTests.cs similarity index 72% rename from Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TimezoneAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TimezoneAttributeTests.cs index 6157a27..55185f5 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DataAnnotations/TimezoneAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TimezoneAttributeTests.cs @@ -1,24 +1,23 @@  namespace SrkToolkit.Common.Tests.DataAnnotations { + using SrkToolkit.DataAnnotations; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; using System.ComponentModel.DataAnnotations; + using Xunit; - [TestClass] public class TimezoneAttributeTests { - [TestMethod] + [Fact] public void Constructs() { var value = new TimezoneAttribute(); } - [TestMethod] + [Fact] public void Model_ValidTz_Pass() { var model = new Model @@ -26,10 +25,10 @@ public void Model_ValidTz_Pass() Tz = "Romance Standard Time", }; var attr = (TimezoneAttribute)model.GetType().GetProperty("Tz").GetCustomAttributes(false).First(); - Assert.IsTrue(attr.IsValid(model.Tz)); + Assert.True(attr.IsValid(model.Tz)); } - [TestMethod] + [Fact] public void Model_NullTz_Pass() { var model = new Model @@ -37,10 +36,10 @@ public void Model_NullTz_Pass() Tz = null, }; var attr = (TimezoneAttribute)model.GetType().GetProperty("Tz").GetCustomAttributes(false).First(); - Assert.IsTrue(attr.IsValid(model.Tz)); + Assert.True(attr.IsValid(model.Tz)); } - [TestMethod] + [Fact] public void Model_EmptyTz_Pass() { var model = new Model @@ -48,10 +47,10 @@ public void Model_EmptyTz_Pass() Tz = "", }; var attr = (TimezoneAttribute)model.GetType().GetProperty("Tz").GetCustomAttributes(false).First(); - Assert.IsTrue(attr.IsValid(model.Tz)); + Assert.True(attr.IsValid(model.Tz)); } - [TestMethod] + [Fact] public void Model_InvalidTz_Invalid() { var model = new Model @@ -59,10 +58,10 @@ public void Model_InvalidTz_Invalid() Tz = "Paris", // not a valid timezone id }; var attr = (TimezoneAttribute)model.GetType().GetProperty("Tz").GetCustomAttributes(false).First(); - Assert.IsFalse(attr.IsValid(model.Tz)); + Assert.False(attr.IsValid(model.Tz)); } - [TestMethod] + [Fact] public void InvalidTz_Invalid() { var attr = new TimezoneAttribute(); @@ -70,10 +69,10 @@ public void InvalidTz_Invalid() var context = new ValidationContext(new object(), null, null); context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNotNull(result); - Assert.AreEqual(@"The timezone is not valid.", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); + Assert.NotNull(result); + Assert.Equal(@"The timezone is not valid.", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); } public class Model diff --git a/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TwitterUsernameAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TwitterUsernameAttributeTests.cs new file mode 100644 index 0000000..a044a75 --- /dev/null +++ b/Sources/SrkToolkit.Common.FxUnitTests/DataAnnotations/TwitterUsernameAttributeTests.cs @@ -0,0 +1,163 @@ + +namespace Sparkle.UnitTests +{ + using SrkToolkit.DataAnnotations; + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.Linq; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading.Tasks; + using Xunit; + + public class TwitterUsernameAttributeTests + { + public class RegexTests + { + private Regex TwitterRegex; + + public RegexTests() + { + this.TwitterRegex = new Regex(TwitterUsernameAttribute.TwitterRegex, RegexOptions.Compiled); + } + + [Fact] + public void TwitterUsernameNoMatch() + { + Assert.False(this.TwitterRegex.IsMatch("é'çà&=")); + Assert.False(this.TwitterRegex.IsMatch("user@name")); + Assert.False(this.TwitterRegex.IsMatch("usernamereallytoolong")); + } + + [Fact] + public void TwitterUsernameMatch() + { + Assert.True(this.TwitterRegex.IsMatch("username")); + Assert.True(this.TwitterRegex.IsMatch("user_name")); + Assert.True(this.TwitterRegex.IsMatch("@username")); + } + + [Fact] + public void TwitterWeirdUrlMatch() + { + Assert.True(this.TwitterRegex.IsMatch("twitter/username")); + Assert.True(this.TwitterRegex.IsMatch("twitter/@username")); + } + + [Fact] + public void TwitterUrlWithoutProtocolMatch() + { + Assert.True(this.TwitterRegex.IsMatch("twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("twitter.com/@username")); + Assert.True(this.TwitterRegex.IsMatch("www.twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("www.twitter.com/@username")); + } + + [Fact] + public void TwitterUrlWithProtocolMatch() + { + Assert.True(this.TwitterRegex.IsMatch("http://twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("https://twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("http://twitter.com/@username")); + Assert.True(this.TwitterRegex.IsMatch("https://twitter.com/@username")); + Assert.True(this.TwitterRegex.IsMatch("http://www.twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("https://www.twitter.com/username")); + Assert.True(this.TwitterRegex.IsMatch("http://www.twitter.com/@username")); + Assert.True(this.TwitterRegex.IsMatch("https://www.twitter.com/@username")); + } + } + + public class GetUsernameMethod + { + [Fact] + public void TwitterGetUsernameFail() + { + string username = null; + + Assert.False(TwitterUsernameAttribute.GetUsername("é'çà&=", out username)); + Assert.Null(username); + Assert.False(TwitterUsernameAttribute.GetUsername("user@name", out username)); + Assert.Null(username); + Assert.False(TwitterUsernameAttribute.GetUsername("usernamereallytoolong", out username)); + Assert.Null(username); + } + + [Fact] + public void TwitterGetUsernameSuccess() + { + string username = null; + + Assert.True(TwitterUsernameAttribute.GetUsername("username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("user_name", out username)); + Assert.Equal("user_name", username); + Assert.True(TwitterUsernameAttribute.GetUsername("@username", out username)); + Assert.Equal("username", username); + } + + [Fact] + public void TwitterGetUsernameFromWeirdUrl() + { + string username = null; + + Assert.True(TwitterUsernameAttribute.GetUsername("twitter/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("twitter/@username", out username)); + Assert.Equal("username", username); + } + + [Fact] + public void TwitterGetUsernameFromUrlWithoutProtocol() + { + string username = null; + + Assert.True(TwitterUsernameAttribute.GetUsername("twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("twitter.com/@username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("www.twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("www.twitter.com/@username", out username)); + Assert.Equal("username", username); + } + + [Fact] + public void TwitterGetUsernameFromUrlWithProtocol() + { + string username = null; + + Assert.True(TwitterUsernameAttribute.GetUsername("http://twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("http://twitter.com/@username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("http://www.twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("http://www.twitter.com/@username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("https://twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("https://twitter.com/@username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("https://www.twitter.com/username", out username)); + Assert.Equal("username", username); + Assert.True(TwitterUsernameAttribute.GetUsername("https://www.twitter.com/@username", out username)); + Assert.Equal("username", username); + } + } + + [Fact] + public void ObviousInvalid() + { + var attr = new TwitterUsernameAttribute(); + string value = "foo bar", name = "Twitter"; + var context = new ValidationContext(new object(), null, null); + context.MemberName = name; + var result = attr.GetValidationResult(value, context); + Assert.NotNull(result); + Assert.Equal(@"Invalid Twitter username. You must provide the username or the url to your account.", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); + } + } +} diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DateRangeAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DateRangeAttributeTests.cs similarity index 77% rename from Sources/NET4.SrkToolkit.Common.Tests/DateRangeAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DateRangeAttributeTests.cs index a787eff..76797ad 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DateRangeAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DateRangeAttributeTests.cs @@ -1,70 +1,69 @@ - -namespace SrkToolkit.Common.Tests -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; - using System.ComponentModel.DataAnnotations; - - [TestClass] - public class DateRangeAttributeTests - { - [TestMethod] - public void NullValue_IsValid() - { - string value = null, name = "Date"; - var attr = new DateRangeAttribute(); - var context = new ValidationContext(new object(), null, null); - context.MemberName = name; - var result = attr.GetValidationResult(value, context); - - Assert.IsNull(result); - } - - [TestMethod] - public void EmptyValue_IsValid() - { - string value = "", name = "Date"; - var attr = new DateRangeAttribute(); - var context = new ValidationContext(new object(), null, null); - context.MemberName = name; - var result = attr.GetValidationResult(value, context); - - Assert.IsNull(result); - } - - [TestMethod] - public void InvalidValue_IsInvalid() - { - string value = "test", name = "Date"; - var attr = new DateRangeAttribute(); - attr.Minimum = "2015-01-01T00:00:00"; - attr.Maximum = "2015-01-03T00:00:00"; - var context = new ValidationContext(new object(), null, null); - context.MemberName = name; - var result = attr.GetValidationResult(value, context); - - Assert.IsNotNull(result); - Assert.AreEqual("The field Date must be between 2015-01-01 00:00:00 and 2015-01-03 00:00:00.", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); - } - - [TestMethod] - public void ValidValue_IsValid() - { - string value = "2015-01-02T01:00:02", name = "Date"; - var attr = new DateRangeAttribute(); - attr.Minimum = "2015-01-01T00:00:00"; - attr.Maximum = "2015-01-03T00:00:00"; - var context = new ValidationContext(new object(), null, null); - context.MemberName = name; - var result = attr.GetValidationResult(value, context); - - Assert.IsNull(result); - } - } -} + +namespace SrkToolkit.Common.Tests +{ + using SrkToolkit.DataAnnotations; + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.Linq; + using System.Text; + using Xunit; + + public class DateRangeAttributeTests + { + [Fact] + public void NullValue_IsValid() + { + string value = null, name = "Date"; + var attr = new DateRangeAttribute(); + var context = new ValidationContext(new object(), null, null); + context.MemberName = name; + var result = attr.GetValidationResult(value, context); + + Assert.Null(result); + } + + [Fact] + public void EmptyValue_IsValid() + { + string value = "", name = "Date"; + var attr = new DateRangeAttribute(); + var context = new ValidationContext(new object(), null, null); + context.MemberName = name; + var result = attr.GetValidationResult(value, context); + + Assert.Null(result); + } + + [Fact] + public void InvalidValue_IsInvalid() + { + string value = "test", name = "Date"; + var attr = new DateRangeAttribute(); + attr.Minimum = "2015-01-01T00:00:00"; + attr.Maximum = "2015-01-03T00:00:00"; + var context = new ValidationContext(new object(), null, null); + context.MemberName = name; + var result = attr.GetValidationResult(value, context); + + Assert.NotNull(result); + Assert.Equal("The field Date must be between 2015-01-01 00:00:00 and 2015-01-03 00:00:00.", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); + } + + [Fact] + public void ValidValue_IsValid() + { + string value = "2015-01-02T01:00:02", name = "Date"; + var attr = new DateRangeAttribute(); + attr.Minimum = "2015-01-01T00:00:00"; + attr.Maximum = "2015-01-03T00:00:00"; + var context = new ValidationContext(new object(), null, null); + context.MemberName = name; + var result = attr.GetValidationResult(value, context); + + Assert.Null(result); + } + } +} diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DictionaryWrapperTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DictionaryWrapperTests.cs similarity index 64% rename from Sources/NET4.SrkToolkit.Common.Tests/DictionaryWrapperTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DictionaryWrapperTests.cs index b5e18a6..c57b8e9 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DictionaryWrapperTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DictionaryWrapperTests.cs @@ -1,60 +1,64 @@  namespace SrkToolkit.Common.Tests { + using SrkToolkit.Collections; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using SrkToolkit.Collections; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; - [TestClass] public class DictionaryWrapperTests { - [TestClass] public class WrappedHashtableTests { - [TestMethod] + [Fact] public void AddOnce_StringInt() { string key = "kk"; int value = 42; var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); - Assert.IsTrue(target.Count == 1); + Assert.True(target.Count == 1); } - [TestMethod] + [Fact] public void AddOnce_StringObject() { string key = "kk"; object value = new object(); var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); - Assert.IsTrue(target.Count == 1); + Assert.True(target.Count == 1); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void AddTwice_StringInt() { string key = "kk"; int value = 42; - var target = new DictionaryWrapper(new System.Collections.Hashtable()); - target.Add(key, value); - target.Add(key, value); + Assert.Throws(() => + { + var target = new DictionaryWrapper(new System.Collections.Hashtable()); + target.Add(key, value); + target.Add(key, value); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void AddTwice_StringObject() { string key = "kk"; object value = new object(); - var target = new DictionaryWrapper(new System.Collections.Hashtable()); - target.Add(key, value); - target.Add(key, value); + Assert.Throws(() => + { + var target = new DictionaryWrapper(new System.Collections.Hashtable()); + target.Add(key, value); + target.Add(key, value); + }); } - [TestMethod] + [Fact] public void GetValid_StringInt() { string key = "kk"; @@ -62,10 +66,10 @@ public void GetValid_StringInt() var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); var result = target[key]; - Assert.AreEqual(result, value); + Assert.Equal(result, value); } - [TestMethod] + [Fact] public void GetValid_StringObject() { string key = "kk"; @@ -73,27 +77,33 @@ public void GetValid_StringObject() var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); var result = target[key]; - Assert.AreSame(result, value); + Assert.Same(result, value); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void GetNoKey_StringInt() { string key = "kk"; int value = 42; var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); - var result = target["aa"]; + Assert.Throws(() => + { + var result = target["aa"]; + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void GetNoKey_StringObject() { string key = "kk"; object value = new object(); var target = new DictionaryWrapper(new System.Collections.Hashtable()); target.Add(key, value); - var result = target["aa"]; + Assert.Throws(() => + { + var result = target["aa"]; + }); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/DisaposableOnceTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/DisaposableOnceTests.cs similarity index 74% rename from Sources/NET4.SrkToolkit.Common.Tests/DisaposableOnceTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/DisaposableOnceTests.cs index f9b5136..ba18ba8 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/DisaposableOnceTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/DisaposableOnceTests.cs @@ -5,13 +5,12 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Threading; + using Xunit; - [TestClass] public class DisaposableOnceTests { - [TestMethod] + [Fact] public void DelegateIsCalledOnceDispose() { // prepare @@ -22,10 +21,10 @@ public void DelegateIsCalledOnceDispose() target.Dispose(); // verify - Assert.AreEqual(1, disposed); + Assert.Equal(1, disposed); } - [TestMethod] + [Fact] public void GarbageCollectorDoesNotCallDelegate() { // prepare @@ -37,14 +36,14 @@ public void GarbageCollectorDoesNotCallDelegate() GC.WaitForPendingFinalizers(); // verify - Assert.IsFalse(target.IsAlive); - Assert.AreEqual(0, disposed); + Assert.False(target.IsAlive); + Assert.Equal(0, disposed); } /// /// Verify... /// - [TestMethod, ExpectedException(typeof(InvalidOperationException))] + [Fact] public void DisposeRethrowsOnDelegateInvocationException() { // prepare @@ -54,7 +53,10 @@ public void DisposeRethrowsOnDelegateInvocationException() }); // execute - target.Dispose(); + Assert.Throws(() => + { + target.Dispose(); + }); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EmailAddressAttributeTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/EmailAddressAttributeTests.cs similarity index 74% rename from Sources/NET4.SrkToolkit.Common.Tests/EmailAddressAttributeTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/EmailAddressAttributeTests.cs index 458fc6c..395635d 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/EmailAddressAttributeTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/EmailAddressAttributeTests.cs @@ -3,19 +3,19 @@ namespace SrkToolkit.Common.Tests { using System; using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + ////using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.DataAnnotations; - using System.ComponentModel.DataAnnotations; + using Xunit; + using EmailAddressAttribute = SrkToolkit.DataAnnotations.EmailAddressAttribute; - [TestClass] +#if NETFRAMEWORK public class EmailAddressAttributeTests { - [TestClass] public class SingleValidation { - [TestMethod] + [Fact] public void NullValue_IsValid() { string value = null, name = "Email"; @@ -24,10 +24,10 @@ public void NullValue_IsValid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void EmptyValue_IsValid() { string value = "", name = "Email"; @@ -36,10 +36,10 @@ public void EmptyValue_IsValid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void InvalidAddress_IsInvalid() { string value = "test", name = "Email"; @@ -48,13 +48,13 @@ public void InvalidAddress_IsInvalid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNotNull(result); - Assert.AreEqual("A valid email address is required.", result.ErrorMessage); - Assert.AreEqual(1, result.MemberNames.Count()); - Assert.AreEqual(name, result.MemberNames.Single()); + Assert.NotNull(result); + Assert.Equal("A valid email address is required.", result.ErrorMessage); + Assert.Equal(1, result.MemberNames.Count()); + Assert.Equal(name, result.MemberNames.Single()); } - [TestMethod] + [Fact] public void ValidAddress_IsValid() { string value = "test@test.com", name = "Email"; @@ -63,10 +63,10 @@ public void ValidAddress_IsValid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void ValidTagAddress_IsValid() { string value = "test+test@test.com", name = "Email"; @@ -75,10 +75,10 @@ public void ValidTagAddress_IsValid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void ValidParisAddress_IsValid() { string value = "test@test.paris", name = "Email"; @@ -87,14 +87,13 @@ public void ValidParisAddress_IsValid() context.MemberName = name; var result = attr.GetValidationResult(value, context); - Assert.IsNull(result); + Assert.Null(result); } } - [TestClass] public class MultiValidation { - [TestMethod] + [Fact] public void NullValue_IsValid() { string value = null; @@ -104,11 +103,11 @@ public void NullValue_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); - //Assert.AreEqual(result.ErrorMessage, "A valid email address is required."); + Assert.Null(result); + //Assert.Equal(result.ErrorMessage, "A valid email address is required."); } - [TestMethod] + [Fact] public void EmptyValue_IsValid() { string value = ""; @@ -118,11 +117,11 @@ public void EmptyValue_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); - //Assert.AreEqual(result.ErrorMessage, "A valid email address is required."); + Assert.Null(result); + //Assert.Equal(result.ErrorMessage, "A valid email address is required."); } - [TestMethod] + [Fact] public void InvalidAddress_IsValid() { string value = "test"; @@ -132,10 +131,10 @@ public void InvalidAddress_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void ValidAddress_IsValid() { string value = "test@test.com"; @@ -145,10 +144,10 @@ public void ValidAddress_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void MultiValidAddress_IsValid() { string value = "test@test.com test@test.com test@test.com cool"; @@ -158,10 +157,10 @@ public void MultiValidAddress_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void ValidTagAddress_IsValid() { string value = "test+test@test.com"; @@ -171,10 +170,10 @@ public void ValidTagAddress_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void InvalidAddressAndMin1_IsInvalid() { string value = "test"; @@ -185,11 +184,11 @@ public void InvalidAddressAndMin1_IsInvalid() }; var result = attr.GetIsValid(value, null); - Assert.IsNotNull(result); - Assert.IsTrue(result.ErrorMessage.Contains("minimum of")); + Assert.NotNull(result); + Assert.True(result.ErrorMessage.Contains("minimum of")); } - [TestMethod] + [Fact] public void MultiValidAddressAndMax1_IsValid() { string value = "test@test.com test@test.com test@test.com cool"; @@ -200,9 +199,10 @@ public void MultiValidAddressAndMax1_IsValid() }; var result = attr.GetIsValid(value, null); - Assert.IsNotNull(result); - Assert.IsTrue(result.ErrorMessage.Contains("maximum of")); + Assert.NotNull(result); + Assert.True(result.ErrorMessage.Contains("maximum of")); } } } + #endif } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EmailAddressTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/EmailAddressTests.cs similarity index 68% rename from Sources/NET4.SrkToolkit.Common.Tests/EmailAddressTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/EmailAddressTests.cs index b1306ca..ae4cef0 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/EmailAddressTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/EmailAddressTests.cs @@ -1,31 +1,36 @@  namespace SrkToolkit.Common.Tests { + using SrkToolkit.Common.Validation; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Common.Validation; + using Xunit; public class EmailAddressTests { - [TestClass] public class Constructor1 { - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void NullAddress() { - var email = new EmailAddress(null); + Assert.Throws(() => + { + var email = new EmailAddress(null); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyAddress() { - var email = new EmailAddress(" "); + Assert.Throws(() => + { + var email = new EmailAddress(" "); + }); } - [TestMethod] + [Fact] public void SplitsEmailInParts_NoTag() { // prepare @@ -39,14 +44,14 @@ public void SplitsEmailInParts_NoTag() var email = new EmailAddress(address); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_WithTag() { // prepare @@ -60,14 +65,14 @@ public void SplitsEmailInParts_WithTag() var email = new EmailAddress(address); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_MultiTag() { // prepare @@ -81,14 +86,14 @@ public void SplitsEmailInParts_MultiTag() var email = new EmailAddress(address); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_EmptyTag() { // prepare @@ -102,18 +107,17 @@ public void SplitsEmailInParts_EmptyTag() var email = new EmailAddress(address); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } } - [TestClass] public class Constructor2 { - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void NullAccountPart() { // prepare @@ -124,10 +128,13 @@ public void NullAccountPart() string address = local + "@" + domain; // execute - var email = new EmailAddress(address); + Assert.Throws(() => + { + var email = new EmailAddress(address); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyAccountPart() { // prepare @@ -138,10 +145,13 @@ public void EmptyAccountPart() string address = local + "@" + domain; // execute - var email = new EmailAddress(address); + Assert.Throws(() => + { + var email = new EmailAddress(address); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void NullDomainPart() { // prepare @@ -152,10 +162,13 @@ public void NullDomainPart() string address = local + "@" + domain; // execute - var email = new EmailAddress(address); + Assert.Throws(() => + { + var email = new EmailAddress(address); + }); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void EmptyDomainPart() { // prepare @@ -166,10 +179,13 @@ public void EmptyDomainPart() string address = local + "@" + domain; // execute - var email = new EmailAddress(address); + Assert.Throws(() => + { + var email = new EmailAddress(address); + }); } - [TestMethod] + [Fact] public void SplitsEmailInParts_NoTag() { // prepare @@ -183,14 +199,14 @@ public void SplitsEmailInParts_NoTag() var email = new EmailAddress(user, tag, domain); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_WithTag() { // prepare @@ -204,14 +220,14 @@ public void SplitsEmailInParts_WithTag() var email = new EmailAddress(user, tag, domain); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_MultiTag() { // prepare @@ -225,14 +241,14 @@ public void SplitsEmailInParts_MultiTag() var email = new EmailAddress(user, tag, domain); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(tag, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(tag, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_EmptyTag() { // prepare @@ -246,14 +262,14 @@ public void SplitsEmailInParts_EmptyTag() var email = new EmailAddress(user, tag, domain); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(null, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(null, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } - [TestMethod] + [Fact] public void SplitsEmailInParts_EmptyTag_SingleQuote() { // prepare @@ -267,18 +283,17 @@ public void SplitsEmailInParts_EmptyTag_SingleQuote() var email = new EmailAddress(user, tag, domain); // verify - Assert.AreEqual(local, email.LocalPart); - Assert.AreEqual(user, email.AccountPart); - Assert.AreEqual(null, email.TagPart); - Assert.AreEqual(domain, email.DomainPart); - Assert.AreEqual(address, email.Value); + Assert.Equal(local, email.LocalPart); + Assert.Equal(user, email.AccountPart); + Assert.Equal(null, email.TagPart); + Assert.Equal(domain, email.DomainPart); + Assert.Equal(address, email.Value); } } - [TestClass] public class ValueWithoutTagGetter { - [TestMethod] + [Fact] public void WorksWithNoTag() { // prepare @@ -289,10 +304,10 @@ public void WorksWithNoTag() var email = new EmailAddress(input); // verify - Assert.AreEqual(expected, email.ValueWithoutTag); + Assert.Equal(expected, email.ValueWithoutTag); } - [TestMethod] + [Fact] public void WorksWithOneTag() { // prepare @@ -303,167 +318,163 @@ public void WorksWithOneTag() var email = new EmailAddress(input); // verify - Assert.AreEqual(expected, email.ValueWithoutTag); + Assert.Equal(expected, email.ValueWithoutTag); } } - [TestClass] public class ObjectEqualsMethod { - [TestMethod] + [Fact] public void ObjectEqual_AgainstNull() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = null; var result = value1.Equals((object)value2); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstSameReference() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = value1; var result = value1.Equals((object)value2); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstSameValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("test@est.com"); var result = value1.Equals((object)value2); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstDifferentValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("lalala@test.com"); var result = value1.Equals((object)value2); - Assert.IsFalse(result); + Assert.False(result); } } - [TestClass] public class EmailAddressEqualsMethod { - [TestMethod] + [Fact] public void ObjectEqual_AgainstNull() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = null; var result = value1.Equals(value2); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstSameReference() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = value1; var result = value1.Equals(value2); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstSameValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("test@est.com"); var result = value1.Equals(value2); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void ObjectEqual_AgainstDifferentValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("lalala@test.com"); var result = value1.Equals(value2); - Assert.IsFalse(result); + Assert.False(result); } } - [TestClass] public class OperatorEqualsMethod { - [TestMethod] + [Fact] public void EqualityOperator_AgainstNull() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = null; var result = value1 == value2; - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void EqualityOperator_AgainstSameReference() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = value1; var result = value1 == value2; - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void EqualityOperator_AgainstSameValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("test@est.com"); var result = value1 == value2; - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void EqualityOperator_AgainstDifferentValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("lalala@test.com"); var result = value1 == value2; - Assert.IsFalse(result); + Assert.False(result); } } - [TestClass] public class OperatorInEqualsMethod { - [TestMethod] + [Fact] public void InequalityOperator_AgainstNull() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = null; var result = value1 != value2; - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void InequalityOperator_AgainstSameReference() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = value1; var result = value1 != value2; - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void InequalityOperator_AgainstSameValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("test@est.com"); var result = value1 != value2; - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void InequalityOperator_AgainstDifferentValue() { EmailAddress value1 = new EmailAddress("test@est.com"); EmailAddress value2 = new EmailAddress("lalala@test.com"); var result = value1 != value2; - Assert.IsTrue(result); + Assert.True(result); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.Designer.cs b/Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.Designer.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.Designer.cs rename to Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.Designer.cs index 5f09375..330fb3a 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.Designer.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -39,7 +38,7 @@ public class EnumStrings { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Common.Tests.EnumStrings", typeof(EnumStrings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Common.CoreUnitTests.EnumStrings", typeof(EnumStrings).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.fr.resx b/Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.fr.resx similarity index 100% rename from Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.fr.resx rename to Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.fr.resx diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.resx b/Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.resx similarity index 100% rename from Sources/NET4.SrkToolkit.Common.Tests/EnumStrings.resx rename to Sources/SrkToolkit.Common.FxUnitTests/EnumStrings.resx diff --git a/Sources/NET4.SrkToolkit.Common.Tests/EnumToolsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/EnumToolsTests.cs similarity index 78% rename from Sources/NET4.SrkToolkit.Common.Tests/EnumToolsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/EnumToolsTests.cs index 3b8b23a..ada6c13 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/EnumToolsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/EnumToolsTests.cs @@ -5,20 +5,18 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Threading; using System.Globalization; + using Xunit; - [TestClass] public class EnumToolsTests { private static CultureInfo defaultCulture = new CultureInfo("en-US"); private static CultureInfo frenchCulture = new CultureInfo("fr-FR"); - [TestClass] public class GetDescription { - [TestMethod] + [Fact] public void HasDescription_ThreadCulture_AssembliesCulture() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -30,10 +28,10 @@ public void HasDescription_ThreadCulture_AssembliesCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager); // verify - Assert.AreEqual("Description of SuperEnum.Two", desc); + Assert.Equal("Description of SuperEnum.Two", desc); } - [TestMethod] + [Fact] public void NoDescription_ThreadCulture_AssembliesCulture() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -45,10 +43,10 @@ public void NoDescription_ThreadCulture_AssembliesCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager); // verify - Assert.AreEqual("Three", desc); + Assert.Equal("Three", desc); } - [TestMethod] + [Fact] public void HasDescription_SpecifiedCulture_AssembliesCulture() { Thread.CurrentThread.CurrentUICulture = frenchCulture; @@ -60,10 +58,10 @@ public void HasDescription_SpecifiedCulture_AssembliesCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, defaultCulture); // verify - Assert.AreEqual("Description of SuperEnum.Two", desc); + Assert.Equal("Description of SuperEnum.Two", desc); } - [TestMethod] + [Fact] public void NoDescription_SpecifiedCulture_AssembliesCulture() { Thread.CurrentThread.CurrentUICulture = frenchCulture; @@ -75,10 +73,10 @@ public void NoDescription_SpecifiedCulture_AssembliesCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, defaultCulture); // verify - Assert.AreEqual("Three", desc); + Assert.Equal("Three", desc); } - [TestMethod] + [Fact] public void HasDescription_ThreadCulture_FrenchCulture() { Thread.CurrentThread.CurrentUICulture = frenchCulture; @@ -90,10 +88,10 @@ public void HasDescription_ThreadCulture_FrenchCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager); // verify - Assert.AreEqual("Description de SuperEnum.Two", desc); + Assert.Equal("Description de SuperEnum.Two", desc); } - [TestMethod] + [Fact] public void NoDescription_ThreadCulture_FrenchCulture() { Thread.CurrentThread.CurrentUICulture = frenchCulture; @@ -105,10 +103,10 @@ public void NoDescription_ThreadCulture_FrenchCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager); // verify - Assert.AreEqual("Three", desc); + Assert.Equal("Three", desc); } - [TestMethod] + [Fact] public void HasDescription_SpecifiedCulture_FrenchCulture() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -120,10 +118,10 @@ public void HasDescription_SpecifiedCulture_FrenchCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, frenchCulture); // verify - Assert.AreEqual("Description de SuperEnum.Two", desc); + Assert.Equal("Description de SuperEnum.Two", desc); } - [TestMethod] + [Fact] public void NoDescription_SpecifiedCulture_FrenchCulture() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -135,10 +133,10 @@ public void NoDescription_SpecifiedCulture_FrenchCulture() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, frenchCulture); // verify - Assert.AreEqual("Three", desc); + Assert.Equal("Three", desc); } - [TestMethod] + [Fact] public void HasDescription_ThreadCulture_AssembliesCulture_Suffix() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -150,10 +148,10 @@ public void HasDescription_ThreadCulture_AssembliesCulture_Suffix() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, null, "_Desc"); // verify - Assert.AreEqual("Super long description of the SuperEnum.Two enum value. lalalalala allalalal alallalalal alal allaall allalallalala.", desc); + Assert.Equal("Super long description of the SuperEnum.Two enum value. lalalalala allalalal alallalalal alal allaall allalallalala.", desc); } - [TestMethod] + [Fact] public void HasDescription_ThreadCulture_AssembliesCulture_Prefix() { Thread.CurrentThread.CurrentUICulture = defaultCulture; @@ -165,7 +163,7 @@ public void HasDescription_ThreadCulture_AssembliesCulture_Prefix() var desc = EnumTools.GetDescription(value, EnumStrings.ResourceManager, "Def_", null); // verify - Assert.AreEqual("Description of SuperEnum.Two blah", desc); + Assert.Equal("Description of SuperEnum.Two blah", desc); } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/ObservableCollectionExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/ObservableCollectionExtensionsTests.cs similarity index 66% rename from Sources/NET4.SrkToolkit.Common.Tests/ObservableCollectionExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/ObservableCollectionExtensionsTests.cs index 1feaf12..651d98b 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/ObservableCollectionExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/ObservableCollectionExtensionsTests.cs @@ -8,29 +8,34 @@ namespace SrkToolkit.Common.Tests { using System; using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.ObjectModel; + using Xunit; public class ObservableCollectionExtensionsTests { - [TestClass] public class AddRangeMethod { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsWhenArg0IsNull() { - SrkObservableCollectionExtensions.AddRange(null, new string[0]); + Assert.Throws(() => + { + SrkObservableCollectionExtensions.AddRange(null, new string[0]); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsWhenArg1IsNull() { - SrkObservableCollectionExtensions.AddRange(new ObservableCollection(), null); + Assert.Throws(() => + { + SrkObservableCollectionExtensions.AddRange(new ObservableCollection(), null); + }); } - [TestMethod] + [Fact] public void CorrectlyAddsElements() { var target = new ObservableCollection(); @@ -38,10 +43,10 @@ public void CorrectlyAddsElements() SrkObservableCollectionExtensions.AddRange(target, elements); - Assert.AreEqual(2, target.Count); + Assert.Equal(2, target.Count); } - [TestMethod] + [Fact] public void ReturnsSelf() { var target = new ObservableCollection(); @@ -49,26 +54,31 @@ public void ReturnsSelf() var result = SrkObservableCollectionExtensions.AddRange(target, elements); - Assert.AreEqual(target, result); + Assert.Equal(target, result); } } - [TestClass] public class RemoveAllMethod { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsWhenArg0IsNull() { - SrkObservableCollectionExtensions.RemoveAll(null, s => true); + Assert.Throws(() => + { + SrkObservableCollectionExtensions.RemoveAll(null, s => true); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsWhenArg1IsNull() { - SrkObservableCollectionExtensions.RemoveAll(new ObservableCollection(), null); + Assert.Throws(() => + { + SrkObservableCollectionExtensions.RemoveAll(new ObservableCollection(), null); + }); } - [TestMethod] + [Fact] public void RemovesElements() { var elements = new string[] { "a", "b", "c", }; @@ -77,10 +87,10 @@ public void RemovesElements() SrkObservableCollectionExtensions.RemoveAll(target, predicate); - Assert.AreEqual(2, target.Count); + Assert.Equal(2, target.Count); } - [TestMethod] + [Fact] public void RemovesSameElements() { var elements = new string[] { "a", "b", "b", "c", }; @@ -89,10 +99,10 @@ public void RemovesSameElements() SrkObservableCollectionExtensions.RemoveAll(target, predicate); - Assert.AreEqual(2, target.Count); + Assert.Equal(2, target.Count); } - [TestMethod] + [Fact] public void ReturnsSelf() { var elements = new string[] { "a", "b", "c", }; @@ -101,7 +111,7 @@ public void ReturnsSelf() var result = SrkObservableCollectionExtensions.RemoveAll(target, predicate); - Assert.AreEqual(target, result); + Assert.Equal(target, result); } } } diff --git a/Sources/SrkToolkit.Common.FxUnitTests/Properties/AssemblyInfo.cs b/Sources/SrkToolkit.Common.FxUnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..823a4a2 --- /dev/null +++ b/Sources/SrkToolkit.Common.FxUnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// 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("SrkToolkit.Common.FxUnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SrkToolkit.Common.FxUnitTests")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("00457CE3-FE08-4AF2-972E-4C2EDD36F38D")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Sources/NET4.SrkToolkit.Common.Tests/RetryLogicTests.NET4.cs b/Sources/SrkToolkit.Common.FxUnitTests/RetryLogicTests.NET4.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common.Tests/RetryLogicTests.NET4.cs rename to Sources/SrkToolkit.Common.FxUnitTests/RetryLogicTests.NET4.cs index b0f3625..ddcd468 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/RetryLogicTests.NET4.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/RetryLogicTests.NET4.cs @@ -16,17 +16,16 @@ namespace SrkToolkit.Common.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using Should; using System; using System.Diagnostics; using System.IO; using System.Threading.Tasks; + using Xunit; - [TestClass] public partial class RetryLogicTests { - [TestMethod] + [Fact] public void Action_Should_Be_Tried_3Times_With_ProgressiveInterval() { var exceptionCount = 0; @@ -56,7 +55,7 @@ public void Action_Should_Be_Tried_3Times_With_ProgressiveInterval() successCount.ShouldEqual(0); } - [TestMethod] + [Fact] public void Function_Should_Be_Tried_3Times_With_ExponentialInterval() { var exceptionCount = 0; @@ -86,7 +85,7 @@ public void Function_Should_Be_Tried_3Times_With_ExponentialInterval() successCount.ShouldEqual(0); } - [TestMethod] + [Fact] public void Function_Should_Be_A_Success() { var exceptionCount = 0; @@ -115,7 +114,7 @@ public void Function_Should_Be_A_Success() successCount.ShouldEqual(1); } - [TestMethod] + [Fact] public void Action_Should_Be_A_Success() { var exceptionCount = 0; diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkArrayExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkArrayExtensionsTests.cs similarity index 51% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkArrayExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkArrayExtensionsTests.cs index 7242a3e..ce90c15 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkArrayExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkArrayExtensionsTests.cs @@ -1,156 +1,162 @@  namespace SrkToolkit.Common.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Text; + using Xunit; - [TestClass] public class SrkArrayExtensionsTests { - [TestClass] public class CombineWithMethod_CombineArray { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsArg0Null() { - SrkArrayExtensions.CombineWith(default(string[]), new string[0]); + Assert.Throws(() => + { + SrkArrayExtensions.CombineWith(default(string[]), new string[0]); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsArg1Null() { - SrkArrayExtensions.CombineWith(new string[0], default(string[])); + Assert.Throws(() => + { + SrkArrayExtensions.CombineWith(new string[0], default(string[])); + }); } - [TestMethod] + [Fact] public void Works1() { var source = new int[] { 1, 2, }; var items = new int[] { 3, 4, }; var result = SrkArrayExtensions.CombineWith(source, items); - Assert.AreEqual(4, result.Length); - Assert.AreEqual(1, result[0]); - Assert.AreEqual(2, result[1]); - Assert.AreEqual(3, result[2]); - Assert.AreEqual(4, result[3]); + Assert.Equal(4, result.Length); + Assert.Equal(1, result[0]); + Assert.Equal(2, result[1]); + Assert.Equal(3, result[2]); + Assert.Equal(4, result[3]); } - [TestMethod] + [Fact] public void Works2() { var source = new int[] { 1, 2, }; var items1 = new int[] { 3, 4, }; var items2 = new int[] { 5, 6, }; var result = SrkArrayExtensions.CombineWith(source, items1, items2); - Assert.AreEqual(6, result.Length); - Assert.AreEqual(1, result[0]); - Assert.AreEqual(2, result[1]); - Assert.AreEqual(3, result[2]); - Assert.AreEqual(4, result[3]); - Assert.AreEqual(5, result[4]); - Assert.AreEqual(6, result[5]); + Assert.Equal(6, result.Length); + Assert.Equal(1, result[0]); + Assert.Equal(2, result[1]); + Assert.Equal(3, result[2]); + Assert.Equal(4, result[3]); + Assert.Equal(5, result[4]); + Assert.Equal(6, result[5]); } - [TestMethod] + [Fact] public void EmptyArg0() { var source = new int[] { }; var items = new int[] { 3, 4, }; var result = SrkArrayExtensions.CombineWith(source, items); - Assert.AreEqual(2, result.Length); - Assert.AreEqual(3, result[0]); - Assert.AreEqual(4, result[1]); + Assert.Equal(2, result.Length); + Assert.Equal(3, result[0]); + Assert.Equal(4, result[1]); } - [TestMethod] + [Fact] public void EmptyArg1() { var source = new int[] { 1, 2, }; var items = new int[] { }; var result = SrkArrayExtensions.CombineWith(source, items); - Assert.AreEqual(2, result.Length); - Assert.AreEqual(1, result[0]); - Assert.AreEqual(2, result[1]); + Assert.Equal(2, result.Length); + Assert.Equal(1, result[0]); + Assert.Equal(2, result[1]); } - [TestMethod] + [Fact] public void EmptyArgs() { var source = new int[] { }; var items = new int[] { }; var result = SrkArrayExtensions.CombineWith(source, items); - Assert.AreEqual(0, result.Length); + Assert.Equal(0, result.Length); } } - [TestClass] public class CombineWithMethod_CombineItem { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsArg0Null() { - SrkArrayExtensions.CombineWith(default(string[]), string.Empty); + Assert.Throws(() => + { + SrkArrayExtensions.CombineWith(default(string[]), string.Empty); + }); } - [TestMethod] + [Fact] public void Works1() { var source = new int[] { 1, 2, }; var item = 3; var result = SrkArrayExtensions.CombineWith(source, item); - Assert.AreEqual(3, result.Length); - Assert.AreEqual(1, result[0]); - Assert.AreEqual(2, result[1]); - Assert.AreEqual(3, result[2]); + Assert.Equal(3, result.Length); + Assert.Equal(1, result[0]); + Assert.Equal(2, result[1]); + Assert.Equal(3, result[2]); } - [TestMethod] + [Fact] public void Works2() { var source = new int[] { 1, 2, }; var item1 = 3; var item2 = 4; var result = SrkArrayExtensions.CombineWith(source, item1, item2); - Assert.AreEqual(4, result.Length); - Assert.AreEqual(1, result[0]); - Assert.AreEqual(2, result[1]); - Assert.AreEqual(3, result[2]); - Assert.AreEqual(4, result[3]); + Assert.Equal(4, result.Length); + Assert.Equal(1, result[0]); + Assert.Equal(2, result[1]); + Assert.Equal(3, result[2]); + Assert.Equal(4, result[3]); } - [TestMethod] + [Fact] public void EmptyArg0() { var source = new int[] { }; var item = 3; var result = SrkArrayExtensions.CombineWith(source, item); - Assert.AreEqual(1, result.Length); - Assert.AreEqual(3, result[0]); + Assert.Equal(1, result.Length); + Assert.Equal(3, result[0]); } - [TestMethod] + [Fact] public void EmptyArg1() { var source = new string[] { "1", "2", }; string item = null; var result = SrkArrayExtensions.CombineWith(source, item); - Assert.AreEqual(3, result.Length); - Assert.AreEqual("1", result[0]); - Assert.AreEqual("2", result[1]); - Assert.AreEqual(item, result[2]); + Assert.Equal(3, result.Length); + Assert.Equal("1", result[0]); + Assert.Equal("2", result[1]); + Assert.Equal(item, result[2]); } - [TestMethod] + [Fact] public void EmptyArgs() { var source = new string[] { }; var item = default(string); var result = SrkArrayExtensions.CombineWith(source, item); - Assert.AreEqual(1, result.Length); - Assert.AreEqual(item, result[0]); + Assert.Equal(1, result.Length); + Assert.Equal(item, result[0]); } } } diff --git a/Sources/SrkToolkit.Common.FxUnitTests/SrkDateTimeExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkDateTimeExtensionsTests.cs new file mode 100644 index 0000000..2f535f6 --- /dev/null +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkDateTimeExtensionsTests.cs @@ -0,0 +1,356 @@ +// ----------------------------------------------------------------------- +// +// TODO: Update copyright text. +// +// ----------------------------------------------------------------------- + +namespace SrkToolkit.Common.Tests +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using Xunit; + + public class SrkDateTimeExtensionsTests + { + public class GetDateMethod + { + [Fact] + public void WorksForNow() + { + var date = DateTime.Now; + + var result = date.GetDate(); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void WorksForUtcNow() + { + var date = DateTime.UtcNow; + + var result = date.GetDate(); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void Works1() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 111, DateTimeKind.Unspecified); + + var result = date.GetDate(); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + } + + public class ToPrecisionMethod + { + [Fact] + public void ToMillisecond() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Millisecond); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToSecond() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Second); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToMinute() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Minute); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToHour() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Hour); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToDay() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Day); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToMonth() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Month); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(1, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + + [Fact] + public void ToYear() + { + var date = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date.ToPrecision(DateTimePrecision.Year); + + Assert.Equal(date.Year, result.Year); + Assert.Equal(1, result.Month); + Assert.Equal(1, result.Day); + Assert.Equal(0, result.Hour); + Assert.Equal(0, result.Minute); + Assert.Equal(0, result.Second); + Assert.Equal(0, result.Millisecond); + Assert.Equal(date.Kind, result.Kind); + } + } + + public class IsEqualToMethod + { + [Fact] + public void CompareMillisecondDifference() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 2, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Millisecond); + Assert.False(result); + } + + [Fact] + public void CompareMillisecondEquality() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Millisecond); + Assert.True(result); + } + + [Fact] + public void CompareSecondDifference() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Second); + Assert.False(result); + } + + [Fact] + public void CompareSecondDifference_MsDifferent() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 2, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Second); + Assert.False(result); + } + + [Fact] + public void CompareSecondEquality() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Second); + Assert.True(result); + } + + [Fact] + public void CompareSecondEquality_MsDifferent() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 2, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Second); + Assert.True(result); + } + + [Fact] + public void CompareMinuteDifference() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 4, 2, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); + Assert.False(result); + } + + [Fact] + public void CompareMinuteDifference_SecondDifferent() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 4, 3, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); + Assert.False(result); + } + + [Fact] + public void CompareMinuteEquality() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); + Assert.True(result); + } + + [Fact] + public void CompareMinuteEquality_SecondDifferent() + { + var date1 = new DateTime(1987, 6, 5, 4, 3, 2, 1, DateTimeKind.Utc); + var date2 = new DateTime(1987, 6, 5, 4, 3, 3, 2, DateTimeKind.Utc); + var result = date1.IsEqualTo(date2, DateTimePrecision.Minute); + Assert.True(result); + } + } + + public class AsLocalMethod + { + [Fact] + public void SameValues() + { + // prepare + var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Unspecified); + var result = SrkDateTimeExtensions.AsLocal(date); + + // verify + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(date.Ticks, result.Ticks); + Assert.Equal(DateTimeKind.Local, result.Kind); + } + } + + public class AsUtcMethod + { + [Fact] + public void SameValues() + { + // prepare + var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Unspecified); + var result = SrkDateTimeExtensions.AsUtc(date); + + // verify + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(date.Ticks, result.Ticks); + Assert.Equal(DateTimeKind.Utc, result.Kind); + } + } + + public class AsUnspecifiedMethod + { + [Fact] + public void SameValues() + { + // prepare + var date = new DateTime(1234, 5, 6, 7, 8, 9, 123, DateTimeKind.Local); + var result = SrkDateTimeExtensions.AsUnspecified(date); + + // verify + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(date.Ticks, result.Ticks); + Assert.Equal(DateTimeKind.Unspecified, result.Kind); + } + } + + public class ToUnixTimeMethod + { + [Fact] + public void UtcTime() + { + DateTime time = new DateTime(2013, 1, 29, 13, 28, 21, 1, DateTimeKind.Utc); + long result = time.ToUnixTime(); + Assert.Equal(1359466101, result); + } + } + } +} diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkIDictionaryExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkIDictionaryExtensionsTests.cs similarity index 67% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkIDictionaryExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkIDictionaryExtensionsTests.cs index 041d89a..d01a392 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkIDictionaryExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkIDictionaryExtensionsTests.cs @@ -6,7 +6,6 @@ namespace SrkToolkit.Common.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections; using System.Collections.Generic; @@ -14,13 +13,13 @@ namespace SrkToolkit.Common.Tests using System.Text; using CSrkIDictionaryExtensions = System.Collections.SrkIDictionaryExtensions; using GSrkIDictionaryExtensions = System.Collections.Generic.SrkIDictionaryExtensions; + using Xunit; public class SrkIDictionaryExtensionsTests { - [TestClass] public class GetValueMethod { - [TestMethod] + [Fact] public void NonGeneric_ReturnsStoredValue() { var value = new object(); @@ -28,20 +27,20 @@ public void NonGeneric_ReturnsStoredValue() IDictionary dictionary = new Dictionary(); dictionary.Add(key, value); var result = CSrkIDictionaryExtensions.GetValue(dictionary, key, () => null, true); - Assert.IsTrue(object.ReferenceEquals(result, value)); + Assert.True(object.ReferenceEquals(result, value)); } - [TestMethod] + [Fact] public void NonGeneric_GeneratesValue() { var value = new object(); var key = "key"; IDictionary dictionary = new Dictionary(); var result = CSrkIDictionaryExtensions.GetValue(dictionary, key, () => value, true); - Assert.IsTrue(object.ReferenceEquals(result, value)); + Assert.True(object.ReferenceEquals(result, value)); } - [TestMethod] + [Fact] public void NonGeneric_GeneratedValueIsStored() { var value = new object(); @@ -49,11 +48,11 @@ public void NonGeneric_GeneratedValueIsStored() IDictionary dictionary = new Dictionary(); var result1 = CSrkIDictionaryExtensions.GetValue(dictionary, key, () => value, true); var result2 = CSrkIDictionaryExtensions.GetValue(dictionary, key, () => null, true); - Assert.IsTrue(object.ReferenceEquals(result1, value)); - Assert.IsTrue(object.ReferenceEquals(result2, value)); + Assert.True(object.ReferenceEquals(result1, value)); + Assert.True(object.ReferenceEquals(result2, value)); } - [TestMethod] + [Fact] public void Generic_ReturnsStoredValue() { var value = new object(); @@ -61,19 +60,19 @@ public void Generic_ReturnsStoredValue() IDictionary dictionary = new Dictionary(); dictionary.Add(key, value); var result = GSrkIDictionaryExtensions.GetValue(dictionary, key); - Assert.AreSame(value, result); + Assert.Same(value, result); } - [TestMethod] + [Fact] public void Generic_KeyNotFound_ReturnsNull() { var key = "key"; IDictionary dictionary = new Dictionary(); var result = GSrkIDictionaryExtensions.GetValue(dictionary, key); - Assert.IsNull(result); + Assert.Null(result); } - [TestMethod] + [Fact] public void Generic_NullValue() { object value = null; @@ -81,46 +80,57 @@ public void Generic_NullValue() IDictionary dictionary = new Dictionary(); dictionary.Add(key, value); var result = GSrkIDictionaryExtensions.GetValue(dictionary, key); - Assert.IsNull(result); + Assert.Null(result); } } - [TestClass] public class AddRangeMethod { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfNullArg0() { List source = new List(); Dictionary target = null; - GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s.Name); + Assert.Throws(() => + { + GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s.Name); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfNullArg1() { List source = null; var target = new Dictionary(); - GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s.Name); + Assert.Throws(() => + { + GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s.Name); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfNullArg2() { List source = new List(); var target = new Dictionary(); - GSrkIDictionaryExtensions.AddRange(target, source, null, s => s.Name); + Assert.Throws(() => + { + GSrkIDictionaryExtensions.AddRange(target, source, null, s => s.Name); + }); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfNullArg3() { List source = new List(); var target = new Dictionary(); - GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, null); + Assert.Throws(() => + { + GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, null); + }); } - [TestMethod] + [Fact] public void Works() { var source = new List() @@ -132,16 +142,16 @@ public void Works() var target = new Dictionary(); GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s); - Assert.AreEqual(3, target.Count); - Assert.IsTrue(target.ContainsKey(1)); - Assert.IsTrue(target.ContainsKey(2)); - Assert.IsTrue(target.ContainsKey(3)); - Assert.AreSame(source[0], target[1]); - Assert.AreSame(source[1], target[2]); - Assert.AreSame(source[2], target[3]); + Assert.Equal(3, target.Count); + Assert.True(target.ContainsKey(1)); + Assert.True(target.ContainsKey(2)); + Assert.True(target.ContainsKey(3)); + Assert.Same(source[0], target[1]); + Assert.Same(source[1], target[2]); + Assert.Same(source[2], target[3]); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [Fact] public void KeyAlreadyExists() { var source = new List() @@ -152,14 +162,16 @@ public void KeyAlreadyExists() }; var target = new Dictionary(); target.Add(1, new TestModel() { Id = 1, }); - GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s); + Assert.Throws(() => + { + GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s); + }); } } - [TestClass] public class MergeMethod { - [TestMethod] + [Fact] public void NoConflict() { var target = new Dictionary(); @@ -172,16 +184,16 @@ public void NoConflict() }; target.Merge(source, m => m.Id, m => m, null); - Assert.AreEqual(3, target.Count); - Assert.IsTrue(target.ContainsKey(1)); - Assert.IsTrue(target.ContainsKey(2)); - Assert.IsTrue(target.ContainsKey(3)); - Assert.AreSame(first, target[1]); - Assert.AreSame(source[0], target[2]); - Assert.AreSame(source[1], target[3]); + Assert.Equal(3, target.Count); + Assert.True(target.ContainsKey(1)); + Assert.True(target.ContainsKey(2)); + Assert.True(target.ContainsKey(3)); + Assert.Same(first, target[1]); + Assert.Same(source[0], target[2]); + Assert.Same(source[1], target[3]); } - [TestMethod] + [Fact] public void EqualConflict() { var target = new Dictionary(); @@ -195,16 +207,16 @@ public void EqualConflict() }; target.Merge(source, m => m.Id, m => m, null); - Assert.AreEqual(3, target.Count); - Assert.IsTrue(target.ContainsKey(1)); - Assert.IsTrue(target.ContainsKey(2)); - Assert.IsTrue(target.ContainsKey(3)); - Assert.AreSame(first, target[1]); - Assert.AreSame(source[1], target[2]); - Assert.AreSame(source[2], target[3]); + Assert.Equal(3, target.Count); + Assert.True(target.ContainsKey(1)); + Assert.True(target.ContainsKey(2)); + Assert.True(target.ContainsKey(3)); + Assert.Same(first, target[1]); + Assert.Same(source[1], target[2]); + Assert.Same(source[2], target[3]); } - [TestMethod, ExpectedException(typeof(InvalidOperationException))] + [Fact] public void RealConflictWithNoResolverThrows() { var target = new Dictionary(); @@ -216,10 +228,13 @@ public void RealConflictWithNoResolverThrows() new TestModel(2), new TestModel(3), }; - target.Merge(source, m => m.Id, m => m, null); + Assert.Throws(() => + { + target.Merge(source, m => m.Id, m => m, null); + }); } - [TestMethod] + [Fact] public void WithConflictResolver() { var target = new Dictionary(); @@ -240,13 +255,13 @@ public void WithConflictResolver() return newValue; }); - Assert.AreEqual(3, target.Count); - Assert.IsTrue(target.ContainsKey(1)); - Assert.IsTrue(target.ContainsKey(2)); - Assert.IsTrue(target.ContainsKey(3)); - Assert.AreSame(source[0], target[1]); - Assert.AreSame(source[1], target[2]); - Assert.AreSame(source[2], target[3]); + Assert.Equal(3, target.Count); + Assert.True(target.ContainsKey(1)); + Assert.True(target.ContainsKey(2)); + Assert.True(target.ContainsKey(3)); + Assert.Same(source[0], target[1]); + Assert.Same(source[1], target[2]); + Assert.Same(source[2], target[3]); } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkIListExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkIListExtensionsTests.cs similarity index 64% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkIListExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkIListExtensionsTests.cs index befaacc..9a1f6db 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkIListExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkIListExtensionsTests.cs @@ -5,47 +5,45 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; - [TestClass] public class SrkIListExtensionsTests { - [TestClass] public class SingleOrCreateMethod { - [TestMethod] + [Fact] public void NoMatchShouldCreateStruct() { string value = "hello"; var list = new List(); var result = list.SingleOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void NoMatchShouldCreateClass() { string value = "hello"; var list = new List(); var result = list.SingleOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateStruct() { string value = "hello"; var list = new List(); list.Add(value); var result = list.SingleOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateClass() { string value = "hello"; @@ -53,23 +51,26 @@ public void OneMatchShouldCreateClass() var item = new Yo { Key = value, }; list.Add(item); var result = list.SingleOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreSame(item, result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Same(item, result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod, ExpectedException(typeof(InvalidOperationException))] + [Fact] public void MultiMatchShouldCreateStruct() { string value = "hello"; var list = new List(); list.Add(value); list.Add(value); - var result = list.SingleOrCreate(x => x == value, () => value); + Assert.Throws(() => + { + var result = list.SingleOrCreate(x => x == value, () => value); + }); } - [TestMethod, ExpectedException(typeof(InvalidOperationException))] + [Fact] public void MultiMatchShouldCreateClass() { string value = "hello"; @@ -77,46 +78,48 @@ public void MultiMatchShouldCreateClass() var item = new Yo { Key = value, }; list.Add(item); list.Add(item); - var result = list.SingleOrCreate(x => x.Key == value, () => new Yo { Key = value, }); + Assert.Throws(() => + { + var result = list.SingleOrCreate(x => x.Key == value, () => new Yo { Key = value, }); + }); } } - [TestClass] public class FirstOrCreateMethod { - [TestMethod] + [Fact] public void NoMatchShouldCreateStruct() { string value = "hello"; var list = new List(); var result = list.FirstOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void NoMatchShouldCreateClass() { string value = "hello"; var list = new List(); var result = list.FirstOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateStruct() { string value = "hello"; var list = new List(); list.Add(value); var result = list.FirstOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateClass() { string value = "hello"; @@ -124,13 +127,13 @@ public void OneMatchShouldCreateClass() var item = new Yo { Key = value, }; list.Add(item); var result = list.FirstOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreSame(item, result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Same(item, result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void MultiMatchShouldReturnFirstStruct() { string value = "hello"; @@ -138,11 +141,11 @@ public void MultiMatchShouldReturnFirstStruct() list.Add(value); list.Add(value); var result = list.FirstOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(2, list.Count); + Assert.Equal(value, result); + Assert.Equal(2, list.Count); } - [TestMethod] + [Fact] public void MultiMatchShouldReturnFirstClass() { string value = "hello"; @@ -152,49 +155,48 @@ public void MultiMatchShouldReturnFirstClass() var item2 = new Yo { Key = value, }; list.Add(item2); var result = list.FirstOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreSame(item1, result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(2, list.Count); + Assert.NotNull(result); + Assert.Same(item1, result); + Assert.Equal(value, result.Key); + Assert.Equal(2, list.Count); } } - [TestClass] public class LastOrCreateMethod { - [TestMethod] + [Fact] public void NoMatchShouldCreateStruct() { string value = "hello"; var list = new List(); var result = list.LastOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void NoMatchShouldCreateClass() { string value = "hello"; var list = new List(); var result = list.LastOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateStruct() { string value = "hello"; var list = new List(); list.Add(value); var result = list.LastOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(1, list.Count); + Assert.Equal(value, result); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void OneMatchShouldCreateClass() { string value = "hello"; @@ -202,13 +204,13 @@ public void OneMatchShouldCreateClass() var item = new Yo { Key = value, }; list.Add(item); var result = list.LastOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreSame(item, result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(1, list.Count); + Assert.NotNull(result); + Assert.Same(item, result); + Assert.Equal(value, result.Key); + Assert.Equal(1, list.Count); } - [TestMethod] + [Fact] public void MultiMatchShouldReturnLastStruct() { string value = "hello"; @@ -216,11 +218,11 @@ public void MultiMatchShouldReturnLastStruct() list.Add(value); list.Add(value); var result = list.LastOrCreate(x => x == value, () => value); - Assert.AreEqual(value, result); - Assert.AreEqual(2, list.Count); + Assert.Equal(value, result); + Assert.Equal(2, list.Count); } - [TestMethod] + [Fact] public void MultiMatchShouldReturnLastClass() { string value = "hello"; @@ -230,10 +232,10 @@ public void MultiMatchShouldReturnLastClass() var item2 = new Yo { Key = value, }; list.Add(item2); var result = list.LastOrCreate(x => x.Key == value, () => new Yo { Key = value, }); - Assert.IsNotNull(result); - Assert.AreSame(item2, result); - Assert.AreEqual(value, result.Key); - Assert.AreEqual(2, list.Count); + Assert.NotNull(result); + Assert.Same(item2, result); + Assert.Equal(value, result.Key); + Assert.Equal(2, list.Count); } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkNameValueCollectionExtensions.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkNameValueCollectionExtensions.cs similarity index 64% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkNameValueCollectionExtensions.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkNameValueCollectionExtensions.cs index 0f84a59..baae669 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkNameValueCollectionExtensions.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkNameValueCollectionExtensions.cs @@ -3,17 +3,16 @@ namespace SrkToolkit.Common.Tests { using System; using System.Collections.Generic; + using System.Collections.Specialized; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Specialized; + using Xunit; public class SrkNameValueCollectionExtensionsTests { - [TestClass] public class ToDictionaryMethod { - [TestMethod] + [Fact] public void Works() { // prepare @@ -25,18 +24,17 @@ public void Works() var result = SrkNameValueCollectionExtensions.ToDictionary(source); // verify - Assert.AreEqual(2, result.Count); - Assert.AreEqual("k1", result.Keys.First()); - Assert.AreEqual("k2", result.Keys.Skip(1).First()); - Assert.AreEqual("v1", result["k1"]); - Assert.AreEqual("v2", result["k2"]); + Assert.Equal(2, result.Count); + Assert.Equal("k1", result.Keys.First()); + Assert.Equal("k2", result.Keys.Skip(1).First()); + Assert.Equal("v1", result["k1"]); + Assert.Equal("v2", result["k2"]); } } - [TestClass] public class AsEnumerableMethod { - [TestMethod] + [Fact] public void Works() { // prepare @@ -48,12 +46,12 @@ public void Works() int i = 1; foreach (var item in SrkNameValueCollectionExtensions.AsEnumerable(source)) { - Assert.AreEqual("k" + i, item.Key); - Assert.AreEqual("v" + i, item.Value); + Assert.Equal("k" + i, item.Key); + Assert.Equal("v" + i, item.Value); i++; } - Assert.AreEqual(3, i); + Assert.Equal(3, i); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkStringExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkStringExtensionsTests.cs similarity index 63% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkStringExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkStringExtensionsTests.cs index 345c287..9504b4f 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkStringExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkStringExtensionsTests.cs @@ -5,230 +5,234 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; public class SrkStringExtensionsTests { - [TestClass] public class NullIfEmptyMethod { - [TestMethod] + [Fact] public void Null() { - Assert.IsNull(SrkStringExtensions.NullIfEmpty(null)); + Assert.Null(SrkStringExtensions.NullIfEmpty(null)); } - [TestMethod] + [Fact] public void Empty() { - Assert.IsNull(SrkStringExtensions.NullIfEmpty("")); + Assert.Null(SrkStringExtensions.NullIfEmpty("")); } - [TestMethod] + [Fact] public void Whitespace() { - Assert.IsNotNull(SrkStringExtensions.NullIfEmpty(" \t\r\n")); + Assert.NotNull(SrkStringExtensions.NullIfEmpty(" \t\r\n")); } - [TestMethod] + [Fact] public void Text() { string value = " hello "; - Assert.AreEqual(value, SrkStringExtensions.NullIfEmpty(value)); + Assert.Equal(value, SrkStringExtensions.NullIfEmpty(value)); } - [TestMethod] + [Fact] public void TextTrim() { string value = " hello "; - Assert.AreEqual("hello", SrkStringExtensions.NullIfEmpty(value, true)); + Assert.Equal("hello", SrkStringExtensions.NullIfEmpty(value, true)); } } - [TestClass] public class NullIfEmptyOrWhitespaceMethod { - [TestMethod] + [Fact] public void Null() { - Assert.IsNull(SrkStringExtensions.NullIfEmptyOrWhitespace(null)); + Assert.Null(SrkStringExtensions.NullIfEmptyOrWhitespace(null)); } - [TestMethod] + [Fact] public void Empty() { - Assert.IsNull(SrkStringExtensions.NullIfEmptyOrWhitespace("")); + Assert.Null(SrkStringExtensions.NullIfEmptyOrWhitespace("")); } - [TestMethod] + [Fact] public void Whitespace() { - Assert.IsNull(SrkStringExtensions.NullIfEmptyOrWhitespace(" \t\r\n")); + Assert.Null(SrkStringExtensions.NullIfEmptyOrWhitespace(" \t\r\n")); } - [TestMethod] + [Fact] public void Text() { string value = " hello "; - Assert.AreEqual(value, SrkStringExtensions.NullIfEmptyOrWhitespace(value)); + Assert.Equal(value, SrkStringExtensions.NullIfEmptyOrWhitespace(value)); } - [TestMethod] + [Fact] public void TextTrim() { string value = " hello "; - Assert.AreEqual("hello", SrkStringExtensions.NullIfEmptyOrWhitespace(value, true)); + Assert.Equal("hello", SrkStringExtensions.NullIfEmptyOrWhitespace(value, true)); } } - [TestClass] public class TrimToLengthMethod { - [TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))] + [Fact] public void SubstringThrowsIfNotLongEnough() { string value = "hello"; - value.Substring(10); + Assert.Throws(() => + { + value.Substring(10); + }); } - [TestMethod] + [Fact] public void TrimToLengthCutsToDesiredLength4() { string value = "hello"; var result = value.TrimToLength(4); - Assert.AreEqual("hell", result); + Assert.Equal("hell", result); } - [TestMethod] + [Fact] public void TrimToLengthCutsToDesiredLength5() { string value = "hello"; var result = value.TrimToLength(5); - Assert.AreEqual("hello", result); + Assert.Equal("hello", result); } - [TestMethod] + [Fact] public void TrimToLengthCutsToDesiredLength6() { string value = "hello"; var result = value.TrimToLength(6); - Assert.AreEqual("hello", result); + Assert.Equal("hello", result); } - [TestMethod] + [Fact] public void TrimToLengthCutsToDesiredLength7() { string value = "hello"; var result = value.TrimToLength(10); - Assert.AreEqual("hello", result); + Assert.Equal("hello", result); } } - [TestClass] public class ContainsAnyStrings { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfArg0IsNull() { - SrkStringExtensions.ContainsAny(null, StringComparison.CurrentCulture, new string[0]); + Assert.Throws(() => + { + SrkStringExtensions.ContainsAny(null, StringComparison.CurrentCulture, new string[0]); + }); } - [TestMethod] + [Fact] public void FalseIsSourceIsEmpty() { string source = string.Empty; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.CurrentCulture, new string[] { string.Empty, }); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void Finds1() { string source = "hello world"; var values = new string[] { "hello", "guys", }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void Finds2() { string source = "hello world"; var values = new string[] { "bye", "world", }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void Finds1CaseMatch() { string source = "Hello World"; var values = new string[] { "hello", "guys", }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void Finds1CaseIgnore() { string source = "Hello World"; var values = new string[] { "hello", "guys", }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCultureIgnoreCase, values); - Assert.IsTrue(result); + Assert.True(result); } } - [TestClass] public class ContainsAnyChars { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfArg0IsNull() { - SrkStringExtensions.ContainsAny(null, StringComparison.CurrentCulture, new char[0]); + Assert.Throws(() => + { + SrkStringExtensions.ContainsAny(null, StringComparison.CurrentCulture, new char[0]); + }); } - [TestMethod] + [Fact] public void Finds1() { string source = "hello world"; var values = new char[] { 'h', 'x', }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void Finds1_Params() { string source = "hello world"; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, 'h', 'x'); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void Finds2() { string source = "hello world"; var values = new char[] { 'x', 'w', }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsTrue(result); + Assert.True(result); } - [TestMethod] + [Fact] public void Finds1CaseMatch() { string source = "Hello World"; var values = new char[] { 'h', 'w', }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCulture, values); - Assert.IsFalse(result); + Assert.False(result); } - [TestMethod] + [Fact] public void Finds1CaseIgnore() { string source = "Hello World"; var values = new char[] { 'h', 'x', }; bool result = SrkStringExtensions.ContainsAny(source, StringComparison.InvariantCultureIgnoreCase, values); - Assert.IsTrue(result); + Assert.True(result); } } } diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkStringTransformer.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkStringTransformer.cs similarity index 77% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkStringTransformer.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkStringTransformer.cs index cf36ee4..25196da 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkStringTransformer.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkStringTransformer.cs @@ -10,11 +10,10 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; public class SrkStringTransformerTests { - [TestClass] public class LinksAsHtmlMethod { ////static readonly string linkFormat = "{1}"; @@ -33,7 +32,7 @@ private string Text1formatted get { return text1formatted ?? (text1formatted = text1.LinksAsHtml()); } } - [TestMethod] + [Fact] public void text1_0() { var html = Text1formatted; @@ -42,7 +41,7 @@ public void text1_0() Test(html, url); } - [TestMethod] + [Fact] public void text1_1() { var html = Text1formatted; @@ -51,7 +50,7 @@ public void text1_1() Test(html, url); } - [TestMethod] + [Fact] public void text1_2() { var html = Text1formatted; @@ -60,7 +59,7 @@ public void text1_2() Test(html, url); } - [TestMethod] + [Fact] public void text1_3() { var html = Text1formatted; @@ -69,7 +68,7 @@ public void text1_3() Test(html, url); } - [TestMethod] + [Fact] public void text1_4() { var html = Text1formatted; @@ -78,7 +77,7 @@ public void text1_4() Test(html, url); } - [TestMethod] + [Fact] public void text1_5() { var html = Text1formatted; @@ -87,7 +86,7 @@ public void text1_5() Test(html, url); } - [TestMethod] + [Fact] public void text1_6() { var html = Text1formatted; @@ -96,7 +95,7 @@ public void text1_6() Test(html, url); } - [TestMethod] + [Fact] public void text1_7() { var html = Text1formatted; @@ -105,7 +104,7 @@ public void text1_7() Test(html, url); } - [TestMethod] + [Fact] public void text1_8() { var html = Text1formatted; @@ -114,7 +113,7 @@ public void text1_8() Test(html, url); } - [TestMethod] + [Fact] public void text1_9() { var html = Text1formatted; @@ -123,7 +122,7 @@ public void text1_9() Test(html, url); } - [TestMethod] + [Fact] public void UrlAtBeginning() { string input = "http://gmail.com shows your emails"; @@ -133,7 +132,7 @@ public void UrlAtBeginning() Test(result, expected); } - [TestMethod] + [Fact] public void emailAddress() { string input = "contact me at antoine.sottiau@gmail.com for more info"; @@ -141,14 +140,14 @@ public void emailAddress() string expected = "mailto:antoine.sottiau@gmail.com"; Test(result, expected); - Assert.IsTrue(result.Contains(">antoine.sottiau@gmail.com<")); + Assert.True(result.Contains(">antoine.sottiau@gmail.com<")); } private void Test(string content, string url) { string expected1 = "\"" + url.ProperHtmlAttributeEscape() + "\""; bool valid = content.Contains(expected1); - Assert.IsTrue(valid, "should contain '" + expected1 + "'"); + Assert.True(valid, "should contain '" + expected1 + "'"); } @@ -156,7 +155,7 @@ private void Test(string content, string url) /// Bug where the same link appear multiple time in a string. /// At the end there is only one <a> with a href attribute containing all urls. /// - [TestMethod] + [Fact] public void Bug1() { // prepare @@ -171,13 +170,13 @@ public void Bug1() string result = input.LinksAsHtml(); // verify - Assert.IsTrue(result.Count(c => c == '<') > 2); + Assert.True(result.Count(c => c == '<') > 2); } /// /// URLs containing the symbol & should not be double escaped. /// - [TestMethod] + [Fact] public void Bug2() { string input = "http://site.com/Complex/path.php?key1=val1&key2=value2&openlink=1"; @@ -186,7 +185,7 @@ public void Bug2() this.Test(result, input); } - [TestMethod] + [Fact] public void LongUrlSpanTruncate() { var input = @"hello, http://verylongsub.domain.rules.com/this/is/a/very/long/url/from/hell/and/other/dark/places/and-finaly/a-page.html?with=arguments&and=more&arguments=all&over=the&workd :D"; @@ -196,49 +195,47 @@ public void LongUrlSpanTruncate() SrkToolkit.Testing.Assert.Contains(expected, result); } - [TestMethod] + [Fact] public void LongUrlSpanTruncateNoEsc() { var input = @"hello, http://verylongsub.domain.rules.com/this/is/a/very/long/url/from/hell/and/other/dark/places/and-finaly/a-page.html?with=arguments&and=more&arguments=all&over=the&workd :D"; var expected = ">http://verylongsub.domain.rules.com/this/is/a/very/long/url/from/hell/and/other/dark/places/and-finaly/a-page.html?with=arguments&and=more&arguments=all&over=the&workd<"; var result = input.LinksAsHtml(avoidDoubleEscape: true); - Assert.IsTrue(result.Contains(expected)); + Assert.True(result.Contains(expected)); } } - [TestClass] public class AddHtmlLineBreaksMethod { - [TestMethod] + [Fact] public void WorksWithWindows() { string text = "aaa\r\nbbb\r\nccc"; string expected = "aaa
\r\nbbb
\r\nccc"; string actual = text.AddHtmlLineBreaks(); - Assert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] + [Fact] public void WorksWithLinux() { string text = "aaa\nbbb\nccc"; string expected = "aaa
\nbbb
\nccc"; string actual = text.AddHtmlLineBreaks(); - Assert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] + [Fact] public void WorksWithStupidProducts() { string text = "aaa\rbbb\rccc"; string expected = "aaa
\rbbb
\rccc"; string actual = text.AddHtmlLineBreaks(); - Assert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } } - [TestClass] public class HtmlParagraphizifyMethod { readonly static string subject = @"p1 @@ -252,25 +249,25 @@ public class HtmlParagraphizifyMethod p3 "; - [TestMethod] + [Fact] public void Single() { string subject = "bla"; string expected = @"

bla

"; string result = subject.HtmlParagraphizify(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void Single1() { string subject = "bla\n"; string expected = "

bla

"; string result = subject.HtmlParagraphizify(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void Many() { string expected = @"

p1 @@ -280,10 +277,10 @@ public void Many()

p3 p3

"; string result = subject.HtmlParagraphizify(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void CombinedWithLineBreaks() { string expected = @"

p1
@@ -293,66 +290,64 @@ public void CombinedWithLineBreaks()

p3
p3

"; string result = subject.HtmlParagraphizify(makeLineBreaks: true); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class TwitterLinksAsHtmlMethod { - [TestMethod] + [Fact] public void SimpleHash() { var text = "c'est cool de regarder #tf1 à 20h"; var result = text.TwitterLinksAsHtml(); Test(result, "https://twitter.com/search/realtime?q=%23tf1&src=hash"); - Assert.IsTrue(result.Contains("c'est")); - Assert.IsTrue(result.Contains("regarder #tf1 à")); + Assert.True(result.Contains("c'est")); + Assert.True(result.Contains("regarder #tf1 à")); } - [TestMethod] + [Fact] public void SimpleUser() { var text = "suivez tous @kalexandre !"; var result = text.TwitterLinksAsHtml(); Test(result, "https://twitter.com/kalexandre"); - Assert.IsTrue(result.Contains("tous @kalexandre !")); + Assert.True(result.Contains("tous @kalexandre !")); } - [TestMethod] + [Fact] public void HashAtBeginning() { var text = "#tf1 à 20h"; var result = text.TwitterLinksAsHtml(); Test(result, "https://twitter.com/search/realtime?q=%23tf1&src=hash"); - Assert.IsTrue(result.Contains("#tf1 à")); + Assert.True(result.Contains("#tf1 à")); } - [TestMethod] + [Fact] public void UserAtBeginning() { var text = "@kalexandre !"; var result = text.TwitterLinksAsHtml(); Test(result, "https://twitter.com/kalexandre"); - Assert.IsTrue(result.Contains("@kalexandre !")); + Assert.True(result.Contains("@kalexandre !")); } private void Test(string content, string url) { string expected1 = "\"" + url.ProperHtmlEscape() + "\""; bool valid = content.Contains(expected1); - Assert.IsTrue(valid, "should contain '" + expected1 + "'"); + Assert.True(valid, "should contain '" + expected1 + "'"); } } - [TestClass] public class ToUpperFirstLettersMethod { - [TestMethod] + [Fact] public void OneWord() { string input = "hello"; @@ -360,10 +355,10 @@ public void OneWord() string result = input.ToUpperFirstLetters(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ManyWords() { string input = "hello world"; @@ -371,10 +366,10 @@ public void ManyWords() string result = input.ToUpperFirstLetters(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ManyWords_LeavesOtherCharsAsIs() { string input = "heLLo wORLd"; @@ -382,10 +377,10 @@ public void ManyWords_LeavesOtherCharsAsIs() string result = input.ToUpperFirstLetters(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void BadPunctuation() { string input = ".hello.world"; @@ -393,14 +388,13 @@ public void BadPunctuation() string result = input.ToUpperFirstLetters(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class CapitalizeWordsMethod { - [TestMethod] + [Fact] public void OneWord() { string input = "hello"; @@ -408,10 +402,10 @@ public void OneWord() string result = input.CapitalizeWords(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ManyWords() { string input = "hello world"; @@ -419,10 +413,10 @@ public void ManyWords() string result = input.CapitalizeWords(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ManyWords_LeavesOtherCharsAsIs() { string input = "heLLo wORLd"; @@ -430,10 +424,10 @@ public void ManyWords_LeavesOtherCharsAsIs() string result = input.CapitalizeWords(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void BadPunctuation() { string input = ".hello.world"; @@ -441,14 +435,13 @@ public void BadPunctuation() string result = input.CapitalizeWords(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class TrimTextRightMethod { - [TestMethod] + [Fact] public void ShorterText() { string input = "hello world"; @@ -456,10 +449,10 @@ public void ShorterText() string result = input.TrimTextRight(12); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ExactLengthText() { string input = "hello world"; @@ -467,10 +460,10 @@ public void ExactLengthText() string result = input.TrimTextRight(11); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void LongerText() {// 123456789012 456789 string input = "hello greater world"; @@ -478,10 +471,10 @@ public void LongerText() string result = input.TrimTextRight(12); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void LongerTextOnSpace() {// 123456789012345 789 string input = "hello great world"; @@ -489,14 +482,13 @@ public void LongerTextOnSpace() string result = input.TrimTextRight(15); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class TrimTextLeftMethod { - [TestMethod] + [Fact] public void ShorterText() { string input = "hello world"; @@ -504,10 +496,10 @@ public void ShorterText() string result = input.TrimTextLeft(12); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ExactLengthText() { string input = "hello world"; @@ -515,10 +507,10 @@ public void ExactLengthText() string result = input.TrimTextLeft(11); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void LongerText() {// 123456789012 456789 string input = "hello greater world"; @@ -527,11 +519,11 @@ public void LongerText() string result = input.TrimTextLeft(length); - Assert.AreEqual(expected, result); - Assert.IsTrue(result.Length <= length); + Assert.Equal(expected, result); + Assert.True(result.Length <= length); } - [TestMethod] + [Fact] public void LongerTextOnSpace() {// 123456789012345 789 string input = "hello great world"; @@ -540,15 +532,14 @@ public void LongerTextOnSpace() string result = input.TrimTextLeft(length); - Assert.AreEqual(expected, result); - Assert.IsTrue(result.Length <= length); + Assert.Equal(expected, result); + Assert.True(result.Length <= length); } } - [TestClass] public class RemoveDiacriticsMethod { - [TestMethod] + [Fact] public void French() { string input = "Là bas se trouvent une çédille et un œuf. L'été fût dur. Par la fenêtre. En grève ex æquo."; @@ -556,10 +547,10 @@ public void French() string result = input.RemoveDiacritics(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void German() { string input = "German uses the umlauts ä, ö and ü. The eszett (ß) represents the unvoiced s sound."; @@ -567,14 +558,13 @@ public void German() string result = input.RemoveDiacritics(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class RemoveSpacesMethod { - [TestMethod] + [Fact] public void SomeSpaces() { string input = " \t\n\r\u00A0\u2002\u2003\u2004\u2005\u205F"; @@ -582,14 +572,13 @@ public void SomeSpaces() string result = input.RemoveSpaces(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class RemoveDuplicateSpacesMethod { - [TestMethod] + [Fact] public void AllSpaces() { string input = " \t\n\r\u00A0\u2002\u2003\u2004\u2005\u205F"; @@ -597,10 +586,10 @@ public void AllSpaces() string result = input.RemoveDuplicateSpaces(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SpacesAndWordAndSpacesAndWordAndSpaces() { string spaces = " \t\n\r\u00A0\u2002\u2003\u2004 \u2005\u205F"; @@ -609,10 +598,10 @@ public void SpacesAndWordAndSpacesAndWordAndSpaces() string result = input.RemoveDuplicateSpaces(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SpacesAndWordAndSpacesAndWord() { string spaces = " \t\n\r\u00A0\u2002\u2003\u2004 \u2005\u205F"; @@ -621,10 +610,10 @@ public void SpacesAndWordAndSpacesAndWord() string result = input.RemoveDuplicateSpaces(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WordAndSpacesAndWordAndSpaces() { string spaces = " \t\n\r\u00A0\u2002\u2003\u2004 \u2005\u205F"; @@ -633,14 +622,13 @@ public void WordAndSpacesAndWordAndSpaces() string result = input.RemoveDuplicateSpaces(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class MakeUrlFriendlyMethod { - [TestMethod] + [Fact] public void Test() { string input = "German uses the umlauts ä, ö and ü. "; @@ -648,10 +636,10 @@ public void Test() string result = input.MakeUrlFriendly(false); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void PreserveCase() { string input = "German uses the umlauts ä, ö AND ü. "; @@ -659,10 +647,10 @@ public void PreserveCase() string result = input.MakeUrlFriendly(true); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NoPreserveCase() { string input = "Hello guys, this is SandRock from http://sparklenetworks.com. "; @@ -670,10 +658,10 @@ public void NoPreserveCase() string result = input.MakeUrlFriendly(false); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void PreserveCase1() { string input = "Hello guys, this is SandRock from http://sparklenetworks.com. "; @@ -681,10 +669,10 @@ public void PreserveCase1() string result = input.MakeUrlFriendly(true); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void PreserveCaseAndChars() { string input = "Hello guys, this is SandRock from http://sparklenetworks.com. "; @@ -692,14 +680,13 @@ public void PreserveCaseAndChars() string result = input.MakeUrlFriendly(true, preserveChars: new char[]{ '.', ',', }); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class GetIncrementedStringMethod { - [TestMethod] + [Fact] public void Nothing() { string input = "test"; @@ -707,10 +694,10 @@ public void Nothing() string result = input.GetIncrementedString(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After1Goes2() { string input = "test-1"; @@ -718,10 +705,10 @@ public void After1Goes2() string result = input.GetIncrementedString(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After2Goes3() { string input = "test-2"; @@ -729,10 +716,10 @@ public void After2Goes3() string result = input.GetIncrementedString(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After9Goes10() { string input = "test-9"; @@ -740,10 +727,10 @@ public void After9Goes10() string result = input.GetIncrementedString(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After10Goes11() { string input = "test-10"; @@ -751,10 +738,10 @@ public void After10Goes11() string result = input.GetIncrementedString(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AfterNothingGoes7() { string input = "test"; @@ -762,10 +749,10 @@ public void AfterNothingGoes7() string result = input.GetIncrementedString(startIndex: 7); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After1Goes7() { string input = "test-1"; @@ -773,10 +760,10 @@ public void After1Goes7() string result = input.GetIncrementedString(startIndex: 7); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After1Goes3() { string input = "test-1"; @@ -784,10 +771,10 @@ public void After1Goes3() string result = input.GetIncrementedString(startIndex: 3); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void After1GoesGreaterThan3() { string input = "test-1"; @@ -808,10 +795,10 @@ public void After1GoesGreaterThan3() } }); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AfterNothingGoesGreaterThan3() { string input = "test"; @@ -832,14 +819,13 @@ public void AfterNothingGoesGreaterThan3() } }); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class ProperHtmlEscapeMethod { - [TestMethod] + [Fact] public void Test() { string input = "helo w & or & ld"; @@ -847,10 +833,10 @@ public void Test() string result = input.ProperHtmlEscape(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NullArg() { string input = null; @@ -858,10 +844,10 @@ public void NullArg() string result = input.ProperHtmlEscape(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AllCharsEscaped() { string input = "&<>\"'/"; @@ -869,14 +855,13 @@ public void AllCharsEscaped() string result = input.ProperHtmlEscape(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class ProperHtmlAttributeEscapeMethod { - [TestMethod] + [Fact] public void Test() { string input = "helo w & or & ld"; @@ -884,10 +869,10 @@ public void Test() string result = input.ProperHtmlAttributeEscape(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NullArg() { string input = null; @@ -895,72 +880,70 @@ public void NullArg() string result = input.ProperHtmlEscape(); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class UnescapeUnicodeSequencesMethod { - [TestMethod] + [Fact] public void WorksOn0x3D() { string input = @"\x3D"; string expected = "="; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0x3D() { string input = @"aaaa\x3Daaaa"; string expected = "aaaa=aaaa"; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0x3DDouble() { string input = @"aaaa\x3Daaaa\x3Daaaa"; string expected = "aaaa=aaaa=aaaa"; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWithHeart() { string input = @"aaaa\xE9aaaa"; string expected = "aaaaéaaaa"; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AtStart() { string input = @"\x3Daaaa"; string expected = "=aaaa"; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void AtEnd() { string input = @"aaaa\x3D"; string expected = "aaaa="; string result = SrkStringTransformer.UnescapeUnicodeSequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } /* - [TestClass] public class UnescapeUTF8SequencesMethod { - [TestMethod] + [Fact] public void WorksOn0x3D() { string input = @"\x3D"; @@ -968,10 +951,10 @@ public void WorksOn0x3D() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0x3D() { string input = @"aaaa\x3Daaaa"; @@ -979,10 +962,10 @@ public void WorksOnStringWith0x3D() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0x3DDouble() { string input = @"aaaa\x3Daaaa\x3Daaaa"; @@ -990,10 +973,10 @@ public void WorksOnStringWith0x3DDouble() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWithHeart() { string input = @"aaaa\xE9aaaa"; @@ -1001,10 +984,10 @@ public void WorksOnStringWithHeart() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0021() { string input = @"aaaa\x0021\x21aaaa"; @@ -1012,10 +995,10 @@ public void WorksOnStringWith0021() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWith0100() { string input = @"aaaa\x0100aaaa"; @@ -1023,10 +1006,10 @@ public void WorksOnStringWith0100() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void WorksOnStringWithAD9D() { string input = @"aaaa\xAD9Daaaa"; @@ -1034,15 +1017,14 @@ public void WorksOnStringWithAD9D() string result = SrkStringTransformer.UnescapeUTF8Sequences(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } */ - [TestClass] public class SimplifySpacesMethod { - [TestMethod] + [Fact] public void ModeInline_MultiSpaces_FirstCharBecomesOnlyChar() { string input = " a b \t\r\nc\t\t d\t \t"; @@ -1051,7 +1033,7 @@ public void ModeInline_MultiSpaces_FirstCharBecomesOnlyChar() SrkToolkit.Testing.Assert.AreEqual(expected, result); } - [TestMethod] + [Fact] public void ModeFull_MultiSpaces_FirstCharBecomesOnlyChar() { string input = " a b \t\r\nc\t\t d\t \t"; diff --git a/Sources/NET4.SrkToolkit.Common.Tests/SrkTimeZoneInfoExtensionsTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/SrkTimeZoneInfoExtensionsTests.cs similarity index 50% rename from Sources/NET4.SrkToolkit.Common.Tests/SrkTimeZoneInfoExtensionsTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/SrkTimeZoneInfoExtensionsTests.cs index 5c6c81a..f86575d 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/SrkTimeZoneInfoExtensionsTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkTimeZoneInfoExtensionsTests.cs @@ -10,14 +10,13 @@ namespace SrkToolkit.Common.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; public class SrkTimeZoneInfoExtensionsTests { - [TestClass] public class ConvertToUtcMethod { - [TestMethod] + [Fact] public void ConvertsTimeFromUnspecified() { // prepare @@ -28,17 +27,17 @@ public void ConvertsTimeFromUnspecified() var result = SrkTimeZoneInfoExtensions.ConvertToUtc(tz, date); // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(5, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(5, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Utc, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromUtc() { // prepare @@ -49,18 +48,18 @@ public void ConvertsTimeFromUtc() var result = SrkTimeZoneInfoExtensions.ConvertToUtc(tz, date); // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(date.Hour, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(date.Ticks, result.Ticks); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(date.Hour, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(date.Ticks, result.Ticks); + Assert.Equal(DateTimeKind.Utc, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromLocal() { // prepare @@ -71,18 +70,17 @@ public void ConvertsTimeFromLocal() var result = SrkTimeZoneInfoExtensions.ConvertToUtc(tz, date); // verify - Assert.AreEqual(date.Year, result.Year); - Assert.AreEqual(date.Month, result.Month); - Assert.AreEqual(date.Day, result.Day); - Assert.AreEqual(5, result.Hour); - Assert.AreEqual(date.Minute, result.Minute); - Assert.AreEqual(date.Second, result.Second); - Assert.AreEqual(date.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(date.Year, result.Year); + Assert.Equal(date.Month, result.Month); + Assert.Equal(date.Day, result.Day); + Assert.Equal(5, result.Hour); + Assert.Equal(date.Minute, result.Minute); + Assert.Equal(date.Second, result.Second); + Assert.Equal(date.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Utc, result.Kind); } } - [TestClass] public class ConvertFromUtcMethod { /* @@ -94,7 +92,7 @@ public class ConvertFromUtcMethod * When converting to the UTC TZ, ensure the DateTime.Kind is UTC. */ - [TestMethod] + [Fact] public void ConvertsTimeFromUnspecified() { // prepare @@ -106,17 +104,17 @@ public void ConvertsTimeFromUnspecified() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); - Assert.AreEqual(dateFrom.Hour + 2, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Unspecified, result.Kind); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Hour + 2, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Unspecified, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromUtc() { // prepare @@ -127,17 +125,17 @@ public void ConvertsTimeFromUtc() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); - Assert.AreEqual(dateFrom.Hour + 2, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Unspecified, result.Kind); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Hour + 2, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Unspecified, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromLocal() { // prepare @@ -149,18 +147,18 @@ public void ConvertsTimeFromLocal() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); var expectedHour = dateFrom.Hour - tzFrom.GetUtcOffset(dateFrom).TotalHours + tzTo.GetUtcOffset(dateFrom).TotalHours; - Assert.AreEqual(expectedHour, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Unspecified, result.Kind); + Assert.Equal(expectedHour, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Unspecified, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromUnspecified_ToUtc() { // prepare @@ -171,17 +169,17 @@ public void ConvertsTimeFromUnspecified_ToUtc() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); - Assert.AreEqual(dateFrom.Hour, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Hour, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Utc, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromUtc_ToUtc() { // prepare @@ -192,17 +190,17 @@ public void ConvertsTimeFromUtc_ToUtc() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); - Assert.AreEqual(dateFrom.Hour, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Hour, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Utc, result.Kind); } - [TestMethod] + [Fact] public void ConvertsTimeFromLocal_ToUtc() { // prepare @@ -214,15 +212,15 @@ public void ConvertsTimeFromLocal_ToUtc() var result = SrkTimeZoneInfoExtensions.ConvertFromUtc(tzTo, dateFrom); // verify - Assert.AreEqual(dateFrom.Year, result.Year); - Assert.AreEqual(dateFrom.Month, result.Month); - Assert.AreEqual(dateFrom.Day, result.Day); + Assert.Equal(dateFrom.Year, result.Year); + Assert.Equal(dateFrom.Month, result.Month); + Assert.Equal(dateFrom.Day, result.Day); var expectedHour = dateFrom.Hour - tzFrom.GetUtcOffset(dateFrom).TotalHours + tzTo.GetUtcOffset(dateFrom).TotalHours; - Assert.AreEqual(expectedHour, result.Hour); - Assert.AreEqual(dateFrom.Minute, result.Minute); - Assert.AreEqual(dateFrom.Second, result.Second); - Assert.AreEqual(dateFrom.Millisecond, result.Millisecond); - Assert.AreEqual(DateTimeKind.Utc, result.Kind); + Assert.Equal(expectedHour, result.Hour); + Assert.Equal(dateFrom.Minute, result.Minute); + Assert.Equal(dateFrom.Second, result.Second); + Assert.Equal(dateFrom.Millisecond, result.Millisecond); + Assert.Equal(DateTimeKind.Utc, result.Kind); } } } diff --git a/Sources/SrkToolkit.Common.FxUnitTests/SrkToolkit.Common.FxUnitTests.csproj b/Sources/SrkToolkit.Common.FxUnitTests/SrkToolkit.Common.FxUnitTests.csproj new file mode 100644 index 0000000..077c90c --- /dev/null +++ b/Sources/SrkToolkit.Common.FxUnitTests/SrkToolkit.Common.FxUnitTests.csproj @@ -0,0 +1,99 @@ + + + + + Debug + AnyCPU + {00457CE3-FE08-4AF2-972E-4C2EDD36F38D} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + SrkToolkit.Common.FxUnitTests + SrkToolkit.Common.FxUnitTests + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE;NETFRAMEWORK + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE;NETFRAMEWORK + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {9442b344-fc0d-4a0b-be0e-d317c72f2a8e} + SrkToolkit.Common + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Sources/NET4.SrkToolkit.Common.Tests/StringReplacerTests.cs b/Sources/SrkToolkit.Common.FxUnitTests/StringReplacerTests.cs similarity index 86% rename from Sources/NET4.SrkToolkit.Common.Tests/StringReplacerTests.cs rename to Sources/SrkToolkit.Common.FxUnitTests/StringReplacerTests.cs index acc40ec..361776d 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/StringReplacerTests.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/StringReplacerTests.cs @@ -1,17 +1,16 @@  namespace SrkToolkit.Common.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; + using Xunit; - [TestClass] public class StringReplacerTests { - [TestMethod] + [Fact] public void Simple() { var target = new StringReplacer(); @@ -19,10 +18,10 @@ public void Simple() var text = "Hello {Hello}"; var expected = "Hello World"; var result = target.Replace(text); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SimpleAndDefault() { var target = new StringReplacer(); @@ -30,10 +29,10 @@ public void SimpleAndDefault() var text = "Hello {Hello} {Other}"; var expected = "Hello World "; var result = target.Replace(text); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SimpleAndCustomDefault() { var target = new StringReplacer(); @@ -42,10 +41,10 @@ public void SimpleAndCustomDefault() var text = "Hello {Hello} {Other}"; var expected = "Hello World ???"; var result = target.Replace(text); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SimpleWithCulture() { var model = new UserModel @@ -59,10 +58,10 @@ public void SimpleWithCulture() var culture = new CultureInfo("en-US"); var tz = TimeZoneInfo.Local; var result = target.Replace(text, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void SimpleWithCulture1() { var model = new UserModel @@ -76,10 +75,10 @@ public void SimpleWithCulture1() var culture = new CultureInfo("fr-FR"); var tz = TimeZoneInfo.Local; var result = target.Replace(text, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void Model() { var model = new UserModel @@ -91,10 +90,10 @@ public void Model() var text = "Hello {User.Name}"; var expected = "Hello Johny"; var result = target.Replace(text, model); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelAndDefault() { var model = new UserModel @@ -106,10 +105,10 @@ public void ModelAndDefault() var text = "Hello {User.Name} {Other}"; var expected = "Hello Johny "; var result = target.Replace(text, model); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelAndCustomDefault() { var model = new UserModel @@ -122,10 +121,10 @@ public void ModelAndCustomDefault() var text = "Hello {User.Name} {Other}"; var expected = "Hello Johny ??Other??"; var result = target.Replace(text, model); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithCulture() { var model = new UserModel @@ -139,10 +138,10 @@ public void ModelWithCulture() var text = "Hello {User.Date}"; var expected = "Hello " + model.Date.ToString("d", culture); var result = target.Replace(text, model, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithReplacerCulture_EnglishUSA() { var model = new UserModel @@ -156,10 +155,10 @@ public void ModelWithReplacerCulture_EnglishUSA() var text = "Hello {User.Date}"; var expected = "Hello " + model.Date.ToString("d", culture); var result = target.Replace(text, model); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithReplacerCulture_FrenchFrance() { var model = new UserModel @@ -173,10 +172,10 @@ public void ModelWithReplacerCulture_FrenchFrance() var text = "Hello {User.Date}"; var expected = "Hello " + model.Date.ToString("d", culture); var result = target.Replace(text, model); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithCulture1() { var model = new UserModel @@ -190,10 +189,10 @@ public void ModelWithCulture1() var culture = new CultureInfo("fr-FR"); var tz = TimeZoneInfo.Local; var result = target.Replace(text, model, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithTimezone1() { var model = new UserModel @@ -207,10 +206,10 @@ public void ModelWithTimezone1() var culture = new CultureInfo("en-US"); var tz = TimeZoneInfo.Utc; var result = target.Replace(text, model, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ModelWithTimezone2() { var model = new UserModel @@ -224,7 +223,7 @@ public void ModelWithTimezone2() var culture = new CultureInfo("en-US"); var tz = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); var result = target.Replace(text, model, culture, tz); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } public class UserModel diff --git a/Sources/NET4.SrkToolkit.Common.Tests/ValidateTEsts.cs b/Sources/SrkToolkit.Common.FxUnitTests/ValidateTEsts.cs similarity index 72% rename from Sources/NET4.SrkToolkit.Common.Tests/ValidateTEsts.cs rename to Sources/SrkToolkit.Common.FxUnitTests/ValidateTEsts.cs index 6606fbc..c1706e8 100644 --- a/Sources/NET4.SrkToolkit.Common.Tests/ValidateTEsts.cs +++ b/Sources/SrkToolkit.Common.FxUnitTests/ValidateTEsts.cs @@ -6,184 +6,181 @@ namespace SrkToolkit.Common.Tests { + using SrkToolkit.Common.Validation; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Common.Validation; + using Xunit; /// /// TODO: Update summary. /// public class ValidateTEsts { - [TestClass] public class EmailAddressMethod { - [TestMethod] + [Fact] public void SimpleAddress() { string input = "antoine@gmail.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(input, result); + Assert.Equal(input, result); } - [TestMethod] + [Fact] public void Loweryfies() { string input = "Antoine@Gmail.com"; string expected = "antoine@gmail.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void FirstAndLastNameAddress() { string input = "antoine.sottiau@gmail.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(input, result); + Assert.Equal(input, result); } - [TestMethod] + [Fact] public void FirstAndLastNameAndPlusAddress() { string input = "antoine.sottiau+something-special@gmail.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(input, result); + Assert.Equal(input, result); } - [TestMethod] + [Fact] public void NoAtSign() { string input = "Antoine.Gmail.com"; string expected = null; var result = Validate.EmailAddress(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void EmailCharacterInternational() { string input = "testspecïalchar@toto.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(input, result); + Assert.Equal(input, result); } - [TestMethod] + [Fact] public void EmailCharacterSingleQuote() { string input = "testspec'alchar@toto.com"; var result = Validate.EmailAddress(input); - Assert.AreEqual(input, result); + Assert.Equal(input, result); } } - [TestClass] public class ManyEmailAddressesMethod { - [TestMethod] + [Fact] public void ReturnsEmptyEnumerationOnNullInput() { string input = null; var result = Validate.ManyEmailAddresses(input).ToArray(); - Assert.AreEqual(0, result.Length); + Assert.Equal(0, result.Length); } - [TestMethod] + [Fact] public void Works() { string input = "blah antoine.sottiau+something-special@gmail.com Antoine@Gmail.com xxxxxx"; var result = Validate.ManyEmailAddresses(input).ToArray(); - Assert.AreEqual(2, result.Length); - Assert.AreEqual("antoine.sottiau+something-special@gmail.com", result[0]); - Assert.AreEqual("antoine@gmail.com", result[1]); + Assert.Equal(2, result.Length); + Assert.Equal("antoine.sottiau+something-special@gmail.com", result[0]); + Assert.Equal("antoine@gmail.com", result[1]); } } - [TestClass] public class PhoneNumberMethod { - [TestMethod] + [Fact] public void ValidPerfectNumber() { string input = "+33123456789"; string expected = input; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ValidPerfectTrimmedNumber() { string input = "\t+33123456789 \r\n "; string expected = "+33123456789"; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ValidPerfectSpacedNumber() { string input = "+33 123 456 789"; string expected = "+33123456789"; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ValidPerfectSeparatedNumber() { string input = "+33 123/456-789.012"; string expected = "+33123456789012"; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void ZeroZeroNumber() { string input = "0033123456789"; string expected = "+33123456789"; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NationalReturnsNull() { string input = "0123456789"; string expected = null; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NationalAccepted() { string input = "0123456789"; string expected = "0123456789"; string result = Validate.PhoneNumber(input, true); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void NationalNonZeroAccepted() { string input = "123456789"; string expected = "123456789"; string result = Validate.PhoneNumber(input, true); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void IntlWithOptionalZero() { string input = "+33 (0) 123456789"; string expected = "+33123456789"; string result = Validate.PhoneNumber(input); - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } } diff --git a/Sources/NET4.SrkToolkit.Common/Collections/DictionaryWrapper.cs b/Sources/SrkToolkit.Common/Collections/DictionaryWrapper.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Collections/DictionaryWrapper.cs rename to Sources/SrkToolkit.Common/Collections/DictionaryWrapper.cs diff --git a/Sources/NET4.SrkToolkit.Common/CompositeDisposable.cs b/Sources/SrkToolkit.Common/CompositeDisposable.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/CompositeDisposable.cs rename to Sources/SrkToolkit.Common/CompositeDisposable.cs diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs index 0b70c3a..3945c11 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/CultureInfoAttribute.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.DataAnnotations { using System; @@ -84,3 +86,4 @@ public override bool IsValid(object value) } } } +#endif diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs index 2eec443..0587cf2 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/DateRangeAttribute.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.DataAnnotations { using System; @@ -161,3 +163,4 @@ public override string FormatErrorMessage(string name) } } } +#endif diff --git a/Sources/SrkToolkit.Common/DataAnnotations/Dummy.cs b/Sources/SrkToolkit.Common/DataAnnotations/Dummy.cs new file mode 100644 index 0000000..b1332b6 --- /dev/null +++ b/Sources/SrkToolkit.Common/DataAnnotations/Dummy.cs @@ -0,0 +1,12 @@ + +namespace SrkToolkit.DataAnnotations +{ + using System; + + /// + /// This class only helps keeps the namespace available. + /// + public static class Dummy + { + } +} diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs similarity index 93% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs index 8f40ca6..42b410d 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/EmailAddressAttribute.cs @@ -16,14 +16,20 @@ namespace SrkToolkit.DataAnnotations { + using SrkToolkit.Resources; using System; - using System.ComponentModel.DataAnnotations; using System.Globalization; - using System.Text.RegularExpressions; - using SrkToolkit.Resources; using System.Reflection; + using System.Text.RegularExpressions; - // TODO: support for netstandard +#if NET40 || NETFRAMEWORK + using System.ComponentModel.DataAnnotations; +#endif + + // This namespace is hard to support with multi-framework + // NET40: reference to System.ComponentModel.DataAnnotations + // NET46: nuget? + // NSTD: no support ? /// /// Validates an email address field (one or multiple addresses). @@ -31,9 +37,11 @@ namespace SrkToolkit.DataAnnotations #if NET40 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)] public class EmailAddressAttribute : ValidationAttribute -#else +#elif NETFRAMEWORK [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)] public class EmailAddressExAttribute : ValidationAttribute +#else + public class EmailAddressExAttribute #endif { /// @@ -46,17 +54,17 @@ public class EmailAddressExAttribute : ValidationAttribute /// /// Initializes a new instance of the class. /// -#if NET40 +#if NET40 || NETFRAMEWORK public EmailAddressAttribute() -#else - public EmailAddressExAttribute() -#endif { -#if !NSTD this.ErrorMessageResourceName = "EmailAddressAttribute_ErrorMessage"; this.ErrorMessageResourceType = typeof(Strings); -#endif } +#else + public EmailAddressExAttribute() + { + } +#endif /// /// Gets or sets a value indicating whether to allow multiple addresses in a single field. Default is false. Use to parse addresses. @@ -81,7 +89,7 @@ public EmailAddressExAttribute() /// protected Regex Regex { get; set; } -#if !NSTD +#if NET40 || NETFRAMEWORK /// /// Validates the specified value with respect to the current validation attribute. /// diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs index af7b0af..69e478b 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/PhoneNumberAttribute.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.DataAnnotations { using SrkToolkit.Resources; @@ -87,3 +89,4 @@ public static bool ConvertNationalToInternational(string value, CultureInfo cult } } } +#endif diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs index 525deda..cc0855e 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/TimezoneAttribute.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.DataAnnotations { using System; @@ -70,3 +72,4 @@ public override bool IsValid(object value) } } } +#endif diff --git a/Sources/NET4.SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs b/Sources/SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs rename to Sources/SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs index 2da6742..7685540 100644 --- a/Sources/NET4.SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs +++ b/Sources/SrkToolkit.Common/DataAnnotations/TwitterUsernameAttribute.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.DataAnnotations { using SrkToolkit.Resources; @@ -74,3 +76,4 @@ public static bool GetUsername(string value, out string username) } } } +#endif diff --git a/Sources/NET4.SrkToolkit.Common/DisposableOnce.cs b/Sources/SrkToolkit.Common/DisposableOnce.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/DisposableOnce.cs rename to Sources/SrkToolkit.Common/DisposableOnce.cs diff --git a/Sources/NET4.SrkToolkit.Common/EnumTools.cs b/Sources/SrkToolkit.Common/EnumTools.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/EnumTools.cs rename to Sources/SrkToolkit.Common/EnumTools.cs diff --git a/Sources/NET4.SrkToolkit.Common/Globalization/CultureInfoHelper.cs b/Sources/SrkToolkit.Common/Globalization/CultureInfoHelper.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Globalization/CultureInfoHelper.cs rename to Sources/SrkToolkit.Common/Globalization/CultureInfoHelper.cs diff --git a/Sources/SrkToolkit.Common/IO/Dummy.cs b/Sources/SrkToolkit.Common/IO/Dummy.cs new file mode 100644 index 0000000..83bd186 --- /dev/null +++ b/Sources/SrkToolkit.Common/IO/Dummy.cs @@ -0,0 +1,12 @@ + +namespace SrkToolkit.IO +{ + using System; + + /// + /// This class only helps keeps the namespace available. + /// + public static class Dummy + { + } +} diff --git a/Sources/NET4.SrkToolkit.Common/IO/RecursiveDelete.cs b/Sources/SrkToolkit.Common/IO/RecursiveDelete.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common/IO/RecursiveDelete.cs rename to Sources/SrkToolkit.Common/IO/RecursiveDelete.cs index 20f8063..9644840 100644 --- a/Sources/NET4.SrkToolkit.Common/IO/RecursiveDelete.cs +++ b/Sources/SrkToolkit.Common/IO/RecursiveDelete.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#if NETFRAMEWORK + namespace SrkToolkit.IO { using System; @@ -131,3 +133,4 @@ private void Recurse(string path, bool deletePath) } } } +#endif diff --git a/Sources/NET4.SrkToolkit.Common/Internals/Nothing.cs b/Sources/SrkToolkit.Common/Internals/Nothing.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Internals/Nothing.cs rename to Sources/SrkToolkit.Common/Internals/Nothing.cs diff --git a/Sources/NET4.SrkToolkit.Common/Internals/RetryLogicState.cs b/Sources/SrkToolkit.Common/Internals/RetryLogicState.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Internals/RetryLogicState.cs rename to Sources/SrkToolkit.Common/Internals/RetryLogicState.cs diff --git a/Sources/NET4.SrkToolkit.Common/Resources/Strings.Designer.cs b/Sources/SrkToolkit.Common/Resources/Strings.Designer.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Common/Resources/Strings.Designer.cs rename to Sources/SrkToolkit.Common/Resources/Strings.Designer.cs index eb0d1c5..4b8acd6 100644 --- a/Sources/NET4.SrkToolkit.Common/Resources/Strings.Designer.cs +++ b/Sources/SrkToolkit.Common/Resources/Strings.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -39,7 +38,7 @@ public class Strings { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Resources.Strings", typeof(Strings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Common.Resources.Strings", typeof(Strings).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Sources/NET4.SrkToolkit.Common/Resources/Strings.fr.resx b/Sources/SrkToolkit.Common/Resources/Strings.fr.resx similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Resources/Strings.fr.resx rename to Sources/SrkToolkit.Common/Resources/Strings.fr.resx diff --git a/Sources/NET4.SrkToolkit.Common/Resources/Strings.resx b/Sources/SrkToolkit.Common/Resources/Strings.resx similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Resources/Strings.resx rename to Sources/SrkToolkit.Common/Resources/Strings.resx diff --git a/Sources/NET4.SrkToolkit.Common/RetryIntervalStrategy.cs b/Sources/SrkToolkit.Common/RetryIntervalStrategy.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/RetryIntervalStrategy.cs rename to Sources/SrkToolkit.Common/RetryIntervalStrategy.cs diff --git a/Sources/NET4.SrkToolkit.Common/RetryLogic.cs b/Sources/SrkToolkit.Common/RetryLogic.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/RetryLogic.cs rename to Sources/SrkToolkit.Common/RetryLogic.cs diff --git a/Sources/SrkToolkit.Common/SrkToolkit.Common.csproj b/Sources/SrkToolkit.Common/SrkToolkit.Common.csproj new file mode 100644 index 0000000..580d88e --- /dev/null +++ b/Sources/SrkToolkit.Common/SrkToolkit.Common.csproj @@ -0,0 +1,37 @@ + + + + disable + disable + net40;net7.0;netstandard2.0 + 9 + true + 2.0.0-preview + SandRock, pyDez + SrkToolkit.Common contains various extension methods, validators and utility classes. + https://github.com/sandrock/SrkToolkit/ + https://github.com/sandrock/SrkToolkit/blob/master/LICENSE + SrkToolkit extension method extensions methods dataannotations validation + 2.0.0.0 + 2.0.0.0 + true + ..\SrkToolkit.snk + + + + + + + + + SrkToolkit.snk + + + + + + PublicResXFileCodeGenerator + + + + diff --git a/Sources/NET4.SrkToolkit.Common/StringComparerEx.cs b/Sources/SrkToolkit.Common/StringComparerEx.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/StringComparerEx.cs rename to Sources/SrkToolkit.Common/StringComparerEx.cs diff --git a/Sources/NET4.SrkToolkit.Common/StringReplacer.cs b/Sources/SrkToolkit.Common/StringReplacer.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/StringReplacer.cs rename to Sources/SrkToolkit.Common/StringReplacer.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Collections.Generic/SrkIDictionaryExtensions.cs b/Sources/SrkToolkit.Common/System.Collections.Generic/SrkIDictionaryExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Collections.Generic/SrkIDictionaryExtensions.cs rename to Sources/SrkToolkit.Common/System.Collections.Generic/SrkIDictionaryExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Collections.Generic/SrkIListExtensions.cs b/Sources/SrkToolkit.Common/System.Collections.Generic/SrkIListExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Collections.Generic/SrkIListExtensions.cs rename to Sources/SrkToolkit.Common/System.Collections.Generic/SrkIListExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Collections.ObjectModel/SrkObservableCollectionExtensions.cs b/Sources/SrkToolkit.Common/System.Collections.ObjectModel/SrkObservableCollectionExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Collections.ObjectModel/SrkObservableCollectionExtensions.cs rename to Sources/SrkToolkit.Common/System.Collections.ObjectModel/SrkObservableCollectionExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Collections.Specialized/SrkNameValueCollectionExtensions.cs b/Sources/SrkToolkit.Common/System.Collections.Specialized/SrkNameValueCollectionExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Collections.Specialized/SrkNameValueCollectionExtensions.cs rename to Sources/SrkToolkit.Common/System.Collections.Specialized/SrkNameValueCollectionExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Collections/SrkIDictionaryExtensions.cs b/Sources/SrkToolkit.Common/System.Collections/SrkIDictionaryExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Collections/SrkIDictionaryExtensions.cs rename to Sources/SrkToolkit.Common/System.Collections/SrkIDictionaryExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Diagnostics/StopwatchExtensions.cs b/Sources/SrkToolkit.Common/System.Diagnostics/StopwatchExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Diagnostics/StopwatchExtensions.cs rename to Sources/SrkToolkit.Common/System.Diagnostics/StopwatchExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System.Linq/SrkEnumerable.cs b/Sources/SrkToolkit.Common/System.Linq/SrkEnumerable.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System.Linq/SrkEnumerable.cs rename to Sources/SrkToolkit.Common/System.Linq/SrkEnumerable.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/DateTimePrecision.cs b/Sources/SrkToolkit.Common/System/DateTimePrecision.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/DateTimePrecision.cs rename to Sources/SrkToolkit.Common/System/DateTimePrecision.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/SrkArrayExtensions.cs b/Sources/SrkToolkit.Common/System/SrkArrayExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/SrkArrayExtensions.cs rename to Sources/SrkToolkit.Common/System/SrkArrayExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/SrkDateTimeExtensions.cs b/Sources/SrkToolkit.Common/System/SrkDateTimeExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/SrkDateTimeExtensions.cs rename to Sources/SrkToolkit.Common/System/SrkDateTimeExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/SrkExceptionExtensions.cs b/Sources/SrkToolkit.Common/System/SrkExceptionExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/SrkExceptionExtensions.cs rename to Sources/SrkToolkit.Common/System/SrkExceptionExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/SrkStringExtensions.cs b/Sources/SrkToolkit.Common/System/SrkStringExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/SrkStringExtensions.cs rename to Sources/SrkToolkit.Common/System/SrkStringExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/SrkTimeZoneInfoExtensions.cs b/Sources/SrkToolkit.Common/System/SrkTimeZoneInfoExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/SrkTimeZoneInfoExtensions.cs rename to Sources/SrkToolkit.Common/System/SrkTimeZoneInfoExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/StringTransformer.Urls.cs b/Sources/SrkToolkit.Common/System/StringTransformer.Urls.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/StringTransformer.Urls.cs rename to Sources/SrkToolkit.Common/System/StringTransformer.Urls.cs diff --git a/Sources/NET4.SrkToolkit.Common/System/StringTransformer.cs b/Sources/SrkToolkit.Common/System/StringTransformer.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/System/StringTransformer.cs rename to Sources/SrkToolkit.Common/System/StringTransformer.cs diff --git a/Sources/NET4.SrkToolkit.Common/Testing/Assert.cs b/Sources/SrkToolkit.Common/Testing/Assert.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Testing/Assert.cs rename to Sources/SrkToolkit.Common/Testing/Assert.cs diff --git a/Sources/NET4.SrkToolkit.Common/Threading.Tasks/TaskEx.cs b/Sources/SrkToolkit.Common/Threading.Tasks/TaskEx.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Threading.Tasks/TaskEx.cs rename to Sources/SrkToolkit.Common/Threading.Tasks/TaskEx.cs diff --git a/Sources/NET4.SrkToolkit.Common/Validation/EmailAddressUtility.cs b/Sources/SrkToolkit.Common/Validation/EmailAddressUtility.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Validation/EmailAddressUtility.cs rename to Sources/SrkToolkit.Common/Validation/EmailAddressUtility.cs diff --git a/Sources/NET4.SrkToolkit.Common/Validation/Validate.cs b/Sources/SrkToolkit.Common/Validation/Validate.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Common/Validation/Validate.cs rename to Sources/SrkToolkit.Common/Validation/Validate.cs diff --git a/Sources/NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web/MessageDisplayMode.cs b/Sources/SrkToolkit.Domain.AspNetCore2/MessageDisplayMode.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web/MessageDisplayMode.cs rename to Sources/SrkToolkit.Domain.AspNetCore2/MessageDisplayMode.cs diff --git a/Sources/NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web/SrkDomainControllerExtensions.cs b/Sources/SrkToolkit.Domain.AspNetCore2/SrkDomainControllerExtensions.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web/SrkDomainControllerExtensions.cs rename to Sources/SrkToolkit.Domain.AspNetCore2/SrkDomainControllerExtensions.cs index 6207c73..8004188 100644 --- a/Sources/NET4.SrkToolkit.Domain.AspMvc4/SrkToolkit.Web/SrkDomainControllerExtensions.cs +++ b/Sources/SrkToolkit.Domain.AspNetCore2/SrkDomainControllerExtensions.cs @@ -16,12 +16,12 @@ namespace SrkToolkit.Web { + using Microsoft.AspNetCore.Mvc; + using SrkToolkit.Domain; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Mvc; - using SrkToolkit.Domain; /// /// Extension methods for to use with actions. diff --git a/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj b/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj new file mode 100644 index 0000000..c0f6569 --- /dev/null +++ b/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj @@ -0,0 +1,38 @@ + + + + net7.0 + enable + enable + SrkToolkit.Domain.AspNetCore2 + true + 2.0.0-preview1 + SandRock + SrkToolkit.Domain.AspNetCore2 contains extension methods for SrkToolkit.Domain in the context of a ASP MVC Core application. + https://github.com/sandrock/SrkToolkit/ + https://github.com/sandrock/SrkToolkit/blob/master/LICENSE + SrkToolkit domain AspMvcCore + 2.0.0.0 + 2.0.0.0 + true + ..\SrkToolkit.snk + + + + + SrkToolkit.snk + + + + + + + + + + + + + + + diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/BaseRequestTests.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/BaseRequestTests.cs similarity index 79% rename from Sources/NET4.SrkToolkit.Domain.Tests/BaseRequestTests.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/BaseRequestTests.cs index b509882..cd30e18 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/BaseRequestTests.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/BaseRequestTests.cs @@ -16,21 +16,19 @@ namespace SrkToolkit.Domain.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using SrkToolkit.Domain; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization.Json; + using Xunit; - [TestClass] public class BaseRequestTests { - [TestClass] public class IsValidProperty { - [TestMethod] + [Fact] public void ReturnsTrueForEmptyModel() { // prepare @@ -40,15 +38,14 @@ public void ReturnsTrueForEmptyModel() var result = request.IsValid; // verify - Assert.IsTrue(result); + Assert.True(result); } } - [TestClass] public class AddValidationErrorMethod { - [TestMethod] + [Fact] public void AddingErrorWorks() { // prepare @@ -58,10 +55,10 @@ public void AddingErrorWorks() request.AddValidationError("test"); // verify - Assert.AreEqual(1, request.AllValidationErrors.Count()); + Assert.Equal(1, request.AllValidationErrors.Count()); } - [TestMethod] + [Fact] public void AddingErrorBeforeValidationKeepsTheErrorAfterValidation() { // prepare @@ -71,15 +68,14 @@ public void AddingErrorBeforeValidationKeepsTheErrorAfterValidation() request.AddValidationError("test"); // verify - Assert.IsFalse(request.IsValid); - Assert.AreEqual(1, request.AllValidationErrors.Count()); + Assert.False(request.IsValid); + Assert.Equal(1, request.AllValidationErrors.Count()); } } - [TestClass] public class Serialization { - [TestMethod] + [Fact] public void DataContractJsonSerializerSerializesAllProperties() { var target = new Request1(); @@ -89,7 +85,7 @@ public void DataContractJsonSerializerSerializesAllProperties() serializer.WriteObject(stream, target); stream.Seek(0L, SeekOrigin.Begin); var unserialized = (Request1)serializer.ReadObject(stream); - Assert.AreEqual(target.Id, unserialized.Id); + Assert.Equal(target.Id, unserialized.Id); } } diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/BaseResultTests.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/BaseResultTests.cs similarity index 75% rename from Sources/NET4.SrkToolkit.Domain.Tests/BaseResultTests.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/BaseResultTests.cs index 3e82e1c..99466a3 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/BaseResultTests.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/BaseResultTests.cs @@ -1,83 +1,81 @@ -// -// Copyright 2014 SandRock -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace SrkToolkit.Domain.Tests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Domain; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Runtime.Serialization.Json; - - [TestClass] - public class BaseResultTests - { - [TestClass] - public class Serialization - { - [TestMethod] - public void DataContractJsonSerializerSerializesAllProperties() - { - var targetRequest = new Request1(); - targetRequest.Id = "42"; - var targetResult = new Result1(targetRequest); - targetResult.Id = "42"; - targetResult.Succeed = true; - targetResult.Errors.AddDetail(Error1.Error42, "The detail.", "The error to all failed algorithms."); - var serializer = new DataContractJsonSerializer(typeof(Result1)); - var stream = new MemoryStream(); - serializer.WriteObject(stream, targetResult); - stream.Seek(0L, SeekOrigin.Begin); - var unserialized = (Result1)serializer.ReadObject(stream); - Assert.AreEqual(targetResult.Succeed, unserialized.Succeed); - Assert.AreEqual(targetResult.Id, unserialized.Id); - Assert.AreEqual(targetResult.Request.Id, unserialized.Request.Id); - Assert.AreEqual(targetResult.Errors.Count, unserialized.Errors.Count); - Assert.AreEqual(targetResult.Errors[0].Code, unserialized.Errors[0].Code); - Assert.AreEqual(targetResult.Errors[0].DisplayMessage, unserialized.Errors[0].DisplayMessage); - Assert.AreEqual(targetResult.Errors[0].Detail, unserialized.Errors[0].Detail); - } - } - - public class Request1 : BaseRequest - { - public string Id { get; set; } - } - - public class Result1 : BaseResult - { - public Result1() - { - } - - public Result1(Request1 request) - : base(request) - { - } - - public string Id { get; set; } - } - - public enum Error1 - { - Unknown, - Error42, - IAmNotATeapot, - } - } -} +// +// Copyright 2014 SandRock +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace SrkToolkit.Domain.Tests +{ + using SrkToolkit.Domain; + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Runtime.Serialization.Json; + using Xunit; + + public class BaseResultTests + { + public class Serialization + { + [Fact] + public void DataContractJsonSerializerSerializesAllProperties() + { + var targetRequest = new Request1(); + targetRequest.Id = "42"; + var targetResult = new Result1(targetRequest); + targetResult.Id = "42"; + targetResult.Succeed = true; + targetResult.Errors.AddDetail(Error1.Error42, "The detail.", "The error to all failed algorithms."); + var serializer = new DataContractJsonSerializer(typeof(Result1)); + var stream = new MemoryStream(); + serializer.WriteObject(stream, targetResult); + stream.Seek(0L, SeekOrigin.Begin); + var unserialized = (Result1)serializer.ReadObject(stream); + Assert.Equal(targetResult.Succeed, unserialized.Succeed); + Assert.Equal(targetResult.Id, unserialized.Id); + Assert.Equal(targetResult.Request.Id, unserialized.Request.Id); + Assert.Equal(targetResult.Errors.Count, unserialized.Errors.Count); + Assert.Equal(targetResult.Errors[0].Code, unserialized.Errors[0].Code); + Assert.Equal(targetResult.Errors[0].DisplayMessage, unserialized.Errors[0].DisplayMessage); + Assert.Equal(targetResult.Errors[0].Detail, unserialized.Errors[0].Detail); + } + } + + public class Request1 : BaseRequest + { + public string Id { get; set; } + } + + public class Result1 : BaseResult + { + public Result1() + { + } + + public Result1(Request1 request) + : base(request) + { + } + + public string Id { get; set; } + } + + public enum Error1 + { + Unknown, + Error42, + IAmNotATeapot, + } + } +} diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/BasicResultTests.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/BasicResultTests.cs similarity index 86% rename from Sources/NET4.SrkToolkit.Domain.Tests/BasicResultTests.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/BasicResultTests.cs index 8c05a4a..a15fbf0 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/BasicResultTests.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/BasicResultTests.cs @@ -16,20 +16,18 @@ namespace SrkToolkit.Domain.Tests { + using SrkToolkit.Domain; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using SrkToolkit.Domain; + using Xunit; - [TestClass] public class BasicResultTests { - [TestClass] public class AddExtension { - [TestMethod] + [Fact] public void EnumValue() { var value = Lalala.One; @@ -38,7 +36,7 @@ public void EnumValue() IList list = new List(); list.Add(value, resourceManager); var result = list[0].DisplayMessage; - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorExtensionsTests.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorExtensionsTests.cs similarity index 60% rename from Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorExtensionsTests.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorExtensionsTests.cs index d5c59ef..53d25eb 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorExtensionsTests.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorExtensionsTests.cs @@ -16,44 +16,42 @@ namespace SrkToolkit.Domain.Tests { - using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; + using Xunit; - [TestClass] public class ResultErrorExtensionsTests { - [TestClass] public class AddMethod { - [TestMethod] + [Fact] public void Overload1() { var result = new Result1(new Request1()); var code = Error1.Hello; var message = "bad error"; result.Errors.Add(code, message); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.IsNull(result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Null(result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload2() { var result = new Result1(new Request1()); var code = Error1.Hello; var message = "Error1 Hello"; result.Errors.Add(code, Strings.ResourceManager); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.IsNull(result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Null(result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload1_Format() { var result = new Result1(new Request1()); @@ -61,13 +59,13 @@ public void Overload1_Format() var format = "Mlivej"; var message = @"WorldCode """ + format + @""""; result.Errors.Add(code, @"WorldCode ""{0}""", format); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.IsNull(result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Null(result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload2_Format() { var result = new Result1(new Request1()); @@ -75,17 +73,16 @@ public void Overload2_Format() var format = "Mlivej"; var message = @"WorldCode """ + format + @""""; result.Errors.Add(code, Strings.ResourceManager, format); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.IsNull(result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Null(result.Errors[0].Detail); } } - [TestClass] public class AddDetailMethod { - [TestMethod] + [Fact] public void Overload1() { var result = new Result1(new Request1()); @@ -93,13 +90,13 @@ public void Overload1() var message = "bad error"; var detail = "Glarg"; result.Errors.AddDetail(code, detail, message); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.AreEqual(detail, result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Equal(detail, result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload2() { var result = new Result1(new Request1()); @@ -107,13 +104,13 @@ public void Overload2() var message = "Error1 Hello"; var detail = "Glarg"; result.Errors.AddDetail(code, detail, Strings.ResourceManager); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.AreEqual(detail, result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Equal(detail, result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload1_Format() { var result = new Result1(new Request1()); @@ -122,13 +119,13 @@ public void Overload1_Format() var message = @"WorldCode """ + format + @""""; var detail = "Glarg"; result.Errors.AddDetail(code, detail, @"WorldCode ""{0}""", format); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.AreEqual(detail, result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Equal(detail, result.Errors[0].Detail); } - [TestMethod] + [Fact] public void Overload2_Format() { var result = new Result1(new Request1()); @@ -137,10 +134,10 @@ public void Overload2_Format() var message = @"WorldCode """ + format + @""""; var detail = "Glarg"; result.Errors.AddDetail(code, detail, Strings.ResourceManager, format); - Assert.AreEqual(1, result.Errors.Count); - Assert.AreEqual(code, result.Errors[0].Code); - Assert.AreEqual(message, result.Errors[0].DisplayMessage); - Assert.AreEqual(detail, result.Errors[0].Detail); + Assert.Equal(1, result.Errors.Count); + Assert.Equal(code, result.Errors[0].Code); + Assert.Equal(message, result.Errors[0].DisplayMessage); + Assert.Equal(detail, result.Errors[0].Detail); } } diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorTests.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorTests.cs similarity index 73% rename from Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorTests.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorTests.cs index 06cd00a..dbbf5c6 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/ResultErrorTests.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/ResultErrorTests.cs @@ -20,80 +20,81 @@ namespace SrkToolkit.Domain.Tests using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Resources; + using Xunit; public class ResultErrorTests { - [TestClass] public class Ctor { - [TestMethod] + [Fact] public void WithResourceManager() { var value = Lalala.One; var resourceManager = Strings.ResourceManager; var expected = "Hello World"; var result = new ResultError(value, resourceManager); - Assert.AreEqual(value, result.Code); - Assert.AreEqual(expected, result.DisplayMessage); + Assert.Equal(value, result.Code); + Assert.Equal(expected, result.DisplayMessage); } - [TestMethod] + [Fact] public void WithoutResourceManager() { var value = Lalala.One; var resourceManager = "Hello World"; var expected = "Hello World"; var result = new ResultError(value, resourceManager); - Assert.AreEqual(value, result.Code); - Assert.AreEqual(expected, result.DisplayMessage); + Assert.Equal(value, result.Code); + Assert.Equal(expected, result.DisplayMessage); } - [TestMethod] + [Fact] public void WithResourceManagerAndFormat() { var value = Lalala.Infinity; var resourceManager = Strings.ResourceManager; var expected = "here is a format => aabb <="; var result = new ResultError(value, resourceManager, "aabb"); - Assert.AreEqual(value, result.Code); - Assert.AreEqual(expected, result.DisplayMessage); + Assert.Equal(value, result.Code); + Assert.Equal(expected, result.DisplayMessage); } - [TestMethod] + [Fact] public void WithoutResourceManagerAndFormat() { var value = Lalala.Infinity; var resourceManager = "here is a format => {0} <="; var expected = "here is a format => aabb <="; var result = new ResultError(value, resourceManager, "aabb"); - Assert.AreEqual(value, result.Code); - Assert.AreEqual(expected, result.DisplayMessage); + Assert.Equal(value, result.Code); + Assert.Equal(expected, result.DisplayMessage); } - [TestMethod] + [Fact] public void WithNestedType() { var value = NestedClass.Lululu.One; var resourceManager = Strings.ResourceManager; var expected = "Hello World"; var result = new ResultError(value, resourceManager); - Assert.AreEqual(value, result.Code); - Assert.AreEqual(expected, result.DisplayMessage); + Assert.Equal(value, result.Code); + Assert.Equal(expected, result.DisplayMessage); } } - [TestClass] public class AddExtension { - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfArg0IsNull() { - ResultErrorExtensions.Add(default(IList>), Lalala.Many, Strings.ResourceManager); + Assert.Throws(() => + { + ResultErrorExtensions.Add(default(IList>), Lalala.Many, Strings.ResourceManager); + }); } - [TestMethod] + [Fact] public void Works() { var value = Lalala.One; @@ -102,10 +103,10 @@ public void Works() var list = new List>(); list.Add(value, resourceManager); var result = list[0].DisplayMessage; - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void Format() { var value = Lalala.Infinity; @@ -114,40 +115,41 @@ public void Format() var list = new List>(); list.Add(value, resourceManager, "test"); var result = list[0].DisplayMessage; - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } - [TestClass] public class ContainsErrorExtension { - [TestMethod] + [Fact] public void ReturnsFalseIfCodeIsNotPresent() { var errors = new List>(); errors.Add(new ResultError(Lalala.One, Strings.ResourceManager)); - Assert.IsFalse(ResultErrorExtensions.ContainsError(errors, Lalala.Many)); + Assert.False(ResultErrorExtensions.ContainsError(errors, Lalala.Many)); } - [TestMethod] + [Fact] public void ReturnsTrueIfCodeIsNotPresent() { var errors = new List>(); errors.Add(new ResultError(Lalala.One, Strings.ResourceManager)); - Assert.IsTrue(ResultErrorExtensions.ContainsError(errors, Lalala.One)); + Assert.True(ResultErrorExtensions.ContainsError(errors, Lalala.One)); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [Fact] public void ThrowsIfArg0IsNull() { - ResultErrorExtensions.ContainsError(default(IList>), Lalala.Many); + Assert.Throws(() => + { + ResultErrorExtensions.ContainsError(default(IList>), Lalala.Many); + }); } } - [TestClass] public class WithPostProcessExtension { - [TestMethod] + [Fact] public void Works() { var value = Lalala.One; @@ -156,10 +158,10 @@ public void Works() var list = new List>(); list.WithPostProcess(str => "[" + str + "]").Add(value, resourceManager); var result = list[0].DisplayMessage; - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } - [TestMethod] + [Fact] public void Format() { var value = Lalala.Infinity; @@ -168,7 +170,7 @@ public void Format() var list = new List>(); list.WithPostProcess(str => "[" + str + "]").Add(value, resourceManager, "test"); var result = list[0].DisplayMessage; - Assert.AreEqual(expected, result); + Assert.Equal(expected, result); } } diff --git a/Sources/SrkToolkit.Domain.CoreUnitTests/SrkToolkit.Domain.CoreUnitTests.csproj b/Sources/SrkToolkit.Domain.CoreUnitTests/SrkToolkit.Domain.CoreUnitTests.csproj new file mode 100644 index 0000000..d65a961 --- /dev/null +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/SrkToolkit.Domain.CoreUnitTests.csproj @@ -0,0 +1,35 @@ + + + + net7.0 + disable + disable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + PublicResXFileCodeGenerator + + + + diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/Strings.Designer.cs b/Sources/SrkToolkit.Domain.CoreUnitTests/Strings.Designer.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Domain.Tests/Strings.Designer.cs rename to Sources/SrkToolkit.Domain.CoreUnitTests/Strings.Designer.cs index 8bc663b..9869010 100644 --- a/Sources/NET4.SrkToolkit.Domain.Tests/Strings.Designer.cs +++ b/Sources/SrkToolkit.Domain.CoreUnitTests/Strings.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -39,7 +38,7 @@ public class Strings { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Domain.Tests.Strings", typeof(Strings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrkToolkit.Domain.CoreUnitTests.Strings", typeof(Strings).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Sources/NET4.SrkToolkit.Domain.Tests/Strings.resx b/Sources/SrkToolkit.Domain.CoreUnitTests/Strings.resx similarity index 100% rename from Sources/NET4.SrkToolkit.Domain.Tests/Strings.resx rename to Sources/SrkToolkit.Domain.CoreUnitTests/Strings.resx diff --git a/Sources/NET4.SrkToolkit.Domain/BaseRequest.cs b/Sources/SrkToolkit.Domain/BaseRequest.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BaseRequest.cs rename to Sources/SrkToolkit.Domain/BaseRequest.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BaseResult.cs b/Sources/SrkToolkit.Domain/BaseResult.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BaseResult.cs rename to Sources/SrkToolkit.Domain/BaseResult.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BasicResult.TResultCode.Payload.cs b/Sources/SrkToolkit.Domain/BasicResult.TResultCode.Payload.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BasicResult.TResultCode.Payload.cs rename to Sources/SrkToolkit.Domain/BasicResult.TResultCode.Payload.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BasicResult.TResultCode.cs b/Sources/SrkToolkit.Domain/BasicResult.TResultCode.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BasicResult.TResultCode.cs rename to Sources/SrkToolkit.Domain/BasicResult.TResultCode.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BasicResult.cs b/Sources/SrkToolkit.Domain/BasicResult.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BasicResult.cs rename to Sources/SrkToolkit.Domain/BasicResult.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BasicResultError.cs b/Sources/SrkToolkit.Domain/BasicResultError.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BasicResultError.cs rename to Sources/SrkToolkit.Domain/BasicResultError.cs diff --git a/Sources/NET4.SrkToolkit.Domain/BasicResultExtensions.cs b/Sources/SrkToolkit.Domain/BasicResultExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/BasicResultExtensions.cs rename to Sources/SrkToolkit.Domain/BasicResultExtensions.cs diff --git a/Sources/NET4.SrkToolkit.Domain/IBaseResult.cs b/Sources/SrkToolkit.Domain/IBaseResult.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/IBaseResult.cs rename to Sources/SrkToolkit.Domain/IBaseResult.cs diff --git a/Sources/NET4.SrkToolkit.Domain/IResultError.cs b/Sources/SrkToolkit.Domain/IResultError.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/IResultError.cs rename to Sources/SrkToolkit.Domain/IResultError.cs diff --git a/Sources/NET4.SrkToolkit.Domain/Internals/Names.cs b/Sources/SrkToolkit.Domain/Internals/Names.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/Internals/Names.cs rename to Sources/SrkToolkit.Domain/Internals/Names.cs diff --git a/Sources/NET4.SrkToolkit.Domain/ResultError.cs b/Sources/SrkToolkit.Domain/ResultError.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/ResultError.cs rename to Sources/SrkToolkit.Domain/ResultError.cs diff --git a/Sources/NET4.SrkToolkit.Domain/ResultErrorExtensions.cs b/Sources/SrkToolkit.Domain/ResultErrorExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Domain/ResultErrorExtensions.cs rename to Sources/SrkToolkit.Domain/ResultErrorExtensions.cs diff --git a/Sources/SrkToolkit.Domain/SrkToolkit.Domain.csproj b/Sources/SrkToolkit.Domain/SrkToolkit.Domain.csproj new file mode 100644 index 0000000..0629771 --- /dev/null +++ b/Sources/SrkToolkit.Domain/SrkToolkit.Domain.csproj @@ -0,0 +1,33 @@ + + + + disable + disable + net46;net7.0;netstandard2.0 + 9 + true + 2.0.0-preview1 + SandRock + SrkToolkit.Domain is used in your domain layer to provider RPC-style request and result classes. + https://github.com/sandrock/SrkToolkit/ + https://github.com/sandrock/SrkToolkit/blob/master/LICENSE + SrkToolkit domain + 2.0.0.0 + 2.0.0.0 + true + ..\SrkToolkit.snk + + + + + SrkToolkit.snk + + + + + + Internals\EnumTools.cs + + + + diff --git a/Sources/NET4.SrkToolkit.Web/NavigationLine.cs b/Sources/SrkToolkit.Web.AspMvc5/NavigationLine.cs similarity index 94% rename from Sources/NET4.SrkToolkit.Web/NavigationLine.cs rename to Sources/SrkToolkit.Web.AspMvc5/NavigationLine.cs index ad12cd6..35d09ad 100644 --- a/Sources/NET4.SrkToolkit.Web/NavigationLine.cs +++ b/Sources/SrkToolkit.Web.AspMvc5/NavigationLine.cs @@ -14,7 +14,7 @@ // limitations under the License. // -namespace SrkToolkit.Web +namespace SrkToolkit.Web.Open { using System; using System.Collections.Generic; diff --git a/Sources/NET4.SrkToolkit.Web/NavigationLineEntry.cs b/Sources/SrkToolkit.Web.AspMvc5/NavigationLineEntry.cs similarity index 94% rename from Sources/NET4.SrkToolkit.Web/NavigationLineEntry.cs rename to Sources/SrkToolkit.Web.AspMvc5/NavigationLineEntry.cs index d238e2b..b83b589 100644 --- a/Sources/NET4.SrkToolkit.Web/NavigationLineEntry.cs +++ b/Sources/SrkToolkit.Web.AspMvc5/NavigationLineEntry.cs @@ -14,7 +14,7 @@ // limitations under the License. // -namespace SrkToolkit.Web +namespace SrkToolkit.Web.Open { using System; using System.Collections.Generic; diff --git a/Sources/NET4.SrkToolkit.Web/Open/OpenGraphName.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphName.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Open/OpenGraphName.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphName.cs diff --git a/Sources/NET4.SrkToolkit.Web/Open/OpenGraphNamespace.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphNamespace.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Open/OpenGraphNamespace.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphNamespace.cs diff --git a/Sources/NET4.SrkToolkit.Web/Open/OpenGraphObject.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphObject.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Open/OpenGraphObject.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphObject.cs diff --git a/Sources/NET4.SrkToolkit.Web/Open/OpenGraphTag.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphTag.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Open/OpenGraphTag.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/OpenGraphTag.cs diff --git a/Sources/NET4.SrkToolkit.Web/Open/PageInfo.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/PageInfo.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/Open/PageInfo.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/PageInfo.cs index 98f9e4f..b8da317 100644 --- a/Sources/NET4.SrkToolkit.Web/Open/PageInfo.cs +++ b/Sources/SrkToolkit.Web.AspMvc5/Open/PageInfo.cs @@ -21,7 +21,12 @@ namespace SrkToolkit.Web.Open using System.Globalization; using System.Linq; using System.Text; + +#if ASPMVCCORE + +#else using System.Web.Mvc; +#endif /// /// Helps attach descriptors to a page in order to generate meta/link tags. diff --git a/Sources/NET4.SrkToolkit.Web/Open/PageInfoItem.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/PageInfoItem.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Open/PageInfoItem.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/PageInfoItem.cs diff --git a/Sources/NET4.SrkToolkit.Web/Open/PageInfoObject.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/PageInfoObject.cs similarity index 93% rename from Sources/NET4.SrkToolkit.Web/Open/PageInfoObject.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/PageInfoObject.cs index 3555f68..55e3452 100644 --- a/Sources/NET4.SrkToolkit.Web/Open/PageInfoObject.cs +++ b/Sources/SrkToolkit.Web.AspMvc5/Open/PageInfoObject.cs @@ -16,11 +16,17 @@ namespace SrkToolkit.Web.Open { + using Microsoft.AspNetCore.Mvc.Rendering; using System; using System.Collections.Generic; using System.Linq; using System.Text; + +#if ASPMVCCORE + +#else using System.Web.Mvc; +#endif /// /// A HTML element that will represent a page information . @@ -74,6 +80,8 @@ public OpenGraphTag OpenGraphTag get { return this.openGraphTag; } } +#if ASPNETCORE +#endif #if !NSTD && !NET40 private TagBuilder Tag { @@ -90,7 +98,8 @@ private TagBuilder Tag if (this.tagValue != null) { - tag.SetInnerText(this.tagValue); + ////tag.SetInnerText(this.tagValue); // net40 + tag.InnerHtml.Append(this.tagValue); // netstandard2.0 } return tag; @@ -217,7 +226,11 @@ public override string ToString() } else if (tag != null) { +#if ASPMVCCORE + return tag.ToString(); +#else return tag.ToString(singleTagNames.Contains(this.tagName) ? TagRenderMode.SelfClosing : TagRenderMode.Normal); +#endif } else { diff --git a/Sources/NET4.SrkToolkit.Web/Open/SrkOpenGraphHtmlExtensions.cs b/Sources/SrkToolkit.Web.AspMvc5/Open/SrkOpenGraphHtmlExtensions.cs similarity index 90% rename from Sources/NET4.SrkToolkit.Web/Open/SrkOpenGraphHtmlExtensions.cs rename to Sources/SrkToolkit.Web.AspMvc5/Open/SrkOpenGraphHtmlExtensions.cs index 090a162..ff5d04b 100644 --- a/Sources/NET4.SrkToolkit.Web/Open/SrkOpenGraphHtmlExtensions.cs +++ b/Sources/SrkToolkit.Web.AspMvc5/Open/SrkOpenGraphHtmlExtensions.cs @@ -20,8 +20,15 @@ namespace SrkToolkit.Web.Open using System.Collections.Generic; using System.Linq; using System.Text; + +#if ASPMVCCORE + +#else using System.Web.Mvc; +#endif +#if ASPMVCCORE +#else /// /// TODO: Update summary. /// @@ -34,4 +41,5 @@ public SrkOpenGraphHtmlExtensions(HtmlHelper html) this.html = html; } } +#endif } diff --git a/Sources/NET4.SrkToolkit.Web/SrkRequestExtensions.cs b/Sources/SrkToolkit.Web.AspMvc5/SrkRequestExtensions.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/SrkRequestExtensions.cs rename to Sources/SrkToolkit.Web.AspMvc5/SrkRequestExtensions.cs diff --git a/Sources/SrkToolkit.Web.AspMvc5/SrkToolkit.Web.AspMvc5.csproj b/Sources/SrkToolkit.Web.AspMvc5/SrkToolkit.Web.AspMvc5.csproj new file mode 100644 index 0000000..8fab804 --- /dev/null +++ b/Sources/SrkToolkit.Web.AspMvc5/SrkToolkit.Web.AspMvc5.csproj @@ -0,0 +1,26 @@ + + + + disable + disable + net45;net46 + 9 + + + + + + + + + + + + + + + + + + + diff --git a/Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpContext.cs b/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpContext.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpContext.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpContext.cs diff --git a/Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpRequest.cs b/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpRequest.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpRequest.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpRequest.cs diff --git a/Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpSessionState.cs b/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpSessionState.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Fakes/BasicHttpSessionState.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpSessionState.cs diff --git a/Sources/NET4.SrkToolkit.Web/Filters/AuthorizeAttribute.cs b/Sources/SrkToolkit.Web.AspNetCore2/Filters/AuthorizeAttribute.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Filters/AuthorizeAttribute.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Filters/AuthorizeAttribute.cs diff --git a/Sources/NET4.SrkToolkit.Web/HttpErrors/BaseErrorController.cs b/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BaseErrorController.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/HttpErrors/BaseErrorController.cs rename to Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BaseErrorController.cs diff --git a/Sources/NET4.SrkToolkit.Web/HttpErrors/BasicHttpErrorResponse.cs b/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BasicHttpErrorResponse.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/HttpErrors/BasicHttpErrorResponse.cs rename to Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BasicHttpErrorResponse.cs diff --git a/Sources/NET4.SrkToolkit.Web/HttpErrors/ErrorControllerHandler.cs b/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/ErrorControllerHandler.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/HttpErrors/ErrorControllerHandler.cs rename to Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/ErrorControllerHandler.cs diff --git a/Sources/NET4.SrkToolkit.Web/HttpErrors/IErrorController.cs b/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/IErrorController.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/HttpErrors/IErrorController.cs rename to Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/IErrorController.cs diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Internals.cs b/Sources/SrkToolkit.Web.AspNetCore2/Internals.cs new file mode 100644 index 0000000..2a32da7 --- /dev/null +++ b/Sources/SrkToolkit.Web.AspNetCore2/Internals.cs @@ -0,0 +1,9 @@ + +namespace SrkToolkit.Web +{ + using System; + + internal static class Internals + { + } +} diff --git a/Sources/NET4.SrkToolkit.Web/JsonNetResult.cs b/Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs similarity index 94% rename from Sources/NET4.SrkToolkit.Web/JsonNetResult.cs rename to Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs index 5a0e508..6c24f8c 100644 --- a/Sources/NET4.SrkToolkit.Web/JsonNetResult.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs @@ -16,6 +16,7 @@ namespace SrkToolkit.Web { + using Microsoft.AspNetCore.Mvc; using System; using System.Diagnostics; using System.Runtime.Serialization.Json; @@ -59,7 +60,7 @@ public JsonNetResult() /// /// The JSON serializer. /// - public static Action Serializer { get; set; } + public static Action Serializer { get; set; } /// /// Gets or sets the content encoding. diff --git a/Sources/NET4.SrkToolkit.Web/Models/HttpErrorModel.cs b/Sources/SrkToolkit.Web.AspNetCore2/Models/HttpErrorModel.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Models/HttpErrorModel.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Models/HttpErrorModel.cs diff --git a/Sources/NET4.SrkToolkit.Web/Models/TempMessage.cs b/Sources/SrkToolkit.Web.AspNetCore2/Models/TempMessage.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Models/TempMessage.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Models/TempMessage.cs diff --git a/Sources/NET4.SrkToolkit.Web/Mvc/DecimalModelBinder.cs b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/Mvc/DecimalModelBinder.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs index c91a0c1..ecdee11 100644 --- a/Sources/NET4.SrkToolkit.Web/Mvc/DecimalModelBinder.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs @@ -16,6 +16,8 @@ namespace SrkToolkit.Web.Mvc { + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.ModelBinding; using System; using System.Collections.Generic; using System.Linq; diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Mvc/Dummy.cs b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/Dummy.cs new file mode 100644 index 0000000..bf10d3e --- /dev/null +++ b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/Dummy.cs @@ -0,0 +1,12 @@ + +namespace SrkToolkit.Web.Mvc; + +using System; + +/// +/// Preserve namespace. +/// +public static class Dummy +{ + +} diff --git a/Sources/NET4.SrkToolkit.Web/Mvc/IntegerModelBinder.cs b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/IntegerModelBinder.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Mvc/IntegerModelBinder.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Mvc/IntegerModelBinder.cs diff --git a/Sources/NET4.SrkToolkit.Web/Services/BaseSessionService.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/BaseSessionService.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/Services/BaseSessionService.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/BaseSessionService.cs index 07f589e..03f9054 100644 --- a/Sources/NET4.SrkToolkit.Web/Services/BaseSessionService.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/Services/BaseSessionService.cs @@ -19,7 +19,6 @@ namespace SrkToolkit.Web.Services using System; using System.Collections.Generic; using System.Linq; - using System.Web; /// /// diff --git a/Sources/NET4.SrkToolkit.Web/Services/DictionarySessionServiceSource.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/DictionarySessionServiceSource.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Services/DictionarySessionServiceSource.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/DictionarySessionServiceSource.cs diff --git a/Sources/NET4.SrkToolkit.Web/Services/HttpBaseSessionServiceSource.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/HttpBaseSessionServiceSource.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Services/HttpBaseSessionServiceSource.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/HttpBaseSessionServiceSource.cs diff --git a/Sources/NET4.SrkToolkit.Web/Services/IResultService.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/IResultService.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/Services/IResultService.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/IResultService.cs index cd3f3c9..9e9fca5 100644 --- a/Sources/NET4.SrkToolkit.Web/Services/IResultService.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/Services/IResultService.cs @@ -16,11 +16,11 @@ namespace SrkToolkit.Web.Services { + using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Mvc; /// /// Helps return generic HTTP responses. diff --git a/Sources/NET4.SrkToolkit.Web/Services/ISessionServiceSource.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/ISessionServiceSource.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Services/ISessionServiceSource.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/ISessionServiceSource.cs diff --git a/Sources/NET4.SrkToolkit.Web/Services/ResultService.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/ResultService.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/Services/ResultService.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/ResultService.cs diff --git a/Sources/NET4.SrkToolkit.Web/Services/ResultServiceBase.cs b/Sources/SrkToolkit.Web.AspNetCore2/Services/ResultServiceBase.cs similarity index 94% rename from Sources/NET4.SrkToolkit.Web/Services/ResultServiceBase.cs rename to Sources/SrkToolkit.Web.AspNetCore2/Services/ResultServiceBase.cs index ede399e..3cee128 100644 --- a/Sources/NET4.SrkToolkit.Web/Services/ResultServiceBase.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/Services/ResultServiceBase.cs @@ -16,18 +16,17 @@ namespace SrkToolkit.Web.Services { - using System; - using System.Web; - using System.Web.Mvc; - using System.Web.Routing; + using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Mvc; using SrkToolkit.Web.HttpErrors; + using System; /// /// Helps return generic HTTP responses. /// public class ResultServiceBase { - private readonly HttpContextBase httpContext; + private readonly HttpContext httpContext; public const string RouteDataExceptionKey = "error"; public const string RouteDataMessageKey = "message"; @@ -39,7 +38,7 @@ public class ResultServiceBase /// Initializes a new instance of the class. /// /// The HTTP context. - public ResultServiceBase(HttpContextBase httpContext) + public ResultServiceBase(HttpContext httpContext) { this.httpContext = httpContext; } diff --git a/Sources/NET4.SrkToolkit.Web/SrkControllerExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Web/SrkControllerExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs index fe2f5e2..f2236a8 100644 --- a/Sources/NET4.SrkToolkit.Web/SrkControllerExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs @@ -16,14 +16,13 @@ namespace SrkToolkit.Web { + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Routing; using SrkToolkit.Web.Open; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Caching; - using System.Web.Mvc; - using System.Web.Routing; /// /// Extension methods for the class. @@ -38,7 +37,7 @@ public static class SrkControllerExtensions /// /// The control. /// - public static SrkToolkit.Web.NavigationLine NavigationLine(this Controller ctrl) + public static NavigationLine NavigationLine(this Controller ctrl) { if (ctrl.HttpContext == null) throw new ArgumentNullException("HttpContext is not set", "ctrl"); @@ -52,7 +51,7 @@ public static SrkToolkit.Web.NavigationLine NavigationLine(this Controller ctrl) return line; } - +/* /// /// Gets an item from the HTTP cache. /// @@ -103,7 +102,7 @@ public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheIt return value; } - +*//* /// /// Clears an item from the HTTP cache. /// @@ -148,7 +147,7 @@ public static T ClearFromCache(this Controller ctrl) return null; } - +*/ /// /// Gets a action result that will redirect the user to the specified local path. Fallbacks to a second path. Then fallbacks to /Home/Index /// @@ -177,7 +176,7 @@ public static ActionResult RedirectToLocal(this Controller controller, string lo return new RedirectToRouteResult(values); } } - +/* /// /// Gets the first valid local URL from the method arguments. /// @@ -216,7 +215,7 @@ public static string GetAnyLocalUrl(this Controller controller, string url1, boo return null; } - +*/ /// /// Helps attach descriptors to a page in order to generate meta/link tags. /// diff --git a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkHtmlExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs similarity index 82% rename from Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkHtmlExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs index 20c2e89..274eda3 100644 --- a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkHtmlExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHtmlExtensions.cs @@ -16,15 +16,20 @@ namespace System.Web.Mvc { + using Microsoft.AspNetCore.Html; + using Microsoft.AspNetCore.Mvc.ModelBinding; + using Microsoft.AspNetCore.Mvc.Rendering; + using Microsoft.AspNetCore.Mvc.ViewFeatures; + using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; + using Microsoft.AspNetCore.Routing; + using SrkToolkit.AspNetCore; + using SrkToolkit.Web; + using SrkToolkit.Web.Open; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; - using System.Web.Mvc.Html; - using System.Web.Routing; - using SrkToolkit.Web.Open; - using SrkToolkit.Web; using System.Globalization; /// @@ -57,7 +62,7 @@ public static class SrkHtmlExtensions /// /// /// - public static HtmlHelper SetTimezone(this HtmlHelper html, string timeZoneName) + public static IHtmlHelper SetTimezone(this IHtmlHelper html, string timeZoneName) { if (string.IsNullOrEmpty(timeZoneName)) throw new ArgumentException("The value cannot be empty", "timeZoneName"); @@ -73,7 +78,7 @@ public static HtmlHelper SetTimezone(this HtmlHelper html, string timeZoneName) /// The time zone. /// /// - public static HtmlHelper SetTimezone(this HtmlHelper html, TimeZoneInfo timeZone) + public static IHtmlHelper SetTimezone(this IHtmlHelper html, TimeZoneInfo timeZone) { if (html == null) throw new ArgumentNullException("html"); @@ -90,7 +95,7 @@ public static HtmlHelper SetTimezone(this HtmlHelper html, TimeZoneInfo timeZone /// The HTML. /// /// html - public static TimeZoneInfo GetTimezone(this HtmlHelper html) + public static TimeZoneInfo GetTimezone(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); @@ -107,7 +112,7 @@ public static TimeZoneInfo GetTimezone(this HtmlHelper html) /// The date. /// The specified in the UTC time zone. /// The specified in the user's time zone. - public static DateTime GetUserDate(this HtmlHelper html, DateTime date, out DateTime utcDate) + public static DateTime GetUserDate(this IHtmlHelper html, DateTime date, out DateTime utcDate) { var tz = html.GetTimezone(); if (date.Kind == DateTimeKind.Utc) @@ -137,7 +142,7 @@ public static DateTime GetUserDate(this HtmlHelper html, DateTime date, out Date /// The date. /// The specified in the UTC time zone. /// DateTime.Kind ' + date.Kind + ' is not supported - public static DateTime GetUtcDate(this HtmlHelper html, DateTime date) + public static DateTime GetUtcDate(this IHtmlHelper html, DateTime date) { if (date.Kind == DateTimeKind.Utc) { @@ -164,7 +169,7 @@ public static DateTime GetUtcDate(this HtmlHelper html, DateTime date) /// /// /// - public static HtmlHelper SetCulture(this HtmlHelper html, string culture) + public static IHtmlHelper SetCulture(this IHtmlHelper html, string culture) { if (string.IsNullOrEmpty(culture)) throw new ArgumentException("The value cannot be empty", "culture"); @@ -180,7 +185,7 @@ public static HtmlHelper SetCulture(this HtmlHelper html, string culture) /// The culture. /// /// - public static HtmlHelper SetCulture(this HtmlHelper html, CultureInfo culture) + public static IHtmlHelper SetCulture(this IHtmlHelper html, CultureInfo culture) { if (html == null) throw new ArgumentNullException("html"); @@ -197,7 +202,7 @@ public static HtmlHelper SetCulture(this HtmlHelper html, CultureInfo culture) /// The HTML. /// /// html - public static CultureInfo GetCulture(this HtmlHelper html) + public static CultureInfo GetCulture(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); @@ -215,7 +220,7 @@ public static CultureInfo GetCulture(this HtmlHelper html) /// /// /// - public static HtmlHelper SetUICulture(this HtmlHelper html, string uICulture) + public static IHtmlHelper SetUICulture(this IHtmlHelper html, string uICulture) { if (string.IsNullOrEmpty(uICulture)) throw new ArgumentException("The value cannot be empty", "culture"); @@ -231,7 +236,7 @@ public static HtmlHelper SetUICulture(this HtmlHelper html, string uICulture) /// The culture. /// /// - public static HtmlHelper SetUICulture(this HtmlHelper html, CultureInfo uICulture) + public static IHtmlHelper SetUICulture(this IHtmlHelper html, CultureInfo uICulture) { if (html == null) throw new ArgumentNullException("html"); @@ -248,7 +253,7 @@ public static HtmlHelper SetUICulture(this HtmlHelper html, CultureInfo uICultur /// The HTML. /// /// html - public static CultureInfo GetUICulture(this HtmlHelper html) + public static CultureInfo GetUICulture(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); @@ -259,7 +264,7 @@ public static CultureInfo GetUICulture(this HtmlHelper html) } #region Display date/time - +/* /// /// Sets the date and time formats. /// @@ -278,7 +283,7 @@ public static CultureInfo GetUICulture(this HtmlHelper html) /// html.ViewContext /// or /// html.ViewContext.HttpContext - public static HtmlHelper SetDateTimeFormats(this HtmlHelper html, string dateFormat = null, string dateTzFormat = null, string timeFormat = null, string timeTzFormat = null, string timespanFormat = null, string dateTimeFormat = null, string shortTimeFormat = null, string shortTimespanFormat = null) + public static IHtmlHelper SetDateTimeFormats(this IHtmlHelper html, string dateFormat = null, string dateTzFormat = null, string timeFormat = null, string timeTzFormat = null, string timespanFormat = null, string dateTimeFormat = null, string shortTimeFormat = null, string shortTimespanFormat = null) { if (html == null) throw new ArgumentNullException("html"); @@ -292,7 +297,7 @@ public static HtmlHelper SetDateTimeFormats(this HtmlHelper html, string dateFor return html; } - +*/ /// /// Gets the date and time formats. /// @@ -305,7 +310,7 @@ public static HtmlHelper SetDateTimeFormats(this HtmlHelper html, string dateFor /// or /// html.ViewContext.HttpContext /// - public static string[] GetDateTimeFormats(this HtmlHelper html) + public static string[] GetDateTimeFormats(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); @@ -328,7 +333,7 @@ public static string[] GetDateTimeFormats(this HtmlHelper html) /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayDateTime(this HtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayDateTime(this IHtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { var defaultFormat = html.GetDateTimeFormats()[5]; DateTime utc; @@ -345,11 +350,11 @@ public static MvcHtmlString DisplayDateTime(this HtmlHelper html, DateTime date, utc.ToString("O"), userDate.ToString("G"), GetDateClasses(utc) + "display-datetime"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -385,7 +390,7 @@ private static string GetDateClasses(DateTimeOffset date) /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayDate(this IHtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { DateTime utc; DateTime userDate = html.GetUserDate(date, out utc); @@ -402,11 +407,11 @@ public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTime date, boo utc.ToString("O"), userDate.ToString("D"), GetDateClasses(utc) + "display-date"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -419,7 +424,7 @@ public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTime date, boo /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTimeOffset date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayDate(this IHtmlHelper html, DateTimeOffset date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { var defaultFormat = html.GetDateTimeFormats()[1]; string displayTime = date.ToString(displayDateFormat ?? defaultFormat); @@ -434,11 +439,11 @@ public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTimeOffset dat date.ToUniversalTime().ToString("O"), date.ToString("D zzz"), GetDateClasses(date) + "display-date"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -451,7 +456,7 @@ public static MvcHtmlString DisplayDate(this HtmlHelper html, DateTimeOffset dat /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayTime(this IHtmlHelper html, DateTime date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { DateTime utc; DateTime userDate = html.GetUserDate(date, out utc); @@ -468,11 +473,11 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTime date, boo utc.ToString("O"), userDate.ToString("G"), GetDateClasses(utc) + "display-time"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -485,7 +490,7 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTime date, boo /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTimeOffset date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayTime(this IHtmlHelper html, DateTimeOffset date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { var defaultFormat = html.GetDateTimeFormats()[3]; string displayTime = date.ToLocalTime().ToString(displayDateFormat ?? defaultFormat); @@ -500,11 +505,11 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTimeOffset dat date.ToUniversalTime().ToString("O"), date.ToString("R"), GetDateClasses(date) + "display-time"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -517,7 +522,7 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, DateTimeOffset dat /// The display value (use to manualy set the display value). /// The display date format (use to change the default display value format). /// - public static MvcHtmlString DisplayTime(this HtmlHelper html, TimeSpan date, bool useTimeTag = true, string display = null, string displayDateFormat = null) + public static HtmlString DisplayTime(this IHtmlHelper html, TimeSpan date, bool useTimeTag = true, string display = null, string displayDateFormat = null) { var defaultFormat = html.GetDateTimeFormats()[4]; string displayTime = date.ToString(displayDateFormat ?? defaultFormat); @@ -532,11 +537,11 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, TimeSpan date, boo date.ToString("c"), date.ToString("c"), "display-time"); - return MvcHtmlString.Create(tag); + return new HtmlString(tag); } else { - return MvcHtmlString.Create(display); + return new HtmlString(display); } } @@ -547,7 +552,7 @@ public static MvcHtmlString DisplayTime(this HtmlHelper html, TimeSpan date, boo /// The date. /// The precision. /// - public static MvcHtmlString JsDate(this HtmlHelper html, DateTime date, DateTimePrecision precision = DateTimePrecision.Second) + public static HtmlString JsDate(this IHtmlHelper html, DateTime date, DateTimePrecision precision = DateTimePrecision.Second) { DateTime utc = SrkHtmlExtensions.GetUtcDate(html, date); /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date @@ -562,7 +567,7 @@ public static MvcHtmlString JsDate(this HtmlHelper html, DateTime date, DateTime string value = "new Date(" + (utc.ToPrecision(precision).Subtract(UnixEpoch).TotalMilliseconds).ToString("F0") + ")"; - return MvcHtmlString.Create(value); + return new HtmlString(value); } /// @@ -573,7 +578,7 @@ public static MvcHtmlString JsDate(this HtmlHelper html, DateTime date, DateTime /// if set to true the date will be enclsoed in a <time> tag. /// The display value (use to manualy set the display value). /// - public static MvcHtmlString DisplayShortTime(this HtmlHelper html, DateTime date, bool useTimeTag = true, string display = null) + public static HtmlString DisplayShortTime(this IHtmlHelper html, DateTime date, bool useTimeTag = true, string display = null) { var defaultFormat = html.GetDateTimeFormats()[6]; return html.DisplayTime(date, useTimeTag, display, displayDateFormat: defaultFormat); @@ -587,7 +592,7 @@ public static MvcHtmlString DisplayShortTime(this HtmlHelper html, DateTime date /// if set to true the date will be enclsoed in a <time> tag. /// The display value (use to manualy set the display value). /// - public static MvcHtmlString DisplayShortTime(this HtmlHelper html, TimeSpan date, bool useTimeTag = true, string display = null) + public static HtmlString DisplayShortTime(this IHtmlHelper html, TimeSpan date, bool useTimeTag = true, string display = null) { var defaultFormat = html.GetDateTimeFormats()[7]; return html.DisplayTime(date, useTimeTag, display, displayDateFormat: defaultFormat); @@ -606,10 +611,10 @@ public static MvcHtmlString DisplayShortTime(this HtmlHelper html, TimeSpan date /// The class attribute to associate to <a> tags (defaults to "external"). /// The target attribute to associate to <a> tags (default to "_blank"). /// - public static MvcHtmlString LineBreaks(this HtmlHelper html, string content, bool makeLinks = false, string linkClasses = "external accentColor", string linkTarget = "_self") + public static HtmlString LineBreaks(this IHtmlHelper html, string content, bool makeLinks = false, string linkClasses = "external accentColor", string linkTarget = "_self") { if (content == null) - return MvcHtmlString.Create(string.Empty); + return new HtmlString(string.Empty); content = content.ProperHtmlEscape(); @@ -620,7 +625,7 @@ public static MvcHtmlString LineBreaks(this HtmlHelper html, string content, boo content = content.AddHtmlLineBreaks(); - return MvcHtmlString.Create(content); + return new HtmlString(content); } /// @@ -631,7 +636,7 @@ public static MvcHtmlString LineBreaks(this HtmlHelper html, string content, boo /// The number of characters desired. /// The ending string (used only if trim occured). /// - public static string TrimText(this HtmlHelper html, string text, int chars, string ending = "...") + public static string TrimText(this IHtmlHelper html, string text, int chars, string ending = "...") { return text.TrimTextRight(chars, ending); } @@ -654,10 +659,10 @@ public static string TrimText(this HtmlHelper html, string text, int chars, stri /// /// an escaped HTML string /// - public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bool makeLinks = true, bool makeParagraphs = true, bool makeLineBreaks = true, bool twitterLinks = false, string linksClass = "external", string linksTarget = "_blank", string wrapClass = null) + public static HtmlString DisplayText(this IHtmlHelper html, string content, bool makeLinks = true, bool makeParagraphs = true, bool makeLineBreaks = true, bool twitterLinks = false, string linksClass = "external", string linksTarget = "_blank", string wrapClass = null) { if (content == null) - return MvcHtmlString.Create(string.Empty); + return new HtmlString(string.Empty); content = content.ProperHtmlEscape(); @@ -673,15 +678,15 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo content = content.AddHtmlLineBreaks(); if (wrapClass == null) - return MvcHtmlString.Create(content); + return new HtmlString(content); else - return MvcHtmlString.Create("
" + content + "
"); + return new HtmlString("
" + content + "
"); } #endregion #endregion - +/* /// /// Returns many HTML radio buttons for the specified list and selected value. /// @@ -691,12 +696,12 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo /// The model expression. /// The list of values. /// - public static MvcHtmlString RadioButtonSelectList( - this HtmlHelper htmlHelper, + public static HtmlString RadioButtonSelectList( + this IHtmlHelper IHtmlHelper, Expression> expression, IEnumerable listOfValues) { - var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData); + var metaData = ModelMetadata.FromLambdaExpression(expression, IHtmlHelper.ViewData); var sb = new StringBuilder(); if (listOfValues != null) @@ -709,8 +714,8 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo var id = metaData.PropertyName + "_" + item.Value; // Create and populate a radio button using the existing html helpers - var label = htmlHelper.Label(id, HttpUtility.HtmlEncode(item.Text)); - var radio = htmlHelper.RadioButtonFor(expression, item.Value, new { id = id }).ToHtmlString(); + var label = IHtmlHelper.Label(id, HttpUtility.HtmlEncode(item.Text)); + var radio = IHtmlHelper.RadioButtonFor(expression, item.Value, new { id = id }).ToHtmlString(); // Create the html string that will be returned to the client // e.g. @@ -718,32 +723,32 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo } } - return MvcHtmlString.Create(sb.ToString()); + return new HtmlString(sb.ToString()); } - +*/ #region GetFullHtmlFieldName - public static string GetFullHtmlFieldName(this HtmlHelper helper, Expression> expression) + public static string GetFullHtmlFieldName(this IHtmlHelper helper, Expression> expression) { return helper.ViewData.TemplateInfo.GetFullHtmlFieldName(expression); } - - public static string GetFullHtmlFieldId(this HtmlHelper helper, Expression> expression) +/* + public static string GetFullHtmlFieldId(this IHtmlHelper helper, Expression> expression) { return helper.ViewData.TemplateInfo.GetFullHtmlFieldId(expression); } - +*/ public static string GetFullHtmlFieldName(this TemplateInfo templateInfo, Expression> expression) { return templateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression)); } - +/* public static string GetFullHtmlFieldId(this TemplateInfo templateInfo, Expression> expression) { return templateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression)); } - - public static string GetFullHtmlFieldDisplayName(this HtmlHelper helper, Expression> expression) +*/ + public static string GetFullHtmlFieldDisplayName(this IHtmlHelper helper, Expression> expression) { var propertyName = helper.GetFullHtmlFieldName(expression); @@ -754,6 +759,7 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo #region DescriptionFor +/* /// /// Returns an HTML span element and the property name of the property that is represented by the specified expression. /// @@ -762,13 +768,12 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo /// The HTML helper instance that this method extends. /// An expression that identifies the property to display. /// An HTML span element and the property name of the property that is represented by the specified expression - public static MvcHtmlString DescriptionFor( - this HtmlHelper helper, + public static HtmlString DescriptionFor( + this IHtmlHelper helper, Expression> expression) { return DescriptionFor(helper, expression, null, null); } - /// /// Returns an HTML span element and the property name of the property that is represented by the specified expression. /// @@ -780,8 +785,8 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo /// /// An HTML span element and the property name of the property that is represented by the specified expression /// - public static MvcHtmlString DescriptionFor( - this HtmlHelper helper, + public static HtmlString DescriptionFor( + this IHtmlHelper helper, Expression> expression, object htmlAttributes) { @@ -799,14 +804,14 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo /// /// An HTML span element and the property name of the property that is represented by the specified expression /// - public static MvcHtmlString DescriptionFor( - this HtmlHelper helper, + public static HtmlString DescriptionFor( + this IHtmlHelper helper, Expression> expression, IDictionary htmlAttributes) { return DescriptionFor(helper, expression, null, htmlAttributes); } - +*//* /// /// Returns an HTML span element and the property name of the property that is represented by the specified expression. /// @@ -819,8 +824,8 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo /// /// An HTML span element and the property name of the property that is represented by the specified expression /// - public static MvcHtmlString DescriptionFor( - this HtmlHelper helper, + public static HtmlString DescriptionFor( + this IHtmlHelper helper, Expression> expression, string descriptionText, IDictionary htmlAttributes) @@ -829,31 +834,32 @@ public static MvcHtmlString DisplayText(this HtmlHelper html, string content, bo var value = descriptionText.NullIfEmpty() ?? meta.Description.NullIfEmpty(); if (string.IsNullOrEmpty(value)) - return MvcHtmlString.Empty; + return HtmlString.Empty; var htmlFieldName = ExpressionHelper.GetExpressionText(expression); var id = TagBuilder.CreateSanitizedId(helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName)); var tag = new TagBuilder("span"); tag.Attributes.Add("data-for", id); tag.MergeAttributes(htmlAttributes, true); - tag.SetInnerText(value); + ////tag.SetInnerText(value); // AspNet + tag.InnerHtml.Append(value); // AspNetCore? return tag.ToMvcHtmlString(TagRenderMode.Normal); } - +*/ #endregion #region BeginFormEx - +/* /// /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. /// /// The HTML helper. /// An object that contains the HTML attributes to set for the element. /// An opening <form> tag. - public static MvcForm BeginFormEx(this HtmlHelper htmlHelper, object htmlAttributes) + public static MvcForm BeginFormEx(this IHtmlHelper IHtmlHelper, object htmlAttributes) { - string rawUrl = htmlHelper.ViewContext.HttpContext.Request.RawUrl; - return htmlHelper.BeginForm(null, null, htmlHelper.ViewContext.RouteData.Values, FormMethod.Post, new RouteValueDictionary(htmlAttributes) as IDictionary); + string rawUrl = IHtmlHelper.ViewContext.HttpContext.Request.RawUrl; + return IHtmlHelper.BeginForm(null, null, IHtmlHelper.ViewContext.RouteData.Values, FormMethod.Post, new RouteValueDictionary(htmlAttributes) as IDictionary); } /// @@ -863,28 +869,28 @@ public static MvcForm BeginFormEx(this HtmlHelper htmlHelper, object htmlAttribu /// An object that contains the HTML attributes to set for the element. /// An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax. /// An opening <form> tag. - public static MvcForm BeginFormEx(this HtmlHelper htmlHelper, object htmlAttributes, object routeValues) + public static MvcForm BeginFormEx(this IHtmlHelper IHtmlHelper, object htmlAttributes, object routeValues) { - string rawUrl = htmlHelper.ViewContext.HttpContext.Request.RawUrl; - return htmlHelper.BeginForm(null, null, routeValues, FormMethod.Post, htmlAttributes); + string rawUrl = IHtmlHelper.ViewContext.HttpContext.Request.RawUrl; + return IHtmlHelper.BeginForm(null, null, routeValues, FormMethod.Post, htmlAttributes); } - +*/ #endregion #region Submit - +/* /// /// Returns a submit input element by using the specified HTML helper and the name of the form field. /// /// The HTML. /// The value. /// An input element whose type attribute is set to "submit". - public static MvcHtmlString Submit(this HtmlHelper html, string value) + public static HtmlString Submit(this IHtmlHelper html, string value) { var builder = new TagBuilder("input"); builder.MergeAttribute("type", "submit"); builder.MergeAttribute("value", value); - return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); } /// @@ -894,13 +900,13 @@ public static MvcHtmlString Submit(this HtmlHelper html, string value) /// The value. /// The name. /// An input element whose type attribute is set to "submit". - public static MvcHtmlString Submit(this HtmlHelper html, string value, string name) + public static HtmlString Submit(this IHtmlHelper html, string value, string name) { var builder = new TagBuilder("input"); builder.MergeAttribute("type", "submit"); builder.MergeAttribute("name", name); builder.MergeAttribute("value", value); - return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); } /// @@ -911,7 +917,7 @@ public static MvcHtmlString Submit(this HtmlHelper html, string value, string na /// The name. /// An object that contains the HTML attributes to set for the element. /// An input element whose type attribute is set to "submit". - public static MvcHtmlString Submit(this HtmlHelper html, string value, string name, object htmlAttributes) + public static HtmlString Submit(this IHtmlHelper html, string value, string name, object htmlAttributes) { var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); var builder = new TagBuilder("input"); @@ -919,25 +925,25 @@ public static MvcHtmlString Submit(this HtmlHelper html, string value, string na builder.MergeAttribute("type", "submit"); builder.MergeAttribute("name", name); builder.MergeAttribute("value", value); - return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); } - +*/ #endregion #region File - +/* /// /// Returns a file input element by using the specified HTML helper and the name of the form field. /// /// The HTML. /// The name. /// An input element whose type attribute is set to "file". - public static MvcHtmlString File(this HtmlHelper html, string name) + public static HtmlString File(this IHtmlHelper html, string name) { var builder = new TagBuilder("input"); builder.MergeAttribute("type", "file"); builder.MergeAttribute("name", name); - return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); } /// @@ -947,34 +953,34 @@ public static MvcHtmlString File(this HtmlHelper html, string name) /// The name. /// An object that contains the HTML attributes to set for the element. /// An input element whose type attribute is set to "file". - public static MvcHtmlString File(this HtmlHelper html, string name, object htmlAttributes) + public static HtmlString File(this IHtmlHelper html, string name, object htmlAttributes) { var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); var builder = new TagBuilder("input"); builder.MergeAttributes(attributes); builder.MergeAttribute("type", "file"); builder.MergeAttribute("name", name); - return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing)); + return new HtmlString(builder.ToString(TagRenderMode.SelfClosing)); } - +*/ #endregion #region OpenGraph - +/* /// /// Gets the opengraph object associated with the current HTTP request. /// /// /// - public static SrkOpenGraphHtmlExtensions OpenGraph(this HtmlHelper html) + public static SrkOpenGraphHtmlExtensions OpenGraph(this IHtmlHelper html) { return new SrkOpenGraphHtmlExtensions(html); } - +*/ #endregion #region ActionLink - +/* /// /// Returns an anchor element (a element) that contains the virtual path of the specified action. /// @@ -988,11 +994,11 @@ public static SrkOpenGraphHtmlExtensions OpenGraph(this HtmlHelper html) /// The protocol for the URL, such as "http" or "https". /// The host name for the URL. /// - public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes = null, string fragment = null, string controllerName = null, string protocol = null, string hostName = null) + public static HtmlString ActionLink(this IHtmlHelper IHtmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes = null, string fragment = null, string controllerName = null, string protocol = null, string hostName = null) { - return htmlHelper.ActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes); + return IHtmlHelper.ActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes); } - +*/ #endregion /// @@ -1003,7 +1009,7 @@ public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkTe /// The class to display if the condition is true. /// The class to display if the condition is false. /// The CSS class corresponding to the condition - public static string CssClass(this HtmlHelper html, bool condition, string classTrue, string classFalse = null) + public static string CssClass(this IHtmlHelper html, bool condition, string classTrue, string classFalse = null) { return condition ? classTrue : classFalse; } @@ -1017,7 +1023,7 @@ public static string CssClass(this HtmlHelper html, bool condition, string class /// The class to display if the condition is false. /// The class to display if the condition is null. /// The CSS class corresponding to the condition - public static string CssClass(this HtmlHelper html, bool? condition, string classTrue, string classFalse = null, string classNull = null) + public static string CssClass(this IHtmlHelper html, bool? condition, string classTrue, string classFalse = null, string classNull = null) { if (condition != null) return condition.Value ? classTrue : classFalse; @@ -1030,7 +1036,7 @@ public static string CssClass(this HtmlHelper html, bool? condition, string clas /// The HTML. /// /// html - public static bool HasOtherValidationErrors(this HtmlHelper html) + public static bool HasOtherValidationErrors(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); @@ -1049,13 +1055,13 @@ public static bool HasOtherValidationErrors(this HtmlHelper html) return html.ViewData.ModelState[string.Empty].Errors.Count > 0; } - +/* /// /// Enhancement of that shows no HTML when there are no errors to display. /// /// The HTML. /// A string that contains an unordered list (ul element) of validation messages. - public static MvcHtmlString ValidationSummaryEx(this HtmlHelper html) + public static HtmlString ValidationSummaryEx(this IHtmlHelper html) { if (SrkHtmlExtensions.HasOtherValidationErrors(html)) { @@ -1064,13 +1070,13 @@ public static MvcHtmlString ValidationSummaryEx(this HtmlHelper html) return null; } - +*/ /// /// Gets the associated to the request. /// /// The HTML. /// - public static SrkToolkit.Web.NavigationLine NavigationLine(this HtmlHelper html) + public static NavigationLine NavigationLine(this IHtmlHelper html) { if (html.ViewContext == null) throw new ArgumentNullException("ViewContext is not set", "ctrl"); @@ -1087,18 +1093,18 @@ public static SrkToolkit.Web.NavigationLine NavigationLine(this HtmlHelper html) return line; } - +/* /// /// Returns an anchor element (a element) that contains a phone call url. /// /// The HTML. /// The phone number. /// - public static MvcHtmlString CallLink(this HtmlHelper html, string phoneNumber) + public static HtmlString CallLink(this IHtmlHelper html, string phoneNumber) { return SrkHtmlExtensions.CallLink(html, phoneNumber, new { @class = "tel", }); } - +*//* /// /// Returns an anchor element (a element) that contains a phone call url. /// @@ -1106,23 +1112,24 @@ public static MvcHtmlString CallLink(this HtmlHelper html, string phoneNumber) /// The phone number. /// An object that contains the HTML attributes for the element. /// - public static MvcHtmlString CallLink(this HtmlHelper html, string phoneNumber, object attributes) + public static HtmlString CallLink(this IHtmlHelper html, string phoneNumber, object attributes) { var tag = new TagBuilder("a"); tag.Attributes.Add("href", "tel:" + phoneNumber); var attrCollection = HtmlHelper.AnonymousObjectToHtmlAttributes(attributes); tag.MergeAttributes(attrCollection, true); - tag.SetInnerText(phoneNumber); + ////tag.SetInnerText(phoneNumber); // AspNet + tag.InnerHtml.Append(phoneNumber); // AspNetCore? return tag.ToMvcHtmlString(TagRenderMode.Normal); } - +*/ /// /// Helps attach descriptors to a page in order to generate meta/link tags. /// /// The HTML. /// The for the current request. /// html or html.ViewContext or html.ViewContext.HttpContext - public static PageInfo GetPageInfo(this HtmlHelper html) + public static PageInfo GetPageInfo(this IHtmlHelper html) { if (html == null) throw new ArgumentNullException("html"); diff --git a/Sources/NET4.SrkToolkit.Web/SrkHttpApplication.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/SrkHttpApplication.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.cs diff --git a/Sources/NET4.SrkToolkit.Web/SrkHttpApplication.tt b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.tt similarity index 100% rename from Sources/NET4.SrkToolkit.Web/SrkHttpApplication.tt rename to Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.tt diff --git a/Sources/NET4.SrkToolkit.Web/SrkHttpApplication.tt.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.tt.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/SrkHttpApplication.tt.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkHttpApplication.tt.cs diff --git a/Sources/NET4.SrkToolkit.Web/SrkHttpContextExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/SrkHttpContextExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs index f38f5b5..074c782 100644 --- a/Sources/NET4.SrkToolkit.Web/SrkHttpContextExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs @@ -16,12 +16,12 @@ namespace SrkToolkit.Web { + using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; - using System.Web; /// /// Extension methods for the and classes. @@ -41,7 +41,7 @@ public static string GetUserIdentityName(this HttpContext httpContext) return httpContext.User != null && httpContext.User.Identity != null ? httpContext.User.Identity.Name.NullIfEmptyOrWhitespace() : null; } - +/* /// /// Fast access to HttpContext.User.Identity.Name. /// @@ -55,7 +55,7 @@ public static string GetUserIdentityName(this HttpContextBase httpContext) return httpContext.User != null && httpContext.User.Identity != null ? httpContext.User.Identity.Name.NullIfEmptyOrWhitespace() : null; } - +*//* /// /// Sets the timezone for displays of dates and times. /// @@ -72,7 +72,7 @@ public static HttpContextBase SetTimezone(this HttpContextBase http, string time SrkHttpContextExtensions.SetTimezone(http, TimeZoneInfo.FindSystemTimeZoneById(timeZoneName)); return http; } - +*//* /// /// Sets the timezone for displays of dates and times. /// @@ -88,7 +88,7 @@ public static HttpContextBase SetTimezone(this HttpContextBase http, TimeZoneInf http.Items["Timezone"] = timeZone; return http; } - +*/ /// /// Sets the timezone for displays of dates and times. /// @@ -121,7 +121,7 @@ public static HttpContext SetTimezone(this HttpContext http, TimeZoneInfo timeZo http.Items["Timezone"] = timeZone; return http; } - +/* /// /// Gets the timezone for displays of dates and times. /// @@ -135,7 +135,7 @@ public static TimeZoneInfo GetTimezone(this HttpContextBase http) return (TimeZoneInfo)http.Items["Timezone"] ?? TimeZoneInfo.Utc; } - +*/ /// /// Gets the timezone for displays of dates and times. /// @@ -149,7 +149,7 @@ public static TimeZoneInfo GetTimezone(this HttpContext http) return (TimeZoneInfo)http.Items["Timezone"] ?? TimeZoneInfo.Utc; } - +/* /// /// Sets the culture. /// @@ -173,7 +173,7 @@ public static HttpContextBase SetCulture(this HttpContextBase http, string cultu http.Items["Culture"] = cultureInfo; return http; } - +*/ /// /// Sets the culture. /// @@ -197,7 +197,7 @@ public static HttpContext SetCulture(this HttpContext http, string culture) http.Items["Culture"] = cultureInfo; return http; } - +/* /// /// Sets the culture. /// @@ -213,7 +213,7 @@ public static HttpContextBase SetCulture(this HttpContextBase http, CultureInfo http.Items["Culture"] = culture; return http; } - +*/ /// /// Sets the culture. /// @@ -229,7 +229,7 @@ public static HttpContext SetCulture(this HttpContext http, CultureInfo culture) http.Items["Culture"] = culture; return http; } - +/* /// /// Gets the current culture. /// @@ -243,7 +243,7 @@ public static CultureInfo GetCulture(this HttpContextBase http) return (CultureInfo)http.Items["Culture"] ?? CultureInfo.CurrentCulture; } - +*/ /// /// Gets the current culture. /// @@ -257,7 +257,7 @@ public static CultureInfo GetCulture(this HttpContext http) return (CultureInfo)http.Items["Culture"] ?? CultureInfo.CurrentCulture; } - +/* /// /// Sets the UICulture. /// @@ -281,7 +281,7 @@ public static HttpContextBase SetUICulture(this HttpContextBase http, string uIC http.Items["UICulture"] = cultureInfo; return http; } - +*/ /// /// Sets the UICulture. /// @@ -305,7 +305,7 @@ public static HttpContext SetUICulture(this HttpContext http, string uICulture) http.Items["UICulture"] = cultureInfo; return http; } - +/* /// /// Sets the UICulture. /// @@ -321,7 +321,7 @@ public static HttpContextBase SetUICulture(this HttpContextBase http, CultureInf http.Items["UICulture"] = uICulture; return http; } - +*/ /// /// Sets the UICulture. /// @@ -337,7 +337,7 @@ public static HttpContext SetUICulture(this HttpContext http, CultureInfo uICult http.Items["UICulture"] = uICulture; return http; } - +/* /// /// Gets the current UICulture. /// @@ -351,7 +351,7 @@ public static CultureInfo GetUICulture(this HttpContextBase http) return (CultureInfo)http.Items["UICulture"] ?? CultureInfo.CurrentUICulture; } - +*/ /// /// Gets the current UICulture. /// @@ -365,7 +365,7 @@ public static CultureInfo GetUICulture(this HttpContext http) return (CultureInfo)http.Items["UICulture"] ?? CultureInfo.CurrentUICulture; } - +/* /// /// Sets the date and time formats. /// @@ -438,7 +438,7 @@ public static void SetDateTimeFormats(this HttpContextBase httpContext, string d httpContext.Items[System.Web.Mvc.SrkHtmlExtensions.defaultDateTimeFormatsKey] = values; } - +*//* /// /// Gets the date and time formats. /// @@ -455,5 +455,6 @@ public static string[] GetDateTimeFormats(this HttpContextBase httpContext) return values; } +*/ } } diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs new file mode 100644 index 0000000..ab17355 --- /dev/null +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs @@ -0,0 +1,48 @@ + +namespace SrkToolkit.AspNetCore +{ + using Microsoft.AspNetCore.Http; + using System; + using System.Diagnostics; + using System.Linq; + using System.Net.Http; + + public static class SrkHttpRequestExtensions + { + public static bool PrefersJson(this HttpRequestMessage request) + { + if (request.Headers.Accept.Any()) + { + foreach (var header in request.Headers.Accept) + { + if ("application/json".Equals(header.MediaType, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + + return false; + } + + // TODO: support HttpRequest.PrefersJson, but which nuget? +#if !NETSTANDARD + public static bool PrefersJson(this HttpRequest request) + { + Debug.Assert(request != null, nameof(request) + " != null"); + if (request.Headers.Accept.Any()) + { + foreach (var header in request.Headers.Accept) + { + if ("application/json".Equals(header, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + + return false; + } +#endif + } +} diff --git a/Sources/NET4.SrkToolkit.Web/SrkTempDataDictionaryExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/SrkTempDataDictionaryExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs index 4cfdfd7..80aba8f 100644 --- a/Sources/NET4.SrkToolkit.Web/SrkTempDataDictionaryExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs @@ -16,9 +16,9 @@ namespace SrkToolkit.Web { - using System.Collections.Generic; - using System.Web.Mvc; + using Microsoft.AspNetCore.Mvc.ViewFeatures; using SrkToolkit.Web.Models; + using System.Collections.Generic; /// /// Extensions methods for . diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj b/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj new file mode 100644 index 0000000..f4d3d31 --- /dev/null +++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj @@ -0,0 +1,131 @@ + + + + netstandard2.0 + enable + default + SrkToolkit.Web.AspNetCore2 + true + 2.0.0-preview1 + SandRock + SrkToolkit.Web.AspNetCore2 is a bunch of extensions and tools to use with your ASP MVC Core project. + https://github.com/sandrock/SrkToolkit/ + https://github.com/sandrock/SrkToolkit/blob/master/LICENSE + SrkToolkit AspMvc AspMvcCore MVC Html NavigationLine TempData TempMessage WebDependencies AuthorizeAttribute OpenGraph DisplayDate DisplayTime + 2.0.0.0 + 2.0.0.0 + true + ..\SrkToolkit.snk + + + + TRACE;ASPMVCCORE + + + + TRACE;ASPMVCCORE + + + + + SrkToolkit.snk + + + + + + + + + + + + + + + + + + + + Open\NavigationLine.cs + + + Open\NavigationLineEntry.cs + + + Open\OpenGraphName.cs + + + Open\OpenGraphNamespace.cs + + + Open\OpenGraphObject.cs + + + Open\OpenGraphTag.cs + + + Open\PageInfo.cs + + + Open\PageInfoItem.cs + + + Open\PageInfoObject.cs + + + Open\SrkOpenGraphHtmlExtensions.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkMvcCollectionExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkMvcCollectionExtensions.cs similarity index 95% rename from Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkMvcCollectionExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkMvcCollectionExtensions.cs index 7861b6d..11b7906 100644 --- a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkMvcCollectionExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkMvcCollectionExtensions.cs @@ -16,11 +16,11 @@ namespace System.Web.Mvc { + using Microsoft.AspNetCore.Mvc.Rendering; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Mvc; /// /// Extension methods for the interface within MVC views. diff --git a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkTagBuilderExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkTagBuilderExtensions.cs similarity index 79% rename from Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkTagBuilderExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkTagBuilderExtensions.cs index f06c98a..a00e108 100644 --- a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkTagBuilderExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkTagBuilderExtensions.cs @@ -16,11 +16,12 @@ namespace System.Web.Mvc { + using Microsoft.AspNetCore.Html; + using Microsoft.AspNetCore.Mvc.Rendering; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Mvc; /// /// Extension methods for the class. @@ -34,9 +35,9 @@ public static class SrkTagBuilderExtensions /// The tag builder. /// The render mode. /// - public static MvcHtmlString ToMvcHtmlString(this TagBuilder tagBuilder, TagRenderMode renderMode) + public static HtmlString ToMvcHtmlString(this TagBuilder tagBuilder, TagRenderMode renderMode) { - return new MvcHtmlString(tagBuilder.ToString(renderMode)); + return new HtmlString(tagBuilder.ToString(renderMode)); } #endif } diff --git a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkUrlHelperExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkUrlHelperExtensions.cs similarity index 97% rename from Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkUrlHelperExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkUrlHelperExtensions.cs index 7144f7a..91b49f2 100644 --- a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkUrlHelperExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkUrlHelperExtensions.cs @@ -16,6 +16,7 @@ namespace System.Web.Mvc { + using Microsoft.AspNetCore.Mvc.Routing; using System; using System.Collections.Generic; using System.Linq; diff --git a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkViewExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkViewExtensions.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkViewExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkViewExtensions.cs index ad1cc89..1b22713 100644 --- a/Sources/NET4.SrkToolkit.Web/System.Web.Mvc/SrkViewExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/System.Web.Mvc/SrkViewExtensions.cs @@ -16,11 +16,11 @@ namespace System.Web.Mvc { + using SrkToolkit.Web.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using SrkToolkit.Web.Models; /// /// Extension methods for . diff --git a/Sources/NET4.SrkToolkit.Web/WebDependencies.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs similarity index 93% rename from Sources/NET4.SrkToolkit.Web/WebDependencies.cs rename to Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs index 5f6e136..73455a5 100644 --- a/Sources/NET4.SrkToolkit.Web/WebDependencies.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs @@ -16,13 +16,12 @@ namespace SrkToolkit.Web { + using Microsoft.AspNetCore.Html; + using Microsoft.AspNetCore.Mvc.Rendering; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web; - using System.Web.Hosting; - using System.Web.Mvc; /// /// Manages web dependencies such as scripts and styles. @@ -44,7 +43,7 @@ public WebDependencies() /// The value. /// HTML /// value - public MvcHtmlString Render(WebDependency value) + public HtmlString Render(WebDependency value) { if (value == null) throw new ArgumentNullException("value"); @@ -57,10 +56,10 @@ public MvcHtmlString Render(WebDependency value) RenderDependency(value.Files[i], sb); } - return MvcHtmlString.Create(sb.ToString()); + return new HtmlString(sb.ToString()); } - return MvcHtmlString.Empty; + return HtmlString.Empty; } /// @@ -122,7 +121,7 @@ public WebDependencies Include(WebDependency value, WebDependencyPosition positi /// /// The position. /// - public MvcHtmlString RenderIncludes(WebDependencyPosition position) + public HtmlString RenderIncludes(WebDependencyPosition position) { var sb = new StringBuilder(); sb.AppendLine(""); @@ -150,7 +149,7 @@ public MvcHtmlString RenderIncludes(WebDependencyPosition position) } sb.AppendLine(""); - return MvcHtmlString.Create(sb.ToString()); + return new HtmlString(sb.ToString()); } protected static void RenderDependency(WebDependencyFile value, StringBuilder sb) diff --git a/Sources/NET4.SrkToolkit.Web/WebDependenciesExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs similarity index 96% rename from Sources/NET4.SrkToolkit.Web/WebDependenciesExtensions.cs rename to Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs index 3cdea85..dc7b30d 100644 --- a/Sources/NET4.SrkToolkit.Web/WebDependenciesExtensions.cs +++ b/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs @@ -20,7 +20,6 @@ namespace SrkToolkit.Web using System.Collections.Generic; using System.Linq; using System.Text; - using System.Web.Mvc; /// /// Extension methods for the class. diff --git a/Sources/NET4.SrkToolkit.Web/WebDependency.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependency.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/WebDependency.cs rename to Sources/SrkToolkit.Web.AspNetCore2/WebDependency.cs diff --git a/Sources/NET4.SrkToolkit.Web/WebDependencyFile.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependencyFile.cs similarity index 100% rename from Sources/NET4.SrkToolkit.Web/WebDependencyFile.cs rename to Sources/SrkToolkit.Web.AspNetCore2/WebDependencyFile.cs