Skip to content

Commit

Permalink
Merge pull request #61 from The-Poolz/update-to-version-1.3.2
Browse files Browse the repository at this point in the history
Update to version 1.3.2
  • Loading branch information
NikitaBuschan authored Jun 3, 2022
2 parents d65fb6f + 3d59548 commit 4da10cc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 11 deletions.
4 changes: 0 additions & 4 deletions QuickSQL.Tests/QuickSQL.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@
<ProjectReference Include="..\QuickSQL\QuickSQL.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Tests\Request\" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions QuickSQL.Tests/Tests/Request/OrderRule.Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Xunit;
using System.Text.Json;

namespace QuickSQL.Tests.Requests
{
public static class OrderRuleTests
{
[Fact]
public static void CreateOrderRule()
{
var orederRule = new OrderRule();

Assert.NotNull(orederRule);
Assert.IsType<OrderRule>(orederRule);
}

[Fact]
public static void CreateOrderRuleWithParams()
{
var orederRule = new OrderRule("Id", SortBy.DESC);

Assert.NotNull(orederRule);
Assert.IsType<OrderRule>(orederRule);
}

[Fact]
public static void SerializeObject()
{
var orederRule = new OrderRule("Id", SortBy.DESC);

var result = JsonSerializer.Serialize(orederRule);

Assert.NotNull(result);
Assert.IsType<string>(result);
Assert.Equal("{\"ColumnName\":\"Id\",\"Sort\":1}", result);
}
}
}
4 changes: 0 additions & 4 deletions QuickSQL/QuickSQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions QuickSQL/QuickSql.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json;

using QuickSQL.DataReader;
using QuickSQL.QueryCreator;
Expand Down Expand Up @@ -35,7 +35,7 @@ public static object InvokeRequest(Request request, string connectionString, Bas

string commandQuery = queryCreator.CreateCommandQuery(request);
string jsonResult = dataReader.GetJsonData(commandQuery, connectionString);
return JsonConvert.DeserializeObject(jsonResult);
return JsonSerializer.Deserialize<object>(jsonResult);
}
}
}
20 changes: 20 additions & 0 deletions QuickSQL/Request/OrderRule/OrderRule.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
namespace QuickSQL
{
/// <summary>
/// This class is an object that combines the name of the sorted column and the sorting direction.
/// </summary>
public class OrderRule
{
/// <summary>
/// Don't use this, as object parameters are only set on initialization.<br/>
/// This constructor for JSON serializing.
/// </summary>
public OrderRule() { }
/// <summary>
/// Create a order rule.
/// </summary>
/// <param name="columnName">Enter the name of the column to be sorted.</param>
/// <param name="sort">Enter <see cref="SortBy"/> to customize sorting.<br/>
/// Default value: <see cref="SortBy.ASC"/> </param>
public OrderRule(string columnName, SortBy sort = SortBy.ASC)
{
ColumnName = columnName;
Sort = sort;
}
/// <summary>
/// The name of the column that will be sorted.
/// </summary>
public string ColumnName { get; init; }
/// <summary>
/// Sorting direction. Default value: <see cref="SortBy.ASC"/>
/// </summary>
public SortBy Sort { get; init; }
}
}
3 changes: 2 additions & 1 deletion QuickSQL/Request/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace QuickSQL
public class Request
{
/// <summary>
/// Constructor for JSON serializing.
/// Don't use this, as object parameters are only set on initialization.<br/>
/// This constructor for JSON serializing.
/// </summary>
public Request() { }
/// <summary>
Expand Down

0 comments on commit 4da10cc

Please sign in to comment.