コード例 #1
0
        public void RegisterInstance_can_create_an_instance_registration(RegistrationHelper sut,
                                                                         SampleServiceImplementationOne instance)
        {
            // Act
            sut.RegisterInstance(instance);

            // Assert
            var registrations = sut.GetRegistrations();

            Assert.That(registrations, Has.Some.InstanceOf <InstanceRegistration>());
            var matchingReg = registrations.FirstOrDefault(x => x is InstanceRegistration);

            Assert.That(matchingReg.ServiceType, Is.EqualTo(typeof(SampleServiceImplementationOne)));
        }
コード例 #2
0
        public void RegisterInstance_uses_inferred_type(RegistrationHelper sut,
                                                        SampleServiceImplementationOne instance)
        {
            // Act
            ISampleService regInstance = instance;

            sut.RegisterInstance(regInstance);

            // Assert
            var registrations = sut.GetRegistrations();

            Assert.That(registrations, Has.Some.InstanceOf <InstanceRegistration>());
            var matchingReg = registrations.FirstOrDefault(x => x is InstanceRegistration);

            Assert.That(matchingReg.ServiceType, Is.EqualTo(typeof(ISampleService)));
        }
コード例 #3
0
ファイル: StepsBase.cs プロジェクト: LogoFX/Samples.WinRT
 /// <summary>
 /// Registers service instance into the scenario context.
 /// </summary>
 /// <typeparam name="TService">he type of service.</typeparam>
 /// <param name="instance">The instance to be registered.</param>
 protected void RegisterInstance <TService>(TService instance) where TService : class
 {
     RegistrationHelper.RegisterInstance(GetRegistrator(), instance);
 }
コード例 #4
0
 public void RegisterInstance_raises_exception_if_instance_is_null(RegistrationHelper sut)
 {
     // Act & assert
     Assert.That(() => sut.RegisterInstance((object)null), Throws.InstanceOf <ArgumentNullException>());
 }