From 24e4a3e25a9ac161097a46b59aee637fe7bdaa50 Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 21 Apr 2018 23:00:22 +0300 Subject: Started working on TangoIOC --- .../Tango.UnitTesting/DependencyInjection_TST.cs | 63 ++++++++++++++++++++++ .../Tango.UnitTesting/Tango.UnitTesting.csproj | 1 + 2 files changed, 64 insertions(+) create mode 100644 Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs (limited to 'Software/Visual_Studio/Tango.UnitTesting') 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(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + + var vm = TangoIOC.Default.GetInstance(); + + 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 @@ GlobalVersionInfo.cs + -- cgit v1.3.1