Skip to content

Commit 378149e

Browse files
author
喵喵大人
authored
Merge pull request #40 from CatLib/feature/1.2.9
Feature/1.2.9
2 parents ea02961 + ddb1ef2 commit 378149e

File tree

25 files changed

+468
-136
lines changed

25 files changed

+468
-136
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
**使用Nuget安装**
2929

3030
```PM
31-
Install-Package CatLib.Core -Version 1.2.8
31+
Install-Package CatLib.Core -Version 1.2.9
3232
```
3333

3434
**直接下载发布版本**

src/CatLib.Core.NetStandard/CatLib.Core.NetStandard.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@
118118
<Compile Include="..\CatLib.Core\Support\Util\Arr.cs" Link="Support\Util\Arr.cs" />
119119
<Compile Include="..\CatLib.Core\Support\Util\Dict.cs" Link="Support\Util\Dict.cs" />
120120
<Compile Include="..\CatLib.Core\Support\Util\Enum.cs" Link="Support\Util\Enum.cs" />
121+
<Compile Include="..\CatLib.Core\Support\Util\Extension\IntExtension.cs" Link="Support\Util\Extension\IntExtension.cs" />
122+
<Compile Include="..\CatLib.Core\Support\Util\Extension\StreamExtension.cs" Link="Support\Util\Extension\StreamExtension.cs" />
121123
<Compile Include="..\CatLib.Core\Support\Util\IAwait.cs" Link="Support\Util\IAwait.cs" />
122124
<Compile Include="..\CatLib.Core\Support\Util\Str.cs" Link="Support\Util\Str.cs" />
123125
<Compile Include="..\CatLib.Core\Support\Util\SystemTime.cs" Link="Support\Util\SystemTime.cs" />
126+
<Compile Include="..\CatLib.Core\Support\Util\ThreadStatic.cs" Link="Support\Util\ThreadStatic.cs" />
124127
<Compile Include="..\CatLib.Core\Support\Util\Util.cs" Link="Support\Util\Util.cs" />
125128
<Compile Include="..\CatLib.Core\Support\Util\Version.cs" Link="Support\Util\Version.cs" />
126129
</ItemGroup>
@@ -139,6 +142,7 @@
139142
<Folder Include="Support\Template\" />
140143
<Folder Include="Support\RingBuffer\" />
141144
<Folder Include="Support\Storage\" />
145+
<Folder Include="Support\Util\Extension\" />
142146
</ItemGroup>
143147

144148
</Project>

src/CatLib.Core.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525

2626
[assembly: Guid("3c9f4024-910c-4881-a04d-34a6c3a09019")]
2727

28-
[assembly: AssemblyVersion("1.2.8.0")]
29-
[assembly: AssemblyFileVersion("1.2.8.0")]
28+
[assembly: AssemblyVersion("1.2.9.0")]
29+
[assembly: AssemblyFileVersion("1.2.9.0")]

src/CatLib.Core.Tests/Support/Container/BindDataTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,28 @@ public void CheckIllegalAlias()
116116
}
117117
#endregion
118118

119+
#region Tag
120+
/// <summary>
121+
/// 是否能增加标签
122+
/// </summary>
123+
[TestMethod]
124+
public void CanAddTag()
125+
{
126+
var container = new Container();
127+
var bindData = container.Bind("data", (app, param) => "hello world", false);
128+
129+
bindData.Tag("tag1").Tag("tag2");
130+
131+
var data = container.Tagged("tag1");
132+
Assert.AreEqual(1, data.Length);
133+
Assert.AreEqual("hello world", data[0]);
134+
135+
data = container.Tagged("tag2");
136+
Assert.AreEqual(1, data.Length);
137+
Assert.AreEqual("hello world", data[0]);
138+
}
139+
#endregion
140+
119141
#region OnRelease
120142
/// <summary>
121143
/// 是否能追加到释放事件

src/CatLib.Core.Tests/Support/Template/ManagerTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* Document: http://catlib.io/
1010
*/
1111

12-
using System;
1312
using Microsoft.VisualStudio.TestTools.UnitTesting;
1413

1514
namespace CatLib.Tests.Stl
@@ -19,9 +18,9 @@ public sealed class ManagerTests
1918
{
2019
private class TestManagerClass : Manager<TestManagerClass>
2120
{
22-
public Func<TestManagerClass> GetResolvePublic(string name)
21+
public void GetResolvePublic(string name)
2322
{
24-
return GetExtend(name);
23+
MakeExtend(name);
2524
}
2625
}
2726

@@ -86,8 +85,6 @@ public void TestGetExtend()
8685
{
8786
return new TestManagerClass();
8887
});
89-
90-
Assert.AreNotEqual(null, cls.GetResolvePublic(null));
9188
}
9289
}
9390
}

src/CatLib.Core.Tests/Support/Template/SingleManagerTests.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,46 @@ public void TestCoverToSingleManagerGet()
5151
Assert.AreSame(manager.Default, manager2.Get());
5252
}
5353

