コード例 #1
0
        public void Has_returns_true_for_a_named_implementation_type_after_it_is_added([Registration(ServiceType = typeof(ISampleService), Name = "A name")] IServiceRegistration registration,
                                                                                       ResolvedServiceCache sut,
                                                                                       SampleServiceImplementationOne instance)
        {
            // Act
            sut.Add(registration, instance);
            var result = sut.Has(new ServiceRegistrationKey(typeof(SampleServiceImplementationOne), registration.Name));

            // Assert
            Assert.That(result, Is.True);
        }
コード例 #2
0
        public void Has_returns_false_for_a_service_which_was_added_under_a_different_name([Registration(ServiceType = typeof(ISampleService), Name = "A name")] IServiceRegistration registration,
                                                                                           ResolvedServiceCache sut,
                                                                                           SampleServiceImplementationOne instance)
        {
            // Act
            sut.Add(registration, instance);
            var result = sut.Has(new ServiceRegistrationKey(typeof(SampleServiceImplementationOne), "Other name"));

            // Assert
            Assert.That(result, Is.False);
        }
コード例 #3
0
        public void TryGet_returns_cached_instance_for_an_added_service([Registration(ServiceType = typeof(ISampleService))] IServiceRegistration registration,
                                                                        ResolvedServiceCache sut,
                                                                        SampleServiceImplementationOne instance)
        {
            // Act
            sut.Add(registration, instance);
            object cached;
            var    result = sut.TryGet(registration, out cached);

            // Assert
            Assert.That(result, Is.True);
            Assert.That(cached, Is.SameAs(instance));
        }