Merge pull request #126 from onerain88/chore4

完善单元测试
oneRain 2021-05-06 12:24:00 +08:00 committed by GitHub
commit 0e103df4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 51905 additions and 470 deletions

View File

@ -0,0 +1 @@
ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1,6 @@
.git/
.DS_Store
.avoscloud/
.leancloud/
web/bin/
web/obj/

View File

@ -0,0 +1,9 @@
# LeanEngineApp
.Net LeanCloud 云引擎 SDK 及脚手架工程
## 参考
- [云函数开发指南](https://leancloud.cn/docs/leanengine_cloudfunction_guide-dotnet.html)
- [即时通信 Hook](https://leancloud.cn/docs/realtime-guide-systemconv.html)

View File

@ -0,0 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.808.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "web", "web\web.csproj", "{7C5B740C-5C99-4ABC-AAB9-CFA87D8EC68D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{326A04CD-93B3-4F1E-B528-1312C170C819}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C5B740C-5C99-4ABC-AAB9-CFA87D8EC68D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C5B740C-5C99-4ABC-AAB9-CFA87D8EC68D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C5B740C-5C99-4ABC-AAB9-CFA87D8EC68D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C5B740C-5C99-4ABC-AAB9-CFA87D8EC68D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5E6ECCA4-FA00-4FEC-B336-A2DBBEA58C30}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 0.1.0
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
{
"sdk": {
"version": "3.1.100",
"rollForward": "latestFeature"
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using LeanCloud.Storage;
using LeanCloud.Engine;
namespace web {
public class App {
// Function
[LCEngineFunction("ping")]
public static string Ping() {
return "pong";
}
[LCEngineFunction("hello")]
public static string Hello([LCEngineFunctionParam("name")] string name) {
string msg = $"hello, {name}";
Console.WriteLine(msg);
return msg;
}
[LCEngineFunction("getObject")]
public static async Task<LCObject> GetObject([LCEngineFunctionParam("className")] string className,
[LCEngineFunctionParam("id")] string id) {
LCQuery<LCObject> query = new LCQuery<LCObject>(className);
return await query.Get(id);
}
[LCEngineFunction("getObjects")]
public static async Task<ReadOnlyCollection<LCObject>> GetObjects() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
query.WhereGreaterThan("balance", 100);
return await query.Find();
}
[LCEngineFunction("getObjectMap")]
public static async Task<Dictionary<string, LCObject>> GetObjectMap() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Todo");
ReadOnlyCollection<LCObject> todos = await query.Find();
return todos.ToDictionary(t => t.ObjectId);
}
}
}

View File

@ -0,0 +1,27 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using web.Models;
namespace web.Controllers {
public class HomeController : Controller {
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger) {
_logger = logger;
}
public IActionResult Index() {
return View();
}
public IActionResult Privacy() {
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

Binary file not shown.

View File

@ -0,0 +1,75 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"Engine/1.0.0": {
"dependencies": {
"Storage.Standard": "1.0.0"
},
"runtime": {
"Engine.dll": {}
}
},
"Common/1.0.0": {
"dependencies": {
"LC.Newtonsoft.Json": "11.0.1-beta2"
},
"runtime": {
"Common.dll": {}
}
},
"LC.Newtonsoft.Json/11.0.1-beta2": {
"runtime": {
"LC.Newtonsoft.Json.dll": {}
}
},
"Storage/1.0.0": {
"dependencies": {
"Common": "1.0.0"
},
"runtime": {
"Storage.dll": {}
}
},
"Storage.Standard/1.0.0": {
"dependencies": {
"Storage": "1.0.0"
},
"runtime": {
"Storage.Standard.dll": {}
}
}
}
},
"libraries": {
"Engine/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Common/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"LC.Newtonsoft.Json/11.0.1-beta2": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Storage/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Storage.Standard/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,77 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"Storage/1.0.0": {
"dependencies": {
"Common": "1.0.0",
"NETStandard.Library": "2.0.3",
"Newtonsoft.Json": "12.0.2"
},
"runtime": {
"Storage.dll": {}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"Newtonsoft.Json/12.0.2": {
"runtime": {
"lib/netstandard2.0/Newtonsoft.Json.dll": {
"assemblyVersion": "12.0.0.0",
"fileVersion": "12.0.2.23222"
}
}
},
"Common/1.0.0": {
"dependencies": {
"Newtonsoft.Json": "12.0.2"
},
"runtime": {
"Common.dll": {}
}
}
}
},
"libraries": {
"Storage/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-blZaySO1YhUZbdvAT4Y/dV5wQhmiBc+N+2z6NEY105HFU4KUV4JlDOUJE5jnxsftTdwUWk9XcLfGa74mYu3NuA==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-y0qCZAz3xrB2CbP5Fejmc50B0L6CuVLdQIETDOJotFuC7+ipCC7l5xAir9Sk/OZV3gLs+LfHrxgqarvvRkXDDw==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"Newtonsoft.Json/12.0.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-rTK0s2EKlfHsQsH6Yx2smvcTCeyoDNgCW7FEYyV01drPlh2T243PR2DiDXqtC5N4GDm4Ma/lkxfW5a/4793vbA==",
"path": "newtonsoft.json/12.0.2",
"hashPath": "newtonsoft.json.12.0.2.nupkg.sha512"
},
"Common/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

View File

@ -0,0 +1,9 @@
using System;
namespace web.Models {
public class ErrorViewModel {
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,17 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace web {
public class Program {
public static void Main(string[] args) {
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using LeanCloud;
using LeanCloud.Engine;
namespace web {
public class Startup {
public Startup(IConfiguration configuration) {
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
LCLogger.LogDelegate = (level, log) => {
switch (level) {
case LCLogLevel.Debug:
Console.WriteLine($"[DEBUG] {log}");
break;
case LCLogLevel.Warn:
Console.WriteLine($"[WARN] {log}");
break;
case LCLogLevel.Error:
Console.WriteLine($"[ERROR] {log}");
break;
default:
break;
}
};
LCEngine.Initialize(services);
services.AddControllersWithViews();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}

View File

@ -0,0 +1,8 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

View File

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - web</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">web</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2021 - web - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@RenderSection("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using web
@using web.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ReleaseVersion>0.1.0</ReleaseVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Storage">
<HintPath>Libs\Storage.dll</HintPath>
</Reference>
<Reference Include="Engine">
<HintPath>Libs\Engine.dll</HintPath>
</Reference>
<Reference Include="Storage.Standard">
<HintPath>Libs\Storage.Standard.dll</HintPath>
</Reference>
<Reference Include="Common">
<HintPath>Libs\Common.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Remove="Libs\Storage.pdb" />
<None Remove="Libs\Storage.pdb" />
<None Remove="Libs\Engine.dll" />
<None Remove="Libs\Engine.pdb" />
</ItemGroup>
<ItemGroup>
<Content Remove="Libs\Storage.deps.json" />
<Content Remove="Libs\Storage.deps.json" />
<Content Remove="Libs\Storage.deps.json" />
<Content Remove="Libs\Engine.deps.json" />
<Content Remove="Libs\Engine.deps.json" />
<Content Remove="Libs\Engine.deps.json" />
<Content Remove="Libs\Engine.deps.json" />
<Content Remove="Libs\Engine.deps.json" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,71 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2018 Twitter, Inc.
Copyright (c) 2011-2018 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,331 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):focus {
outline: 0;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
Copyright (c) .NET Foundation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
these files 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.

View File

@ -0,0 +1,432 @@
// Unobtrusive validation support library for jQuery and jQuery Validate
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// @version v3.2.11
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
/*global document: false, jQuery: false */
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define("jquery.validate.unobtrusive", ['jquery-validation'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports
module.exports = factory(require('jquery-validation'));
} else {
// Browser global
jQuery.validator.unobtrusive = factory(jQuery);
}
}(function ($) {
var $jQval = $.validator,
adapters,
data_validation = "unobtrusiveValidation";
function setValidationValues(options, ruleName, value) {
options.rules[ruleName] = value;
if (options.message) {
options.messages[ruleName] = options.message;
}
}
function splitAndTrim(value) {
return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g);
}
function escapeAttributeValue(value) {
// As mentioned on http://api.jquery.com/category/selectors/
return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
}
function getModelPrefix(fieldName) {
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
}
function appendModelPrefix(value, prefix) {
if (value.indexOf("*.") === 0) {
value = value.replace("*.", prefix);
}
return value;
}
function onError(error, inputElement) { // 'this' is the form element
var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"),
replaceAttrValue = container.attr("data-valmsg-replace"),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
container.removeClass("field-validation-valid").addClass("field-validation-error");
error.data("unobtrusiveContainer", container);
if (replace) {
container.empty();
error.removeClass("input-validation-error").appendTo(container);
}
else {
error.hide();
}
}
function onErrors(event, validator) { // 'this' is the form element
var container = $(this).find("[data-valmsg-summary=true]"),
list = container.find("ul");
if (list && list.length && validator.errorList.length) {
list.empty();
container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
$.each(validator.errorList, function () {
$("<li />").html(this.message).appendTo(list);
});
}
}
function onSuccess(error) { // 'this' is the form element
var container = error.data("unobtrusiveContainer");
if (container) {
var replaceAttrValue = container.attr("data-valmsg-replace"),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null;
container.addClass("field-validation-valid").removeClass("field-validation-error");
error.removeData("unobtrusiveContainer");
if (replace) {
container.empty();
}
}
}
function onReset(event) { // 'this' is the form element
var $form = $(this),
key = '__jquery_unobtrusive_validation_form_reset';
if ($form.data(key)) {
return;
}
// Set a flag that indicates we're currently resetting the form.
$form.data(key, true);
try {
$form.data("validator").resetForm();
} finally {
$form.removeData(key);
}
$form.find(".validation-summary-errors")
.addClass("validation-summary-valid")
.removeClass("validation-summary-errors");
$form.find(".field-validation-error")
.addClass("field-validation-valid")
.removeClass("field-validation-error")
.removeData("unobtrusiveContainer")
.find(">*") // If we were using valmsg-replace, get the underlying error
.removeData("unobtrusiveContainer");
}
function validationInfo(form) {
var $form = $(form),
result = $form.data(data_validation),
onResetProxy = $.proxy(onReset, form),
defaultOptions = $jQval.unobtrusive.options || {},
execInContext = function (name, args) {
var func = defaultOptions[name];
func && $.isFunction(func) && func.apply(form, args);
};
if (!result) {
result = {
options: { // options structure passed to jQuery Validate's validate() method
errorClass: defaultOptions.errorClass || "input-validation-error",
errorElement: defaultOptions.errorElement || "span",
errorPlacement: function () {
onError.apply(form, arguments);
execInContext("errorPlacement", arguments);
},
invalidHandler: function () {
onErrors.apply(form, arguments);
execInContext("invalidHandler", arguments);
},
messages: {},
rules: {},
success: function () {
onSuccess.apply(form, arguments);
execInContext("success", arguments);
}
},
attachValidation: function () {
$form
.off("reset." + data_validation, onResetProxy)
.on("reset." + data_validation, onResetProxy)
.validate(this.options);
},
validate: function () { // a validation function that is called by unobtrusive Ajax
$form.validate();
return $form.valid();
}
};
$form.data(data_validation, result);
}
return result;
}
$jQval.unobtrusive = {
adapters: [],
parseElement: function (element, skipAttach) {
/// <summary>
/// Parses a single HTML element for unobtrusive validation attributes.
/// </summary>
/// <param name="element" domElement="true">The HTML element to be parsed.</param>
/// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
/// validation to the form. If parsing just this single element, you should specify true.
/// If parsing several elements, you should specify false, and manually attach the validation
/// to the form when you are finished. The default is false.</param>
var $element = $(element),
form = $element.parents("form")[0],
valInfo, rules, messages;
if (!form) { // Cannot do client-side validation without a form
return;
}
valInfo = validationInfo(form);
valInfo.options.rules[element.name] = rules = {};
valInfo.options.messages[element.name] = messages = {};
$.each(this.adapters, function () {
var prefix = "data-val-" + this.name,
message = $element.attr(prefix),
paramValues = {};
if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy)
prefix += "-";
$.each(this.params, function () {
paramValues[this] = $element.attr(prefix + this);
});
this.adapt({
element: element,
form: form,
message: message,
params: paramValues,
rules: rules,
messages: messages
});
}
});
$.extend(rules, { "__dummy__": true });
if (!skipAttach) {
valInfo.attachValidation();
}
},
parse: function (selector) {
/// <summary>
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
/// attribute values.
/// </summary>
/// <param name="selector" type="String">Any valid jQuery selector.</param>
// $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one
// element with data-val=true
var $selector = $(selector),
$forms = $selector.parents()
.addBack()
.filter("form")
.add($selector.find("form"))
.has("[data-val=true]");
$selector.find("[data-val=true]").each(function () {
$jQval.unobtrusive.parseElement(this, true);
});
$forms.each(function () {
var info = validationInfo(this);
if (info) {
info.attachValidation();
}
});
}
};
adapters = $jQval.unobtrusive.adapters;
adapters.add = function (adapterName, params, fn) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
/// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
/// mmmm is the parameter name).</param>
/// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
/// attributes into jQuery Validate rules and/or messages.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
if (!fn) { // Called with no params, just a function
fn = params;
params = [];
}
this.push({ name: adapterName, params: params, adapt: fn });
return this;
};
adapters.addBool = function (adapterName, ruleName) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation rule has no parameter values.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
/// of adapterName will be used instead.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, function (options) {
setValidationValues(options, ruleName || adapterName, true);
});
};
adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
/// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
/// have a minimum value.</param>
/// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
/// have a maximum value.</param>
/// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
/// have both a minimum and maximum value.</param>
/// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
/// contains the minimum value. The default is "min".</param>
/// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
/// contains the maximum value. The default is "max".</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) {
var min = options.params.min,
max = options.params.max;
if (min && max) {
setValidationValues(options, minMaxRuleName, [min, max]);
}
else if (min) {
setValidationValues(options, minRuleName, min);
}
else if (max) {
setValidationValues(options, maxRuleName, max);
}
});
};
adapters.addSingleVal = function (adapterName, attribute, ruleName) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation rule has a single value.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
/// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
/// The default is "val".</param>
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
/// of adapterName will be used instead.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, [attribute || "val"], function (options) {
setValidationValues(options, ruleName || adapterName, options.params[attribute]);
});
};
$jQval.addMethod("__dummy__", function (value, element, params) {
return true;
});
$jQval.addMethod("regex", function (value, element, params) {
var match;
if (this.optional(element)) {
return true;
}
match = new RegExp(params).exec(value);
return (match && (match.index === 0) && (match[0].length === value.length));
});
$jQval.addMethod("nonalphamin", function (value, element, nonalphamin) {
var match;
if (nonalphamin) {
match = value.match(/\W/g);
match = match && match.length >= nonalphamin;
}
return match;
});
if ($jQval.methods.extension) {
adapters.addSingleVal("accept", "mimtype");
adapters.addSingleVal("extension", "extension");
} else {
// for backward compatibility, when the 'extension' validation method does not exist, such as with versions
// of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for
// validating the extension, and ignore mime-type validations as they are not supported.
adapters.addSingleVal("extension", "extension", "accept");
}
adapters.addSingleVal("regex", "pattern");
adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");
adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range");
adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength");
adapters.add("equalto", ["other"], function (options) {
var prefix = getModelPrefix(options.element.name),
other = options.params.other,
fullOtherName = appendModelPrefix(other, prefix),
element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0];
setValidationValues(options, "equalTo", element);
});
adapters.add("required", function (options) {
// jQuery Validate equates "required" with "mandatory" for checkbox elements
if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") {
setValidationValues(options, "required", true);
}
});
adapters.add("remote", ["url", "type", "additionalfields"], function (options) {
var value = {
url: options.params.url,
type: options.params.type || "GET",
data: {}
},
prefix = getModelPrefix(options.element.name);
$.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) {
var paramName = appendModelPrefix(fieldName, prefix);
value.data[paramName] = function () {
var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']");
// For checkboxes and radio buttons, only pick up values from checked fields.
if (field.is(":checkbox")) {
return field.filter(":checked").val() || field.filter(":hidden").val() || '';
}
else if (field.is(":radio")) {
return field.filter(":checked").val() || '';
}
return field.val();
};
});
setValidationValues(options, "remote", value);
});
adapters.add("password", ["min", "nonalphamin", "regex"], function (options) {
if (options.params.min) {
setValidationValues(options, "minlength", options.params.min);
}
if (options.params.nonalphamin) {
setValidationValues(options, "nonalphamin", options.params.nonalphamin);
}
if (options.params.regex) {
setValidationValues(options, "regex", options.params.regex);
}
});
adapters.add("fileextensions", ["extensions"], function (options) {
setValidationValues(options, "extension", options.params.extensions);
});
$(function () {
$jQval.unobtrusive.parse(document);
});
return $jQval.unobtrusive;
}));

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
=====================
Copyright Jörn Zaefferer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,46 +1,40 @@
using NUnit.Framework;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System;
using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
public class ACLTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class ACLTest : BaseTest {
private Account account;
[Test]
[Order(0)]
public async Task PrivateReadAndWrite() {
LCObject account = new LCObject("Account");
LCACL acl = new LCACL();
acl.PublicReadAccess = false;
acl.PublicWriteAccess = false;
account.ACL = acl;
account["balance"] = 1024;
Account account = new Account();
account.ACL = new LCACL {
PublicReadAccess = false,
PublicWriteAccess = false
};
account.Balance = 1024;
await account.Save();
Assert.IsFalse(acl.PublicReadAccess);
Assert.IsFalse(acl.PublicWriteAccess);
Assert.IsFalse(account.ACL.PublicReadAccess);
Assert.IsFalse(account.ACL.PublicWriteAccess);
}
[Test]
[Order(1)]
public async Task UserReadAndWrite() {
await LCUser.Login("hello", "world");
LCObject account = new LCObject("Account");
await LCUser.Login(TestPhone, TestPhone);
account = new Account();
LCUser currentUser = await LCUser.GetCurrent();
LCACL acl = LCACL.CreateWithOwner(currentUser);
account.ACL = acl;
account["balance"] = 512;
account.ACL = LCACL.CreateWithOwner(currentUser);
account.Balance = 512;
await account.Save();
Assert.IsTrue(acl.GetUserReadAccess(currentUser));
Assert.IsTrue(acl.GetUserWriteAccess(currentUser));
Assert.IsTrue(account.ACL.GetUserReadAccess(currentUser));
Assert.IsTrue(account.ACL.GetUserWriteAccess(currentUser));
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject result = await query.Get(account.ObjectId);
@ -57,29 +51,39 @@ namespace Storage.Test {
}
[Test]
[Order(2)]
public async Task RoleReadAndWrite() {
LCQuery<LCRole> query = LCRole.GetQuery();
LCRole owner = await query.Get("5e1440cbfc36ed006add1b8d");
LCObject account = new LCObject("Account");
LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
LCACL roleACL = new LCACL();
roleACL.SetUserReadAccess(currentUser, true);
roleACL.SetUserWriteAccess(currentUser, true);
LCRole role = LCRole.Create(name, roleACL);
role.AddRelation("users", currentUser);
await role.Save();
account = new Account();
LCACL acl = new LCACL();
acl.SetRoleReadAccess(owner, true);
acl.SetRoleWriteAccess(owner, true);
acl.SetRoleReadAccess(role, true);
acl.SetRoleWriteAccess(role, true);
account.ACL = acl;
await account.Save();
Assert.IsTrue(acl.GetRoleReadAccess(owner));
Assert.IsTrue(acl.GetRoleWriteAccess(owner));
Assert.IsTrue(acl.GetRoleReadAccess(role));
Assert.IsTrue(acl.GetRoleWriteAccess(role));
}
[Test]
[Order(3)]
public async Task Query() {
await LCUser.Login("game", "play");
await LCUser.Login(TestPhone, TestPhone);
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e144525dd3c13006a8f8de2");
TestContext.WriteLine(account.ObjectId);
Assert.NotNull(account.ObjectId);
Account queryAccount = (await query.Get(account.ObjectId)) as Account;
TestContext.WriteLine(queryAccount.ObjectId);
Assert.NotNull(queryAccount.ObjectId);
}
[Test]
[Order(4)]
public async Task Serialization() {
await LCUser.Login("hello", "world");
LCQuery<LCObject> query = new LCQuery<LCObject>("Account") {

View File

@ -0,0 +1,86 @@
using NUnit.Framework;
using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
internal class Hello : LCObject {
internal World World {
get => this["objectValue"] as World;
set {
this["objectValue"] = value;
}
}
internal Hello() : base("Hello") { }
}
internal class World : LCObject {
internal string Content {
get => this["content"] as string;
set {
this["content"] = value;
}
}
internal World() : base("World") { }
}
internal class Account : LCObject {
internal int Balance {
get => (int)this["balance"];
set {
this["balance"] = value;
}
}
internal LCUser User {
get => this["user"] as LCUser;
set {
this["user"] = value;
}
}
internal Account() : base("Account") { }
}
public class BaseTest {
internal const string AppId = "ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz";
internal const string AppKey = "NUKmuRbdAhg1vrb2wexYo1jo";
internal const string MasterKey = "pyvbNSh5jXsuFQ3C8EgnIdhw";
internal const string AppServer = "https://ikggdre2.lc-cn-n1-shared.com";
internal const string TestPhone = "18888888888";
internal const string TestSMSCode = "235750";
[SetUp]
public virtual void SetUp() {
LCLogger.LogDelegate += Print;
LCApplication.Initialize(AppId, AppKey, AppServer);
LCObject.RegisterSubclass("Account", () => new Account());
LCObject.RegisterSubclass("Hello", () => new Hello());
LCObject.RegisterSubclass("World", () => new World());
}
[TearDown]
public virtual void TearDown() {
LCLogger.LogDelegate -= Print;
}
internal static void Print(LCLogLevel level, string info) {
switch (level) {
case LCLogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}");
break;
case LCLogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}");
break;
case LCLogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}");
break;
default:
TestContext.Out.WriteLine(info);
break;
}
}
}
}

