public void WhenSingletonDoesNotImplementIDisposable_DoesNotReturnError()
        {
            //arrange
            var sut      = GetSut();
            var instance = new SingletonInstanceProvider <NotDisposableClass>(InstanceProtectionMode.NoProtection);
            //act
            var isSatisfied = sut.IsSatisfiedBy(instance);
            var errors      = sut.Errors;

            //assert
            Assert.That(isSatisfied, Is.True);
            Assert.That(errors, Is.Null.Or.Empty);
        }
        public void WhenSingletonImplementsIDisposable_ReturnsError()
        {
            //arrange
            var sut      = GetSut();
            var instance = new SingletonInstanceProvider <DisposableClass>(InstanceProtectionMode.NoProtection);
            //act
            var isSatisfied = sut.IsSatisfiedBy(instance);
            var errors      = sut.Errors;

            //assert
            Assert.That(isSatisfied, Is.False);
            Assert.That(errors, Is.Not.Null.Or.Empty);
            Assert.That(errors.Count(), Is.EqualTo(1));
        }
예제 #3
0
        public void WhenSingletonDependsOnTransient_ReturnsError()
        {
            //arrange
            var instanceProviders = new List <IInstanceProvider>();
            var singleton         = new SingletonInstanceProvider <Singleton>(InstanceProtectionMode.NoProtection);
            var transient         = new TransientInstanceProvider <Transient>(InstanceProtectionMode.NoProtection);

            instanceProviders.Add(singleton);
            instanceProviders.Add(transient);
            var sut = new SingletonShouldNotDependOnTransientRule(instanceProviders);
            //act
            var isSatisfied = sut.IsSatisfiedBy(singleton);
            var errors      = sut.Errors;

            //assert
            Assert.That(isSatisfied, Is.False);
            Assert.That(errors, Is.Not.Null.Or.Empty);
            Assert.That(errors.Count(), Is.EqualTo(1));
        }