Пример #1
0
 public void NullCanBeAddedAndHasNoEffect()
 {
     var target = new Joint();
     target.Add(null);
     Assert.IsFalse(target.Has<object>());
     Assert.IsNull(target.Get<object>());
     Assert.Throws<InvalidOperationException>(() => target.The<object>());
 }
Пример #2
0
        public void NullCanBeAddedAndHasNoEffect()
        {
            var target = new Joint();

            target.Add(null);
            Assert.IsFalse(target.Has <object>());
            Assert.IsNull(target.Get <object>());
            Assert.Throws <InvalidOperationException>(() => target.The <object>());
        }
Пример #3
0
        public void SetGetSingleTest()
        {
            var target = new Joint();
            var inst   = new TestService();

            target.Add <TestService>(inst);

            Assert.IsTrue(target.Has <TestService>());
            Assert.AreSame(inst, target.The <TestService>());
            Assert.AreSame(inst, target.Get <TestService>());

            Assert.IsTrue(target.Has <ITestService>());
            Assert.AreSame(inst, target.The <ITestService>());
        }
Пример #4
0
        public void SetGetSingleTest()
        {
            var target = new Joint();
            var inst = new TestService();

            target.Add<TestService>(inst);

            Assert.IsTrue(target.Has<TestService>());
            Assert.AreSame(inst, target.The<TestService>());
            Assert.AreSame(inst, target.Get<TestService>());

            Assert.IsTrue(target.Has<ITestService>());
            Assert.AreSame(inst, target.The<ITestService>());
        }
Пример #5
0
        public void SetGetMultipleTest()
        {
            var target    = new Joint();
            var instances = new[] { new TestService(), new TestService(), new TestService() };

            foreach (var inst in instances)
            {
                target.Add <TestService>(inst);
            }

            Assert.IsTrue(target.Has <TestService>());
            Assert.AreEqual(instances, target.All <TestService>().ToArray());
            Assert.AreEqual(instances, target.All <ITestService>().ToArray());

            Assert.Throws <InvalidOperationException>(() => target.The <TestService>());
            Assert.Throws <InvalidOperationException>(() => target.The <ITestService>());
            Assert.Throws <InvalidOperationException>(() => target.Get <ITestService>());
            Assert.Throws <InvalidOperationException>(() => target.Get <TestService>());
        }
Пример #6
0
        public void SetGetMultipleTest()
        {
            var target = new Joint();
            var instances = new[] { new TestService(), new TestService(), new TestService() };

            foreach (var inst in instances)
            {
                target.Add<TestService>(inst);
            }

            Assert.IsTrue(target.Has<TestService>());
            Assert.AreEqual(instances, target.All<TestService>().ToArray());
            Assert.AreEqual(instances, target.All<ITestService>().ToArray());

            Assert.Throws<InvalidOperationException>(() => target.The<TestService>());
            Assert.Throws<InvalidOperationException>(() => target.The<ITestService>());
            Assert.Throws<InvalidOperationException>(() => target.Get<ITestService>());
            Assert.Throws<InvalidOperationException>(() => target.Get<TestService>());
        }