Skip to content

Commit 6e73c28

Browse files
author
喵喵大人
authored
Merge pull request #121 from CatLib/feature/1.3.0-alpha.3
Feature/1.3.0 alpha.3
2 parents 137b0db + 5dc2d1c commit 6e73c28

File tree

122 files changed

+762
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+762
-573
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
> We are currently preparing to convert the comments in the code to the English version. We look forward to your joining.
1616
17-
> CatLib Framework 请访问:[CatLib/Framework](https://github.com/CatLib/Framework)
18-
19-
> CatLib For Unity 请访问:[CatLib/CatLib](https://github.com/CatLib/CatLib)
20-
2117
## 关于CatLib
2218

2319
`CatLib Core``CatLib` 的最小可用框架。仅提供最基础的功能,是其他框架开发者作为基础的理想选择。

src/CatLib.Core.Tests/CatLib.Core.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<Compile Include="CatLib\ApplicationTests.cs" />
3838
<Compile Include="CatLib\FacaedTests.cs" />
3939
<Compile Include="CatLib\GlobalDispatcherTests.cs" />
40+
<Compile Include="CatLib\TypeExtendTests.cs" />
4041
<Compile Include="Support\Container\ContainerPerformanceTests.cs" />
4142
<Compile Include="Support\Container\MethodContainerTests.cs" />
4243
<Compile Include="Support\Dispatcher\DispatcherTests.cs" />

src/CatLib.Core.Tests/CatLib/ApplicationTests.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System;
@@ -242,7 +242,16 @@ public void TestTerminate()
242242
Assert.AreEqual(1, num++);
243243
});
244244
App.Terminate();
245-
Assert.AreNotEqual(oldApp, App.Handler);
245+
var isCall = false;
246+
try
247+
{
248+
Assert.AreNotEqual(oldApp, App.Handler);
249+
}
250+
catch (LogicException)
251+
{
252+
isCall = true;
253+
}
254+
Assert.AreEqual(true, isCall);
246255
Assert.AreEqual(2, num);
247256
}
248257

src/CatLib.Core.Tests/CatLib/FacaedTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System;
@@ -345,5 +345,12 @@ public void TestStructBindToSingleRebound()
345345
Assert.AreEqual(300, Facade<int>.Instance);
346346
Assert.AreEqual(4, makeCount);
347347
}
348+
349+
[TestMethod]
350+
[ExpectedException(typeof(UnresolvableException))]
351+
public void TestEmptyFacade()
352+
{
353+
var ins = Facade<IBindData>.Instance;
354+
}
348355
}
349356
}

src/CatLib.Core.Tests/CatLib/GlobalDispatcherTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using Microsoft.VisualStudio.TestTools.UnitTesting;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* This file is part of the CatLib package.
3+
*
4+
* (c) CatLib <support@catlib.io>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Document: https://catlib.io/
10+
*/
11+
12+
using Microsoft.VisualStudio.TestTools.UnitTesting;
13+
14+
namespace CatLib.Core.Tests
15+
{
16+
[TestClass]
17+
public class TypeExtendTests
18+
{
19+
[TestMethod]
20+
public void TestGetService()
21+
{
22+
var app = new Application();
23+
Assert.AreEqual(App.Type2Service<TypeExtendTests>(), typeof(TypeExtendTests).ToService());
24+
}
25+
}
26+
}

src/CatLib.Core.Tests/ExceptionAssert.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System.Reflection;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System;
@@ -71,7 +71,7 @@ public void CanGetContextual()
7171

7272
Assert.AreEqual("abc", bindData.GetContextual("need1"));
7373
Assert.AreEqual(container.Type2Service(typeof(BindDataTest)), bindData.GetContextual("need2"));
74-
Assert.AreEqual("empty", bindData.GetContextual("empty"));
74+
Assert.AreEqual(null, bindData.GetContextual("empty"));
7575
}
7676
#endregion
7777

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* This file is part of the CatLib package.
33
*
4-
* (c) Yu Bin <support@catlib.io>
4+
* (c) CatLib <support@catlib.io>
55
*
66
* For the full copyright and license information, please view the LICENSE
77
* file that was distributed with this source code.
88
*
9-
* Document: http://catlib.io/
9+
* Document: https://catlib.io/
1010
*/
1111

1212
using System;
@@ -62,7 +62,12 @@ public void BindSingleton()
6262
Assert.AreSame(obj, container.Make("BindSingleton"));
6363
}
6464

65-
public class ContainerHelperTestClass
65+
public interface IContainerHelperTestClass
66+
{
67+
68+
}
69+
70+
public class ContainerHelperTestClass : IContainerHelperTestClass
6671
{
6772

6873
}
@@ -79,11 +84,9 @@ public class TestClassService
7984
public void BindSingletonTServiceTConcrete()
8085
{
8186
var container = MakeContainer();
82-
container.Singleton<TestClassService, ContainerHelperTestClass>();
83-
var obj = container.Make(container.Type2Service(typeof(ContainerHelperTestClass)));
84-
var obj2 = container.Make(container.Type2Service(typeof(TestClassService)));
85-
86-
Assert.AreSame(obj, obj2);
87+
container.Singleton<IContainerHelperTestClass, ContainerHelperTestClass>();
88+
var obj = container.Make(container.Type2Service(typeof(IContainerHelperTestClass)));
89+
Assert.AreNotEqual(null, obj);
8790
}
8891

8992
/// <summary>
@@ -146,10 +149,10 @@ public void TestBindIf()
146149
Assert.AreEqual(true, App.BindIf<int>(() => 100, out bindData));
147150
Assert.AreEqual(100, App.Make<int>());
148151
Assert.AreEqual(100, App.Make<int>()); // double get check
149-
Assert.AreEqual(true, App.BindIf<double, float>(out bindData));
150-
Assert.AreEqual(false, App.BindIf<double, float>(out bindData));
152+
Assert.AreEqual(true, App.BindIf<float, float>(out bindData));
153+
Assert.AreEqual(false, App.BindIf<float, float>(out bindData));
151154

152-
Assert.AreEqual(typeof(double), App.Make<double>(App.Type2Service(typeof(float))).GetType());
155+
Assert.AreEqual(typeof(float), App.Make<float>(App.Type2Service(typeof(float))).GetType());
153156
}
154157

155158
[TestMethod]
@@ -172,10 +175,10 @@ public void TestSingletonIf()
172175
Assert.AreEqual(true, App.SingletonIf<long>((c, p) => 100, out bindData));
173176
Assert.AreEqual(true, App.SingletonIf<int>(() => 100, out bindData));
174177
Assert.AreEqual(100, App.Make<int>());
175-
Assert.AreEqual(true, App.SingletonIf<double, float>(out bindData));
176-
Assert.AreEqual(false, App.SingletonIf<double, float>(out bindData));
178+
Assert.AreEqual(true, App.SingletonIf<float, float>(out bindData));
179+
Assert.AreEqual(false, App.SingletonIf<float, float>(out bindData));
177180

178-
Assert.AreEqual(typeof(double), App.Make<double>(App.Type2Service(typeof(float))).GetType());
181+
Assert.AreEqual(typeof(float), App.Make<float>(App.Type2Service(typeof(float))).GetType());
179182
}
180183

181184
[TestMethod]

0 commit comments

Comments
 (0)