internal override void AddControlledRegistrations(Type serviceType,
                                                          ContainerControlledItem[] registrations, bool append)
        {
            var group = RegistrationGroup.CreateForControlledItems(serviceType, registrations, append);

            this.AddRegistrationGroup(group);
        }
Exemple #2
0
        protected void AddRegistrationGroup(RegistrationGroup group)
        {
            if (!group.Appended)
            {
                if (this.Container.Options.AllowOverridingRegistrations)
                {
                    this.RemoveRegistrationsToOverride(group.ServiceType);
                }

                this.CheckForOverlappingRegistrations(group.ServiceType);
            }

            this.registrationGroups.Add(group);
        }
        public async Task ShouldRequestAnItemFromTheApi()
        {
            var client = Mock.Of <ApiClient>();

            var item = new RegistrationGroup();

            int itemId = 1;

            Mock.Get(client).Setup(c => c.GetObject <RegistrationGroup>(
                                       $"registration_groups/{itemId}",
                                       It.IsAny <ExpandoObject>())).Returns(Task.FromResult(item)).Verifiable();

            var registrationGroupResource = new RegistrationGroupsResource(client);
            var result = await registrationGroupResource.Find(itemId);

            Mock.Get(client).VerifyAll();
        }
        public async Task RegistrationGroupFetchesStudents()
        {
            IList <Student> groups = new List <Student>()
            {
                new Student(), new Student()
            };

            var client = Mock.Of <ApiClient>();

            var resource = new RegistrationGroupsResource(client);

            var registrationGroup = new RegistrationGroup();

            registrationGroup.Resource = resource;

            var resourceAddress = $"{RegistrationGroupsResource.ResourceName}/{registrationGroup.Id}/students";

            Mock.Get(client).Setup(c => c.GetList <Student>(resourceAddress, It.IsAny <ExpandoObject>())).Returns(Task.FromResult(groups));

            var results = await registrationGroup.Students();

            Assert.That(results.First().FirstName, Is.EqualTo(groups.First().FirstName));
        }
        protected void AddRegistrationGroup(RegistrationGroup group)
        {
            if (!group.Appended)
            {
                if (this.Container.Options.AllowOverridingRegistrations)
                {
                    this.RemoveRegistrationsToOverride(group.ServiceType);
                }

                this.CheckForOverlappingRegistrations(group.ServiceType);
            }

            this.registrationGroups.Add(group);
        }
Exemple #6
0
 internal override void RegisterUncontrolledCollection(Type serviceType, InstanceProducer producer)
 {
     this.AddRegistrationGroup(RegistrationGroup.CreateForUncontrolledProducer(serviceType, producer));
 }