Exemple #1
0
        public void Scan_ShouldWorkProperly()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var mappings = new ServiceConfigurationScanner().Scan(typeof(AppDomainWrapper).Assembly.GetTypes());
#pragma warning restore CS0618 // Type or member is obsolete

            Assert.AreEqual(ExpectedNumberOfMappingsInTheAssembly, mappings.Count());
        }
        public void Scan_ShouldWorkProperly()
        {
            var mappings = new ServiceConfigurationScanner().Scan(typeof(FirstAssembly.First).Assembly.GetTypes()).ToArray();

            Assert.AreEqual(3, mappings.Length);

            Assert.AreEqual(ServiceLifetime.Singleton, mappings[0].Configuration.Lifetime);
            Assert.AreEqual(typeof(FirstAssembly.IFirst), mappings[0].Configuration.ServiceType);
            Assert.AreEqual(typeof(FirstAssembly.First), mappings[0].Type);

            Assert.AreEqual(ServiceLifetime.Singleton, mappings[1].Configuration.Lifetime);
            Assert.AreEqual(typeof(FirstAssembly.Second), mappings[1].Configuration.ServiceType);
            Assert.AreEqual(typeof(FirstAssembly.Second), mappings[1].Type);

            Assert.AreEqual(ServiceLifetime.Transient, mappings[2].Configuration.Lifetime);
            Assert.AreEqual(typeof(FirstAssembly.Third), mappings[2].Configuration.ServiceType);
            Assert.AreEqual(typeof(FirstAssembly.Third), mappings[2].Type);
        }