diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-04-22 13:59:10 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-04-22 13:59:10 +0300 |
| commit | 531c3aba8b49d38f53890c61aa3addef3b5c28dd (patch) | |
| tree | 0a913689a8968bcea2e174d90f0d423ffa3ccaca /Software/Visual_Studio/Tango.UnitTesting | |
| parent | 540272c93c7d0b4a12ea797c996f2c9ddf2a5bbb (diff) | |
| parent | 24e4a3e25a9ac161097a46b59aee637fe7bdaa50 (diff) | |
| download | Tango-531c3aba8b49d38f53890c61aa3addef3b5c28dd.tar.gz Tango-531c3aba8b49d38f53890c61aa3addef3b5c28dd.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs | 63 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs new file mode 100644 index 000000000..d1b888ed4 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs @@ -0,0 +1,63 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; + +namespace Tango.UnitTesting +{ + [TestClass] + [TestCategory("Dependency Injection")] + public class DependencyInjection_TST + { + [TestMethod] + public void Test_Tango_Dependency_Injection() + { + TangoIOC.Default.Register<IDataProvider, DataProvider>(); + TangoIOC.Default.Register<IService, Service>(); + TangoIOC.Default.Register<ViewModel>(); + + var vm = TangoIOC.Default.GetInstance<ViewModel>(); + + Assert.IsNotNull(vm); + Assert.IsNotNull(vm.Service); + Assert.IsNotNull(vm.DataProvider); + Assert.IsNotNull(vm.Service.DataProvider); + } + + public class ViewModel + { + public IService Service { get; set; } + public IDataProvider DataProvider { get; set; } + + public ViewModel(IService service, IDataProvider dataProvider) + { + DataProvider = dataProvider; + Service = service; + } + } + + public interface IDataProvider + { + + } + + public class DataProvider : IDataProvider + { + + } + + public interface IService + { + IDataProvider DataProvider { get; set; } + } + + public class Service : IService + { + [TangoInject] + public IDataProvider DataProvider { get; set; } + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 1378ed1d4..03d3dc4a7 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -85,6 +85,7 @@ <Compile Include="..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="DependencyInjection_TST.cs" /> <Compile Include="Logging_TST.cs" /> <Compile Include="MachineStudio_TST.cs" /> <Compile Include="Scripting_TST.cs" /> |
