public void TestInrefaceFive() { DependenciesConfiguration configuration = new DependenciesConfiguration(); configuration.Register <IGetNum, GetFive>(TimeToLive.InstancePerDependency); DependencyProvider provider = new DependencyProvider(configuration); Mock <IGetNum> mockActual = new Mock <IGetNum>(); mockActual.Setup(mock => mock.GetNum()).Returns(5); var expected = provider.Resolve <IGetNum>(); var actual = new GetFive(); try { Assert.AreEqual(expected.GetNum(), mockActual.Object.GetNum()); Assert.IsTrue(expected is GetFive); Assert.AreEqual(expected.GetNum(), actual.GetNum()); logger.Info(nameof(TestInrefaceFive) + " - passed"); } catch (Exception e) { logger.Error(e, nameof(TestInrefaceFive) + " - failed"); } }
public void TestNameDependenies() { DependenciesConfiguration configuration = new DependenciesConfiguration(); configuration.Register <IGetNum, GetFive>(TimeToLive.InstancePerDependency, Numbers.Five); configuration.Register <IGetNum, GetSeven>(TimeToLive.InstancePerDependency, Numbers.Seven); configuration.Register <IGetNum, GetTen>(TimeToLive.InstancePerDependency, Numbers.Ten); DependencyProvider provider = new DependencyProvider(configuration); var actualSeven = provider.Resolve <IGetNum>(Numbers.Seven); var actualFive = provider.Resolve <IGetNum>(Numbers.Five); var actualTen = provider.Resolve <IGetNum>(Numbers.Ten); var expectedSeven = new GetSeven(); var expectedFive = new GetFive(); var expectedTen = new GetTen(); try { Assert.IsTrue(actualSeven is GetSeven); Assert.IsTrue(actualFive is GetFive); Assert.IsTrue(actualTen is GetTen); Assert.AreEqual(expectedSeven.GetNum(), actualSeven.GetNum()); Assert.AreEqual(expectedFive.GetNum(), actualFive.GetNum()); Assert.AreEqual(expectedTen.GetNum(), actualTen.GetNum()); logger.Info(nameof(TestNameDependenies) + " - passed"); } catch (Exception e) { logger.Error(e, nameof(TestNameDependenies) + " - failed"); } }
public void TestAbsractrFive() { DependenciesConfiguration configuration = new DependenciesConfiguration(); configuration.Register <GetAbsNum, GetFive>(TimeToLive.InstancePerDependency); DependencyProvider provider = new DependencyProvider(configuration); var actual = provider.Resolve <GetAbsNum>(); var expected = new GetFive(); try { Assert.IsTrue(actual is GetFive); Assert.AreEqual(expected.GetNumAbs(), actual.GetNumAbs()); logger.Info(nameof(TestAbsractrFive) + " - passed"); } catch (Exception e) { logger.Error(e, nameof(TestAbsractrFive) + " - failed"); } }