Esempio n. 1
0
        public void TryAddTransient()
        {
            IDependencyCollection collection = new DependencyCollection();

            collection.HasDependency <TestDisposable>().ShouldBeFalse();
            collection.HasDependency <TestDependency>().ShouldBeFalse();

            collection.CheckIfAdded <TestDisposable>(c =>
            {
                c.TryRegister(() => new TestDisposable
                {
                    IntValue    = 171,
                    StringValue = "Hello World"
                }).AsTransient();
            }).ShouldBeTrue();

            collection.CheckIfAdded <TestDependency>(c =>
            {
                c.TryRegister <TestDependency>().AsTransient();
            }).ShouldBeTrue();

            collection.CheckIfAdded <TestDisposable>(c =>
            {
                c.TryRegister(() => new TestDisposable()).AsTransient();
            }).ShouldBeFalse();

            collection.CheckIfAdded <TestDependency>(c =>
            {
                c.TryRegister <TestDependency>().AsTransient();
            }).ShouldBeFalse();

            collection.HasDependency <TestDisposable>().ShouldBeTrue();
            collection.HasDependency <TestDependency>().ShouldBeTrue();
        }