Ejemplo n.º 1
0
        public void ShouldRemoveProfileIfNull()
        {
            SetupTestEntities();

            var editModel = new TestEditApplicationModel
            {
                ApplicationId            = _application.ApplicationId,
                ApplicationName          = _application.ApplicationName,
                ClaimSetName             = _application.ClaimSetName,
                EducationOrganizationIds = new List <int> {
                    12345, 67890
                },
                ProfileId = null,
                VendorId  = _vendor.VendorId
            };

            Scoped <IUsersContext>(usersContext =>
            {
                var command = new EditApplicationCommand(usersContext);
                command.Execute(editModel);
            });

            Transaction(usersContext =>
            {
                var persistedApplication = usersContext.Applications.Single(a => a.ApplicationId == _application.ApplicationId);
                persistedApplication.ApplicationName.ShouldBe("Test Application");
                persistedApplication.ClaimSetName.ShouldBe("FakeClaimSet");
                persistedApplication.ApiClients.Count.ShouldBe(1);
                persistedApplication.ApiClients.First().Name.ShouldBe("Test Application");
                persistedApplication.ApiClients.First().ApplicationEducationOrganizations.ShouldAllBe(aeo => persistedApplication.ApplicationEducationOrganizations.Contains(aeo));
                persistedApplication.ApplicationEducationOrganizations.Count.ShouldBe(2);
                persistedApplication.ApplicationEducationOrganizations.ShouldAllBe(aeo => aeo.EducationOrganizationId == 12345 || aeo.EducationOrganizationId == 67890);
                persistedApplication.Profiles.Count.ShouldBe(0);
            });
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [FromBody] EApplicationDto eApplicationDto)
        {
            var request = new EditApplicationRequest(id);
            var editApplicationCommand = new EditApplicationCommand(request, eApplicationDto);
            var response = await _mediator.Send(editApplicationCommand);

            return(Ok(response));
        }
Ejemplo n.º 3
0
        public void ShouldUpdateAllEntitiesProperly()
        {
            SetupTestEntities();

            var editModel = new TestEditApplicationModel
            {
                ApplicationId            = _application.ApplicationId,
                ApplicationName          = "New Application Name",
                ClaimSetName             = "DifferentFakeClaimSet",
                EducationOrganizationIds = new List <int> {
                    23456, 78901
                },
                Environment = CloudOdsEnvironment.Production,
                ProfileId   = _otherProfile.ProfileId,
                VendorId    = _otherVendor.VendorId
            };


            var command = new EditApplicationCommand(SetupContext);

            command.Execute(editModel);

            var persistedApplication = TestContext.Applications.Single(a => a.ApplicationId == _application.ApplicationId);

            persistedApplication.ApplicationName.ShouldBe(CloudOdsApplicationName.GetPersistedName("New Application Name", CloudOdsEnvironment.Production));
            persistedApplication.ClaimSetName.ShouldBe("DifferentFakeClaimSet");

            persistedApplication.ApiClients.Count.ShouldBe(1);
            persistedApplication.ApiClients.First().Name.ShouldBe(CloudOdsApplicationName.GetPersistedName("New Application Name", CloudOdsEnvironment.Production));
            persistedApplication.ApiClients.First().ApplicationEducationOrganizations.ShouldAllBe(aeo => persistedApplication.ApplicationEducationOrganizations.Contains(aeo));

            persistedApplication.Profiles.Count.ShouldBe(1);
            persistedApplication.Profiles.First().ProfileName.ShouldBe("Other Test Profile");

            persistedApplication.ApplicationEducationOrganizations.Count.ShouldBe(2);
            persistedApplication.ApplicationEducationOrganizations.ShouldAllBe(aeo => aeo.EducationOrganizationId == 23456 || aeo.EducationOrganizationId == 78901);
        }
Ejemplo n.º 4
0
        public void ShouldRemoveProfileIfNull()
        {
            SetupTestEntities();

            var editModel = new TestEditApplicationModel
            {
                ApplicationId            = _application.ApplicationId,
                ApplicationName          = _application.ApplicationName,
                ClaimSetName             = _application.ClaimSetName,
                EducationOrganizationIds = new List <int> {
                    12345, 67890
                },
                Environment = CloudOdsEnvironment.Production,
                ProfileId   = null,
                VendorId    = _vendor.VendorId
            };


            var command = new EditApplicationCommand(SetupContext);

            command.Execute(editModel);

            var persistedApplication = TestContext.Applications.Single(a => a.ApplicationId == _application.ApplicationId);

            persistedApplication.ApplicationName.ShouldBe(CloudOdsApplicationName.GetPersistedName("Test Application", CloudOdsEnvironment.Production));
            persistedApplication.ClaimSetName.ShouldBe("FakeClaimSet");

            persistedApplication.ApiClients.Count.ShouldBe(1);
            persistedApplication.ApiClients.First().Name.ShouldBe(CloudOdsApplicationName.GetPersistedName("Test Application", CloudOdsEnvironment.Production));
            persistedApplication.ApiClients.First().ApplicationEducationOrganizations.ShouldAllBe(aeo => persistedApplication.ApplicationEducationOrganizations.Contains(aeo));

            persistedApplication.ApplicationEducationOrganizations.Count.ShouldBe(2);
            persistedApplication.ApplicationEducationOrganizations.ShouldAllBe(aeo => aeo.EducationOrganizationId == 12345 || aeo.EducationOrganizationId == 67890);

            persistedApplication.Profiles.Count.ShouldBe(0);
        }