View File

@ -1,22 +1,11 @@
using NUnit.Framework;
using System.Threading.Tasks;
using LeanCloud;
using LeanCloud.Storage;
using static NUnit.Framework.TestContext;
namespace Storage.Test {
public class CaptchaTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class CaptchaTest : BaseTest {
//[Test]
public async Task Request() {
LCCapture captcha = await LCCaptchaClient.RequestCaptcha();

View File

@ -2,83 +2,60 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
public class CloudTest {
[SetUp]
public void SetUp() {
LCLogger.LogDelegate += Utils.Print;
//LCApplication.Initialize("ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz", "NUKmuRbdAhg1vrb2wexYo1jo", "https://ikggdre2.lc-cn-n1-shared.com");
LCApplication.Initialize("8ijVI3gBAnPGynW0rVfh5gHP-gzGzoHsz", "265r8JSHhNYpV0qIJBvUWrQY", "https://8ijvi3gb.lc-cn-n1-shared.com");
}
[TearDown]
public void TearDown() {
LCLogger.LogDelegate -= Utils.Print;
public class CloudTest : BaseTest {
[Test]
public async Task Ping() {
Dictionary<string, object> response = await LCCloud.Run("ping");
TestContext.WriteLine(response["result"]);
Assert.AreEqual(response["result"], "pong");
}
[Test]
public async Task Call() {
Dictionary<string, object> response = await LCCloud.Run("hello", parameters: new Dictionary<string, object> {
public async Task Hello() {
string result = await LCCloud.Run<string>("hello", new Dictionary<string, object> {
{ "name", "world" }
});
TestContext.WriteLine(response["result"]);
Assert.AreEqual(response["result"], "Hello, world!");
TestContext.WriteLine(result);
Assert.AreEqual(result, "hello, world");
}
[Test]
public async Task RunAverageScore() {
float score = await LCCloud.Run<float>("averageStars", new Dictionary<string, object> {
{ "movie", "夏洛特烦恼" }
public async Task GetObject() {
LCObject hello = new LCObject("Hello");
await hello.Save();
object reponse = await LCCloud.RPC("getObject", new Dictionary<string, object> {
{ "className", "Hello" },
{ "id", hello.ObjectId }
});
TestContext.WriteLine($"score: {score}");
Assert.True(score.Equals(3.8f));
LCObject obj = reponse as LCObject;
Assert.AreEqual(obj.ObjectId, hello.ObjectId);
}
[Test]
public async Task CallWithoutParams() {
await LCCloud.Run("hello");
}
[Test]
public async Task RPC() {
List<object> result = await LCCloud.RPC("getTycoonList") as List<object>;
IEnumerable<LCObject> tycoonList = result.Cast<LCObject>();
foreach (LCObject item in tycoonList) {
TestContext.WriteLine(item.ObjectId);
Assert.NotNull(item.ObjectId);
public async Task GetObjects() {
object response = await LCCloud.RPC("getObjects");
List<object> list = response as List<object>;
IEnumerable<LCObject> objects = list.Cast<LCObject>();
TestContext.WriteLine(objects.Count());
Assert.Greater(objects.Count(), 0);
foreach (LCObject obj in objects) {
int balance = (int)obj["balance"];
Assert.Greater(balance, 100);
}
}
[Test]
public async Task RPCObject() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Todo");
LCObject todo = await query.Get("6052cd87b725a143ea83dbf8");
object result = await LCCloud.RPC("getTodo", todo);
LCObject obj = result as LCObject;
TestContext.WriteLine(obj.ToString());
}
[Test]
public async Task RPCObjects() {
Dictionary<string, object> parameters = new Dictionary<string, object> {
{ "limit", 20 }
};
List<object> result = await LCCloud.RPC("getTodos", parameters) as List<object>;
IEnumerable<LCObject> todos = result.Cast<LCObject>();
foreach (LCObject todo in todos) {
TestContext.WriteLine(todo.ObjectId);
}
}
[Test]
public async Task RPCObjectMap() {
Dictionary<string, object> result = await LCCloud.RPC("getTodoMap") as Dictionary<string, object>;
foreach (KeyValuePair<string, object> kv in result) {
LCObject todo = kv.Value as LCObject;
TestContext.WriteLine(todo.ObjectId);
public async Task GetObjectMap() {
object response = await LCCloud.RPC("getObjectMap");
Dictionary<string, object> dict = response as Dictionary<string, object>;
TestContext.WriteLine(dict.Count);
Assert.Greater(dict.Count, 0);
foreach (KeyValuePair<string, object> kv in dict) {
LCObject obj = kv.Value as LCObject;
Assert.AreEqual(kv.Key, obj.ObjectId);
}
}
}

View File

@ -2,7 +2,7 @@
using LeanCloud;
namespace Storage.Test {
public class ExceptionTest {
public class ExceptionTest : BaseTest {
[Test]
public void LeanCloudException() {
try {

View File

@ -6,39 +6,33 @@ using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
public class FileTest {
public class FileTest : BaseTest {
static readonly string AvatarFilePath = "../../../../../assets/hello.png";
static readonly string APKFilePath = "../../../../../assets/test.apk";
[SetUp]
public void SetUp() {
Utils.SetUp();
}
private LCFile avatar;
[TearDown]
public void TearDown() {
Utils.TearDown();
[Test]
[Order(0)]
public async Task SaveFromPath() {
avatar = new LCFile("avatar", AvatarFilePath);
await avatar.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(avatar.ObjectId);
Assert.NotNull(avatar.ObjectId);
}
[Test]
[Order(1)]
public async Task QueryFile() {
LCQuery<LCFile> query = LCFile.GetQuery();
LCFile file = await query.Get("5e0dbfa0562071008e21c142");
LCFile file = await query.Get(avatar.ObjectId);
Assert.NotNull(file.Url);
TestContext.WriteLine(file.Url);
TestContext.WriteLine(file.GetThumbnailUrl(32, 32));
}
[Test]
public async Task SaveFromPath() {
LCFile file = new LCFile("avatar", AvatarFilePath);
await file.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(file.ObjectId);
Assert.NotNull(file.ObjectId);
}
[Test]
public async Task SaveFromMemory() {
string text = "hello, world";
@ -69,17 +63,6 @@ namespace Storage.Test {
Assert.NotNull(file.ObjectId);
}
[Test]
public async Task AWS() {
LCApplication.Initialize("UlCpyvLm8aMzQsW6KnP6W3Wt-MdYXbMMI", "PyCTYoNoxCVoKKg394PBeS4r");
LCFile file = new LCFile("avatar", AvatarFilePath);
await file.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(file.ObjectId);
Assert.NotNull(file.ObjectId);
}
[Test]
public async Task FileACL() {
LCUser user = await LCUser.LoginAnonymously();
@ -101,5 +84,16 @@ namespace Storage.Test {
Assert.AreEqual(e.Code, 403);
}
}
//[Test]
//public async Task AWS() {
// LCApplication.Initialize("UlCpyvLm8aMzQsW6KnP6W3Wt-MdYXbMMI", "PyCTYoNoxCVoKKg394PBeS4r");
// LCFile file = new LCFile("avatar", AvatarFilePath);
// await file.Save((count, total) => {
// TestContext.WriteLine($"progress: {count}/{total}");
// });
// TestContext.WriteLine(file.ObjectId);
// Assert.NotNull(file.ObjectId);
//}
}
}

View File

@ -8,7 +8,7 @@ using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
public class FriendTest {
public class FriendTest : BaseTest {
async Task<LCUser> SignUp() {
LCUser user = new LCUser {
Username = Guid.NewGuid().ToString(),
@ -36,16 +36,6 @@ namespace Storage.Test {
private LCUser user1;
private LCUser user2;
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test]
[Order(0)]
public async Task Init() {

View File

@ -2,7 +2,7 @@
using LeanCloud.Storage;
namespace Storage.Test {
public class GeoTest {
public class GeoTest : BaseTest {
[Test]
public void Calculate() {
LCGeoPoint p1 = new LCGeoPoint(20.0059, 110.3665);

View File

@ -9,21 +9,21 @@ using LeanCloud.Storage;
using static NUnit.Framework.TestContext;
namespace Storage.Test {
public class LeaderboardTest {
public class LeaderboardTest : BaseTest {
private string leaderboardName;
[SetUp]
public void SetUp() {
LCLogger.LogDelegate += Utils.Print;
LCApplication.Initialize(Utils.AppId, Utils.AppKey, Utils.AppServer, Utils.MasterKey);
public override void SetUp() {
base.SetUp();
LCApplication.Initialize(AppId, AppKey, AppServer, MasterKey);
LCApplication.UseMasterKey = true;
leaderboardName = $"Leaderboard_{DateTimeOffset.Now.DayOfYear}";
}
[TearDown]
public void TearDown() {
public override void TearDown() {
base.TearDown();
LCApplication.UseMasterKey = false;
Utils.TearDown();
}
[Test]

View File

@ -2,26 +2,17 @@ using NUnit.Framework;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using LeanCloud;
using LeanCloud.Storage;
using static NUnit.Framework.TestContext;
namespace Storage.Test {
public class ObjectTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class ObjectTest : BaseTest {
[Test]
public async Task CreateObject() {
LCObject @object = new LCObject("Hello");
Hello @object = new Hello();
@object["intValue"] = 123;
@object["boolValue"] = true;
@object["stringValue"] = "hello, world";
@ -32,25 +23,25 @@ namespace Storage.Test {
{ "k2", true },
{ "k3", "haha" }
};
LCObject nestedObj = new LCObject("World");
nestedObj["content"] = "7788";
@object["objectValue"] = nestedObj;
World nestedObj = new World();
nestedObj.Content = "7788";
@object.World = nestedObj;
@object["pointerList"] = new List<object> { new LCObject("World"), nestedObj };
await @object.Save();
TestContext.WriteLine(@object.ClassName);
TestContext.WriteLine(@object.ObjectId);
TestContext.WriteLine(@object.CreatedAt);
TestContext.WriteLine(@object.UpdatedAt);
TestContext.WriteLine(@object["intValue"]);
TestContext.WriteLine(@object["boolValue"]);
TestContext.WriteLine(@object["stringValue"]);
TestContext.WriteLine(@object["objectValue"]);
TestContext.WriteLine(@object["time"]);
WriteLine(@object.ClassName);
WriteLine(@object.ObjectId);
WriteLine(@object.CreatedAt);
WriteLine(@object.UpdatedAt);
WriteLine(@object["intValue"]);
WriteLine(@object["boolValue"]);
WriteLine(@object["stringValue"]);
WriteLine(@object["objectValue"]);
WriteLine(@object["time"]);
Assert.AreEqual(nestedObj, @object["objectValue"]);
TestContext.WriteLine(nestedObj.ClassName);
TestContext.WriteLine(nestedObj.ObjectId);
WriteLine(nestedObj.ClassName);
WriteLine(nestedObj.ObjectId);
Assert.NotNull(@object.ObjectId);
Assert.NotNull(@object.ClassName);
@ -77,8 +68,9 @@ namespace Storage.Test {
public async Task SaveAll() {
List<LCObject> list = new List<LCObject>();
for (int i = 0; i < 5; i++) {
LCObject world = new LCObject("World");
world["content"] = $"word_{i}";
World world = new World {
Content = $"word_{i}"
};
list.Add(world);
}
await LCObject.SaveAll(list);
@ -89,18 +81,18 @@ namespace Storage.Test {
[Test]
public async Task Delete() {
LCObject world = new LCObject("World");
World world = new World();
await world.Save();
await world.Delete();
}
[Test]
public async Task DeleteAll() {
List<LCObject> list = new List<LCObject> {
new LCObject("World"),
new LCObject("World"),
new LCObject("World"),
new LCObject("World")
List<World> list = new List<World> {
new World(),
new World(),
new World(),
new World(),
};
await LCObject.SaveAll(list);
await LCObject.DeleteAll(list);
@ -108,47 +100,53 @@ namespace Storage.Test {
[Test]
public async Task Fetch() {
LCObject hello = LCObject.CreateWithoutData("Hello", "5e14392743c257006fb769d5");
await hello.Fetch(includes: new List<string> { "objectValue" });
LCObject world = hello["objectValue"] as LCObject;
TestContext.WriteLine(world["content"]);
Assert.AreEqual(world["content"], "7788");
Hello hello = new Hello {
World = new World {
Content = "7788"
}
};
await hello.Save();
hello = LCObject.CreateWithoutData("Hello", hello.ObjectId) as Hello;
await hello.Fetch(includes: new string[] { "objectValue" });
World world = hello.World;
WriteLine(world.Content);
Assert.AreEqual(world.Content, "7788");
}
[Test]
public async Task SaveWithOption() {
LCObject account = new LCObject("Account");
account["balance"] = 10;
Account account = new Account {
Balance = 10
};
await account.Save();
account["balance"] = 1000;
LCQuery<LCObject> q = new LCQuery<LCObject>("Account");
q.WhereGreaterThan("balance", 100);
try {
await account.Save(fetchWhenSave: true, query: q);
} catch(LCException e) {
TestContext.WriteLine($"{e.Code} : {e.Message}");
WriteLine($"{e.Code} : {e.Message}");
Assert.AreEqual(e.Code, 305);
}
}
[Test]
public async Task Unset() {
LCObject hello = new LCObject("Hello");
hello["content"] = "hello, world";
Hello hello = new Hello {
World = new World()
};
await hello.Save();
TestContext.WriteLine(hello["content"]);
Assert.AreEqual(hello["content"], "hello, world");
Assert.NotNull(hello.World);
hello.Unset("content");
hello.Unset("objectValue");
await hello.Save();
TestContext.WriteLine(hello["content"]);
Assert.IsNull(hello["content"]);
Assert.IsNull(hello.World);
}
[Test]
public async Task OperateNullProperty() {
LCObject obj = new LCObject("Hello");
Hello obj = new Hello();
obj.Increment("intValue", 123);
obj.Increment("intValue", 321);
obj.Add("intList", 1);
@ -168,21 +166,19 @@ namespace Storage.Test {
[Test]
public async Task FetchAll() {
List<LCObject> list = new List<LCObject> {
LCObject.CreateWithoutData("Hello", "5e8fe86938ed12000870ae82"),
LCObject.CreateWithoutData("Hello", "5e8fe867158a7a0006be0feb"),
LCObject.CreateWithoutData("Hello", "5e8fe84e5c385800081a1d64"),
};
LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
IEnumerable<string> ids = (await query.Find()).Select(obj => obj.ObjectId);
IEnumerable<LCObject> list = ids.Select(id => LCObject.CreateWithoutData("Hello", id));
await LCObject.FetchAll(list);
Assert.Greater(list.Count, 0);
Assert.Greater(list.Count(), 0);
foreach (LCObject obj in list) {
Assert.NotNull(obj["intList"]);
Assert.NotNull(obj.CreatedAt);
}
}
[Test]
public async Task Serialization() {
LCObject obj = new LCObject("Hello");
Hello obj = new Hello();
obj["intValue"] = 123;
obj["boolValue"] = true;
obj["stringValue"] = "hello, world";

View File

@ -4,39 +4,31 @@ using System.Threading.Tasks;
using LeanCloud.Storage;
namespace Storage.Test {
public class OperationTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class OperationTest : BaseTest {
[Test]
public async Task Increment() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e154a5143c257006fbff63f");
TestContext.WriteLine(account["balance"]);
int balance = (int)account["balance"];
Account account = new Account {
Balance = 10
};
await account.Save();
TestContext.WriteLine(account.Balance);
account.Increment("balance", 100);
await account.Save();
TestContext.WriteLine(account["balance"]);
Assert.AreEqual((int)account["balance"], balance + 100);
TestContext.WriteLine(account.Balance);
Assert.AreEqual(account.Balance, 110);
}
[Test]
public async Task Decrement() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e154a5143c257006fbff63f");
TestContext.WriteLine(account["balance"]);
int balance = (int)account["balance"];
Account account = new Account {
Balance = 100
};
await account.Save();
TestContext.WriteLine(account.Balance);
account.Increment("balance", -10);
await account.Save();
TestContext.WriteLine(account["balance"]);
Assert.AreEqual((int)account["balance"], balance - 10);
TestContext.WriteLine(account.Balance);
Assert.AreEqual(account.Balance, 90);
}
[Test]

View File

@ -5,17 +5,7 @@ using System.Threading.Tasks;
using LeanCloud.Storage;
namespace Storage.Test {
public class QueryTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class QueryTest : BaseTest {
[Test]
public async Task BaseQuery() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
@ -80,19 +70,30 @@ namespace Storage.Test {
[Test]
public async Task Include() {
Hello hello = new Hello {
World = new World {
Content = "7788"
}
};
await hello.Save();
LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
query.Include("objectValue");
LCObject hello = await query.Get("5e0d55aedd3c13006a53cd87");
LCObject world = hello["objectValue"] as LCObject;
TestContext.WriteLine(world["content"]);
Assert.AreEqual(world["content"], "7788");
Hello queryHello = (await query.Get(hello.ObjectId)) as Hello;
World world = queryHello.World;
TestContext.WriteLine(world.Content);
Assert.AreEqual(world.Content, "7788");
}
[Test]
public async Task Get() {
Account account = new Account {
Balance = 1024
};
await account.Save();
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e0d9f7fd4b56c008e5d048a");
Assert.AreEqual(account["balance"], 400);
Account newAccount = (await query.Get(account.ObjectId)) as Account;
Assert.AreEqual(newAccount.Balance, 1024);
}
[Test]
@ -143,13 +144,19 @@ namespace Storage.Test {
[Test]
public async Task WhereObjectEquals() {
World world = new World();
Hello hello = new Hello {
World = world
};
await hello.Save();
LCQuery<LCObject> worldQuery = new LCQuery<LCObject>("World");
LCObject world = await worldQuery.Get("5e0d55ae21460d006a1ec931");
LCObject queryWorld = await worldQuery.Get(world.ObjectId);
LCQuery<LCObject> helloQuery = new LCQuery<LCObject>("Hello");
helloQuery.WhereEqualTo("objectValue", world);
LCObject hello = await helloQuery.First();
TestContext.WriteLine(hello.ObjectId);
Assert.AreEqual(hello.ObjectId, "5e0d55aedd3c13006a53cd87");
helloQuery.WhereEqualTo("objectValue", queryWorld);
LCObject queryHello = await helloQuery.First();
TestContext.WriteLine(queryHello.ObjectId);
Assert.AreEqual(queryHello.ObjectId, hello.ObjectId);
}
[Test]

View File

@ -4,23 +4,18 @@ using System.Collections.ObjectModel;
using LeanCloud.Storage;
namespace Storage.Test {
public class RelationTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class RelationTest : BaseTest {
private LCObject parent;
private LCObject c1;
private LCObject c2;
[Test]
[Order(0)]
public async Task AddAndRemove() {
LCObject parent = new LCObject("Parent");
LCObject c1 = new LCObject("Child");
parent = new LCObject("Parent");
c1 = new LCObject("Child");
parent.AddRelation("children", c1);
LCObject c2 = new LCObject("Child");
c2 = new LCObject("Child");
parent.AddRelation("children", c2);
await parent.Save();
@ -40,10 +35,11 @@ namespace Storage.Test {
}
[Test]
[Order(1)]
public async Task Query() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Parent");
LCObject parent = await query.Get("5e13112021b47e0070ed0922");
LCRelation<LCObject> relation = parent["children"] as LCRelation<LCObject>;
LCObject queryParent = await query.Get(parent.ObjectId);
LCRelation<LCObject> relation = queryParent["children"] as LCRelation<LCObject>;
TestContext.WriteLine(relation.Key);
TestContext.WriteLine(relation.Parent);

View File

@ -5,23 +5,13 @@ using System.Threading.Tasks;
using LeanCloud.Storage;
namespace Storage.Test {
[TestFixture]
public class RoleTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class RoleTest : BaseTest {
[Test]
public async Task NewRole() {
LCUser currentUser = await LCUser.Login("game", "play");
LCACL acl = new LCACL();
acl.PublicReadAccess = true;
LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
LCACL acl = new LCACL {
PublicReadAccess = true
};
acl.SetUserWriteAccess(currentUser, true);
string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
LCRole role = LCRole.Create(name, acl);

View File

@ -4,20 +4,10 @@ using System.Threading.Tasks;
using LeanCloud.Storage;
namespace Storage.Test {
public class SMSTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class SMSTest : BaseTest {
//[Test]
public async Task RequestSMS() {
await LCSMSClient.RequestSMSCode("15101006007",
await LCSMSClient.RequestSMSCode(TestPhone,
template: "test_template",
signature: "flutter-test",
variables: new Dictionary<string, object> {
@ -27,12 +17,12 @@ namespace Storage.Test {
//[Test]
public async Task RequestVoice() {
await LCSMSClient.RequestVoiceCode("+8615101006007");
await LCSMSClient.RequestVoiceCode(TestPhone);
}
//[Test]
[Test]
public async Task Verify() {
await LCSMSClient.VerifyMobilePhone("15101006007", "");
await LCSMSClient.VerifyMobilePhone(TestPhone, TestSMSCode);
}
}
}

View File

@ -6,21 +6,11 @@ using System.Collections.ObjectModel;
using LeanCloud.Storage;
namespace Storage.Test {
public class StatusTest {
public class StatusTest : BaseTest {
private LCUser user1;
private LCUser user2;
private LCUser user3;
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test]
[Order(0)]
public async Task Init() {

View File

@ -1,55 +1,12 @@
using NUnit.Framework;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
internal class Hello : LCObject {
internal World World => this["objectValue"] as World;
internal Hello() : base("Hello") { }
}
internal class World : LCObject {
internal string Content {
get {
return this["content"] as string;
} set {
this["content"] = value;
}
}
internal World() : base("World") { }
}
internal class Account : LCObject {
internal int Balance {
get {
return (int)this["balance"];
} set {
this["balance"] = value;
}
}
internal Account() : base("Account") { }
}
[TestFixture]
public class SubClassTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class SubClassTest : BaseTest {
[Test]
public async Task Create() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
Account account = new Account();
account.Balance = 1000;
await account.Save();
@ -59,7 +16,6 @@ namespace Storage.Test {
[Test]
public async Task Query() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
LCQuery<Account> query = new LCQuery<Account>("Account");
query.WhereGreaterThan("balance", 500);
ReadOnlyCollection<Account> list = await query.Find();
@ -72,29 +28,11 @@ namespace Storage.Test {
[Test]
public async Task Delete() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
Account account = new Account() {
Balance = 1024
};
await account.Save();
await account.Delete();
}
[Test]
public async Task Include() {
LCObject.RegisterSubclass<Hello>("Hello", () => new Hello());
LCObject.RegisterSubclass<World>("World", () => new World());
LCQuery<Hello> helloQuery = new LCQuery<Hello>("Hello");
helloQuery.Include("objectValue");
Hello hello = await helloQuery.Get("5e0d55aedd3c13006a53cd87");
World world = hello.World;
TestContext.WriteLine(hello.ObjectId);
Assert.AreEqual(hello.ObjectId, "5e0d55aedd3c13006a53cd87");
TestContext.WriteLine(world.ObjectId);
Assert.AreEqual(world.ObjectId, "5e0d55ae21460d006a1ec931");
Assert.AreEqual(world.Content, "7788");
}
}
}

View File

@ -7,18 +7,9 @@ using LeanCloud.Storage;
using LC.Newtonsoft.Json;
namespace Storage.Test {
public class UserTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
public class UserTest : BaseTest {
[Test]
[Order(0)]
public async Task SignUp() {
LCUser user = new LCUser();
long unixTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
@ -26,11 +17,11 @@ namespace Storage.Test {
user.Password = "world";
string email = $"{unixTime}@qq.com";
user.Email = email;
Random random = new Random();
string mobile = $"151{random.Next(10000000, 99999999)}";
user.Mobile = mobile;
//Random random = new Random();
//string mobile = $"151{random.Next(10000000, 99999999)}";
//user.Mobile = mobile;
await user.SignUp();
TestContext.WriteLine(user.Username);
TestContext.WriteLine(user.Password);
@ -42,40 +33,63 @@ namespace Storage.Test {
}
[Test]
[Order(1)]
public async Task Login() {
await LCUser.Login("hello", "world");
try {
await LCUser.Login(TestPhone, TestPhone);
} catch (LCException e) {
if (e.Code == 211) {
LCUser user = new LCUser {
Username = TestPhone,
Password = TestPhone,
Mobile = TestPhone,
Email = GetTestEmail()
};
await user.SignUp();
} else {
throw e;
}
}
await LCUser.Login(TestPhone, TestPhone);
LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId);
Assert.IsFalse(current.EmailVerified);
Assert.IsFalse(!current.MobileVerified);
Assert.AreEqual(current.Mobile, "15101006007");
Assert.IsTrue(current.MobileVerified);
Assert.AreEqual(current.Mobile, TestPhone);
}
[Test]
[Order(2)]
public async Task LoginByEmail() {
await LCUser.LoginByEmail("171253484@qq.com", "world");
await LCUser.LoginByEmail(GetTestEmail(), TestPhone);
LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId);
}
[Test]
[Order(3)]
public async Task LoginBySessionToken() {
LCUser user = await LCUser.Login(TestPhone, TestPhone);
string sessionToken = user.SessionToken;
await LCUser.Logout();
string sessionToken = "luo2fpl4qij2050e7enqfz173";
await LCUser.BecomeWithSessionToken(sessionToken);
LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId);
}
[Test]
[Order(4)]
public async Task RelateObject() {
LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "world");
LCObject account = new LCObject("Account");
account["user"] = user;
LCUser user = await LCUser.LoginByMobilePhoneNumber(TestPhone, TestPhone);
Account account = new Account();
account.User = user;
await account.Save();
}
[Test]
[Order(5)]
public async Task LoginAnonymous() {
LCUser user = await LCUser.LoginAnonymously();
Assert.NotNull(user.ObjectId);
@ -83,6 +97,7 @@ namespace Storage.Test {
}
[Test]
[Order(6)]
public async Task LoginWithAuthData() {
string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> {
@ -109,6 +124,7 @@ namespace Storage.Test {
}
[Test]
[Order(7)]
public async Task AssociateAuthData() {
string uuid = Guid.NewGuid().ToString();
LCUser currentUser = await LCUser.Login("hello", "world");
@ -123,12 +139,14 @@ namespace Storage.Test {
}
[Test]
[Order(8)]
public async Task DisassociateAuthData() {
LCUser currentUser = await LCUser.Login("hello", "world");
await currentUser.DisassociateWithAuthData("weixin");
}
[Test]
[Order(9)]
public async Task IsAuthenticated() {
LCUser currentUser = await LCUser.Login("hello", "world");
bool isAuthenticated = await currentUser.IsAuthenticated();
@ -137,13 +155,16 @@ namespace Storage.Test {
}
[Test]
[Order(10)]
public async Task UpdatePassword() {
LCUser currentUser = await LCUser.Login("hello", "world");
await currentUser.UpdatePassword("world", "newWorld");
await currentUser.UpdatePassword("newWorld", "world");
LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
string newPassword = "newpassword";
await currentUser.UpdatePassword(TestPhone, newPassword);
await currentUser.UpdatePassword(newPassword, TestPhone);
}
[Test]
[Order(11)]
public async Task LoginWithAuthDataWithUnionId() {
string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> {
@ -174,8 +195,9 @@ namespace Storage.Test {
}
[Test]
[Order(12)]
public async Task AssociateAuthDataWithUnionId() {
LCUser currentUser = await LCUser.Login("hello", "world");
LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> {
{ "expires_in", 7200 },
@ -188,22 +210,24 @@ namespace Storage.Test {
// 手动测试
//[Test]
//public async Task LoginByMobile() {
// LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "112358");
// Assert.NotNull(user.ObjectId);
//}
[Test]
[Order(13)]
public async Task LoginByMobile() {
LCUser user = await LCUser.LoginByMobilePhoneNumber(TestPhone, TestPhone);
Assert.NotNull(user.ObjectId);
}
//[Test]
//public async Task RequestLoginSMSCode() {
// await LCUser.RequestLoginSMSCode("15101006007");
//}
//[Test]
//public async Task LoginBySMSCode() {
// LCUser user = await LCUser.LoginBySMSCode("15101006007", "194998");
// Assert.NotNull(user.ObjectId);
//}
[Test]
[Order(14)]
public async Task LoginBySMSCode() {
LCUser user = await LCUser.LoginBySMSCode(TestPhone, TestSMSCode);
Assert.NotNull(user.ObjectId);
}
//[Test]
//public async Task RequestEmailVerify() {
@ -215,10 +239,11 @@ namespace Storage.Test {
// await LCUser.RequestMobilePhoneVerify("15101006007");
//}
//[Test]
//public async Task VerifyMobile() {
// await LCUser.VerifyMobilePhone("15101006007", "506993");
//}
[Test]
[Order(15)]
public async Task VerifyMobile() {
await LCUser.VerifyMobilePhone(TestPhone, TestSMSCode);
}
//[Test]
//public async Task RequestResetPasswordBySMSCode() {
@ -230,19 +255,21 @@ namespace Storage.Test {
// await LCUser.ResetPasswordBySmsCode("15101006007", "732552", "112358");
//}
[Test]
public async Task RequestSMSCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world");
await LCUser.RequestSMSCodeForUpdatingPhoneNumber("15101006007");
}
//[Test]
//public async Task RequestSMSCodeForUpdatingPhoneNumber() {
// await LCUser.Login(TestPhone, TestPhone);
// await LCUser.RequestSMSCodeForUpdatingPhoneNumber(TestPhone);
//}
[Test]
[Order(16)]
public async Task VerifyCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world");
await LCUser.VerifyCodeForUpdatingPhoneNumber("15101006007", "969327");
await LCUser.Login(TestPhone, TestPhone);
await LCUser.VerifyCodeForUpdatingPhoneNumber(TestPhone, TestSMSCode);
}
[Test]
[Order(17)]
public async Task AuthData() {
string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> {
@ -270,5 +297,9 @@ namespace Storage.Test {
TestContext.WriteLine(JsonConvert.SerializeObject(currentUser.AuthData));
}
}
private string GetTestEmail() {
return $"{TestPhone}@leancloud.rocks";
}
}
}

View File

@ -1,37 +0,0 @@
using NUnit.Framework;
using LeanCloud;
namespace Storage.Test {
public static class Utils {
internal const string AppId = "ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz";
internal const string AppKey = "NUKmuRbdAhg1vrb2wexYo1jo";
internal const string MasterKey = "pyvbNSh5jXsuFQ3C8EgnIdhw";
internal const string AppServer = "https://ikggdre2.lc-cn-n1-shared.com";
internal static void Print(LCLogLevel level, string info) {
switch (level) {
case LCLogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}");
break;
case LCLogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}");
break;
case LCLogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}");
break;
default:
TestContext.Out.WriteLine(info);
break;
}
}
internal static void SetUp() {
LCLogger.LogDelegate += Print;
LCApplication.Initialize(AppId, AppKey, AppServer);
}
internal static void TearDown() {
LCLogger.LogDelegate -= Print;
}
}
}

View File

@ -173,7 +173,7 @@ namespace LeanCloud.Storage {
if (role == null) {
throw new ArgumentNullException(nameof(role));
}
string roleKey = $"{RoleKeyPrefix}{role.ObjectId}";
string roleKey = $"{RoleKeyPrefix}{role.Name}";
return GetAccess(ReadAccess, roleKey);
}
@ -186,7 +186,7 @@ namespace LeanCloud.Storage {
if (role == null) {
throw new ArgumentNullException(nameof(role));
}
string roleKey = $"{RoleKeyPrefix}{role.ObjectId}";
string roleKey = $"{RoleKeyPrefix}{role.Name}";
SetAccess(ReadAccess, roleKey, value);
}
@ -199,7 +199,7 @@ namespace LeanCloud.Storage {
if (role == null) {
throw new ArgumentNullException(nameof(role));
}
string roleKey = $"{RoleKeyPrefix}{role.ObjectId}";
string roleKey = $"{RoleKeyPrefix}{role.Name}";
return GetAccess(WriteAccess, roleKey);
}
@ -212,7 +212,7 @@ namespace LeanCloud.Storage {
if (role == null) {
throw new ArgumentNullException(nameof(role));
}
string roleKey = $"{RoleKeyPrefix}{role.ObjectId}";
string roleKey = $"{RoleKeyPrefix}{role.Name}";
SetAccess(WriteAccess, roleKey, value);
}

View File

@ -30,7 +30,7 @@ namespace LeanCloud.Storage {
Dictionary<string, object> headers = new Dictionary<string, object> {
{ PRODUCTION_KEY, IsProduction ? 1 : 0 }
};
object encodeParams = LCEncoder.Encode(parameters);
object encodeParams = LCEncoder.Encode(parameters ?? new Dictionary<string, object>());
Dictionary<string, object> response = await LCCore.HttpClient.Post<Dictionary<string, object>>(path,
headers: headers,
data: encodeParams);
@ -59,7 +59,8 @@ namespace LeanCloud.Storage {
/// <param name="name">Cloud function name.</param>
/// <param name="parameters">Parameters of cloud function.</param>
/// <returns>LCObject, List<LCObject>, or Map<string, LCObject>.</returns>
public static async Task<object> RPC(string name, object parameters = null) {
public static async Task<object> RPC(string name,
object parameters = null) {
string path = $"call/{name}";
Dictionary<string, object> headers = new Dictionary<string, object> {
{ PRODUCTION_KEY, IsProduction ? 1 : 0 }

View File

@ -550,7 +550,7 @@ namespace LeanCloud.Storage {
}
async Task LinkWithAuthData(string authType, Dictionary<string, object> data) {
Dictionary<string, object> oriAuthData = new Dictionary<string, object>(AuthData);
Dictionary<string, object> oriAuthData = new Dictionary<string, object>(AuthData ?? new Dictionary<string, object>());
AuthData = new Dictionary<string, object> {
{ authType, data }
};