Skip to content

Commit

Permalink
Merge pull request #121 from CatLib/feature/1.3.0-alpha.3
Browse files Browse the repository at this point in the history
Feature/1.3.0 alpha.3
  • Loading branch information
喵喵大人 authored Dec 20, 2018
2 parents 137b0db + 5dc2d1c commit 6e73c28
Show file tree
Hide file tree
Showing 122 changed files with 762 additions and 573 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

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

`CatLib Core``CatLib` 的最小可用框架。仅提供最基础的功能,是其他框架开发者作为基础的理想选择。
Expand Down
1 change: 1 addition & 0 deletions src/CatLib.Core.Tests/CatLib.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<Compile Include="CatLib\ApplicationTests.cs" />
<Compile Include="CatLib\FacaedTests.cs" />
<Compile Include="CatLib\GlobalDispatcherTests.cs" />
<Compile Include="CatLib\TypeExtendTests.cs" />
<Compile Include="Support\Container\ContainerPerformanceTests.cs" />
<Compile Include="Support\Container\MethodContainerTests.cs" />
<Compile Include="Support\Dispatcher\DispatcherTests.cs" />
Expand Down
15 changes: 12 additions & 3 deletions src/CatLib.Core.Tests/CatLib/ApplicationTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down Expand Up @@ -242,7 +242,16 @@ public void TestTerminate()
Assert.AreEqual(1, num++);
});
App.Terminate();
Assert.AreNotEqual(oldApp, App.Handler);
var isCall = false;
try
{
Assert.AreNotEqual(oldApp, App.Handler);
}
catch (LogicException)
{
isCall = true;
}
Assert.AreEqual(true, isCall);
Assert.AreEqual(2, num);
}

Expand Down
11 changes: 9 additions & 2 deletions src/CatLib.Core.Tests/CatLib/FacaedTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down Expand Up @@ -345,5 +345,12 @@ public void TestStructBindToSingleRebound()
Assert.AreEqual(300, Facade<int>.Instance);
Assert.AreEqual(4, makeCount);
}

[TestMethod]
[ExpectedException(typeof(UnresolvableException))]
public void TestEmptyFacade()
{
var ins = Facade<IBindData>.Instance;
}
}
}
4 changes: 2 additions & 2 deletions src/CatLib.Core.Tests/CatLib/GlobalDispatcherTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
26 changes: 26 additions & 0 deletions src/CatLib.Core.Tests/CatLib/TypeExtendTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CatLib.Core.Tests
{
[TestClass]
public class TypeExtendTests
{
[TestMethod]
public void TestGetService()
{
var app = new Application();
Assert.AreEqual(App.Type2Service<TypeExtendTests>(), typeof(TypeExtendTests).ToService());
}
}
}
4 changes: 2 additions & 2 deletions src/CatLib.Core.Tests/ExceptionAssert.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down
4 changes: 2 additions & 2 deletions src/CatLib.Core.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System.Reflection;
Expand Down
6 changes: 3 additions & 3 deletions src/CatLib.Core.Tests/Support/Container/BindDataTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down Expand Up @@ -71,7 +71,7 @@ public void CanGetContextual()

Assert.AreEqual("abc", bindData.GetContextual("need1"));
Assert.AreEqual(container.Type2Service(typeof(BindDataTest)), bindData.GetContextual("need2"));
Assert.AreEqual("empty", bindData.GetContextual("empty"));
Assert.AreEqual(null, bindData.GetContextual("empty"));
}
#endregion

Expand Down
31 changes: 17 additions & 14 deletions src/CatLib.Core.Tests/Support/Container/ContainerHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down Expand Up @@ -62,7 +62,12 @@ public void BindSingleton()
Assert.AreSame(obj, container.Make("BindSingleton"));
}

public class ContainerHelperTestClass
public interface IContainerHelperTestClass
{

}

public class ContainerHelperTestClass : IContainerHelperTestClass
{

}
Expand All @@ -79,11 +84,9 @@ public class TestClassService
public void BindSingletonTServiceTConcrete()
{
var container = MakeContainer();
container.Singleton<TestClassService, ContainerHelperTestClass>();
var obj = container.Make(container.Type2Service(typeof(ContainerHelperTestClass)));
var obj2 = container.Make(container.Type2Service(typeof(TestClassService)));

Assert.AreSame(obj, obj2);
container.Singleton<IContainerHelperTestClass, ContainerHelperTestClass>();
var obj = container.Make(container.Type2Service(typeof(IContainerHelperTestClass)));
Assert.AreNotEqual(null, obj);
}

/// <summary>
Expand Down Expand Up @@ -146,10 +149,10 @@ public void TestBindIf()
Assert.AreEqual(true, App.BindIf<int>(() => 100, out bindData));
Assert.AreEqual(100, App.Make<int>());
Assert.AreEqual(100, App.Make<int>()); // double get check
Assert.AreEqual(true, App.BindIf<double, float>(out bindData));
Assert.AreEqual(false, App.BindIf<double, float>(out bindData));
Assert.AreEqual(true, App.BindIf<float, float>(out bindData));
Assert.AreEqual(false, App.BindIf<float, float>(out bindData));

Assert.AreEqual(typeof(double), App.Make<double>(App.Type2Service(typeof(float))).GetType());
Assert.AreEqual(typeof(float), App.Make<float>(App.Type2Service(typeof(float))).GetType());
}

[TestMethod]
Expand All @@ -172,10 +175,10 @@ public void TestSingletonIf()
Assert.AreEqual(true, App.SingletonIf<long>((c, p) => 100, out bindData));
Assert.AreEqual(true, App.SingletonIf<int>(() => 100, out bindData));
Assert.AreEqual(100, App.Make<int>());
Assert.AreEqual(true, App.SingletonIf<double, float>(out bindData));
Assert.AreEqual(false, App.SingletonIf<double, float>(out bindData));
Assert.AreEqual(true, App.SingletonIf<float, float>(out bindData));
Assert.AreEqual(false, App.SingletonIf<float, float>(out bindData));

Assert.AreEqual(typeof(double), App.Make<double>(App.Type2Service(typeof(float))).GetType());
Assert.AreEqual(typeof(float), App.Make<float>(App.Type2Service(typeof(float))).GetType());
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
* Document: https://catlib.io/
*/

using System;
Expand Down
Loading

0 comments on commit 6e73c28

Please sign in to comment.