54+
[TestMethod]
55+
public void TestContains()
56+
{
57+
var manager = new TestManager();
58+
manager.Extend(() => new InterfaceImpl());
59+
bool resolve = false, release = false;
60+
manager.OnResolving += (_) =>
61+
{
62+
resolve = true;
63+
};
64+
manager.OnRelease += (_) =>
65+
{
66+
release = true;
67+
};
68+
Assert.AreEqual(false, manager.Contains());
69+
Assert.AreEqual(false, resolve);
70+
Assert.AreEqual(false, release);
71+
manager.Get();
72+
Assert.AreEqual(true, resolve);
73+
Assert.AreEqual(true, manager.Contains());
74+
manager.Release();
75+
Assert.AreEqual(true, release);
76+
Assert.AreEqual(false, manager.Contains());
77+
}
78+
79+
[TestMethod]
80+
public void TestDispose()
81+
{
82+
var manager = new TestManager();
83+
manager.Extend(() => new InterfaceImpl());
84+
manager.Extend(() => new InterfaceImpl(), "name-2");
85+
manager.Get();
86+
manager.Get("name-2");
87+
Assert.AreEqual(true, manager.Contains());
88+
Assert.AreEqual(true, manager.Contains("name-2"));
89+
manager.Dispose();
90+
Assert.AreEqual(false, manager.Contains());
91+
Assert.AreEqual(false, manager.Contains("name-2"));
92+
}
93+
5494
[TestMethod]
5595
public void TestCoverToInterfaceSingleManagerGet()
5696
{
@@ -76,7 +116,7 @@ public void TestManagerRelease()
76116
public void TestContainsExtend()
77117
{
78118
var manager = new TestManager();
79-
manager.Extend(() => new InterfaceImpl() , "hello");
119+
manager.Extend(() => new InterfaceImpl(), "hello");
80120

81121
Assert.AreEqual(false, manager.ContainsExtend());
82122
Assert.AreEqual(true, manager.ContainsExtend("hello"));

src/CatLib.Core.Tests/Support/Util/ArrTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,15 @@ public void TestIndexOfString()
499499
Assert.AreEqual(3, result);
500500
}
501501

502+
[TestMethod]
503+
public void TestIndexOfString2()
504+
{
505+
var data = new[] { "a", "b", "c", "d", "e" };
506+
var result = Arr.IndexOf(data, new[] { "d"});
507+
508+
Assert.AreEqual(3, result);
509+
}
510+
502511
[TestMethod]
503512
public void TestIndexOfNull()
504513
{
@@ -514,6 +523,36 @@ public void TestIndexNotFind()
514523
Assert.AreEqual(-1, result);
515524
}
516525

526+
[TestMethod]
527+
public void TestIndexOfAny()
528+
{
529+
var data = new[] { 'a', 'b', 'c', 'd', 'e' };
530+
var result = Arr.IndexOfAny(data, new[] { 'e', 'd' , 'b' });
531+
532+
Assert.AreEqual(1, result);
533+
}
534+
535+
[TestMethod]
536+
public void TestIndexAnyNotFind()
537+
{
538+
var data = new[] { 'a', 'b', 'c', 'd', 'e' };
539+
var result = Arr.IndexOfAny(data, new[] { 'z' });
540+
541+
Assert.AreEqual(-1, result);
542+
}
543+
544+
[TestMethod]
545+
public void TestIndexOfAnyNull()
546+
{
547+
var data = new[] { 'a', 'b', 'c', 'd', 'e' };
548+
var result = Arr.IndexOfAny(data, null);
549+
550+
Assert.AreEqual(-1, result);
551+
result = Arr.IndexOfAny<string>(null, null);
552+
553+
Assert.AreEqual(-1, result);
554+
}
555+
517556
[TestMethod]
518557
public void TestDifference()
519558
{

src/CatLib.Core/CatLib.Core.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@
101101
<Compile Include="Support\Template\SingleManager.cs" />
102102
<Compile Include="Support\Util\Arr.cs" />
103103
<Compile Include="Support\Util\Enum.cs" />
104+
<Compile Include="Support\Util\Extension\IntExtension.cs" />
104105
<Compile Include="Support\Util\IAwait.cs" />
105106
<Compile Include="Support\Util\Str.cs" />
106-
<Compile Include="Support\Util\StreamExtension.cs" />
107+
<Compile Include="Support\Util\Extension\StreamExtension.cs" />
107108
<Compile Include="Support\Util\SystemTime.cs" />
109+
<Compile Include="Support\Util\ThreadStatic.cs" />
108110
<Compile Include="Support\Util\Util.cs" />
109111
<Compile Include="Support\Util\Version.cs" />
110112
</ItemGroup>

src/CatLib.Core/CatLib/Application.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Application : Container, IApplication, IOriginalDispatcher
2323
/// <summary>
2424
/// 版本号
2525
/// </summary>
26-
private readonly Version version = new Version("1.2.2");
26+
private readonly Version version = new Version("1.2.9");
2727

2828
/// <summary>
2929
/// 框架启动流程

src/CatLib.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
[assembly: Guid("4204658e-81fd-4106-a347-890cd369c8a4")]
2828

29-
[assembly: AssemblyVersion("1.2.8.0")]
30-
[assembly: AssemblyFileVersion("1.2.8.0")]
29+
[assembly: AssemblyVersion("1.2.9.0")]
30+
[assembly: AssemblyFileVersion("1.2.9.0")]
3131

3232
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor"),
3333
InternalsVisibleTo("Assembly-CSharp-Editor-firstpass"),

0 commit comments

Comments
 (0)