Ejemplo n.º 1
0
        public void WhenITryToSaveAFeature_ThenFeatureHasBeenSavedEventIsRaisedWithCorrectDetails()
        {
            var saveFeature                    = new CreateFeatureFake();
            var updateFeature                  = new UpdateFeature();
            var saveApplication                = new CreateApplicationFake();
            var getApplicationByName           = new GetApplicationByName();
            var getFeatureByNameAndApplication = new GetFeatureByNameAndApplication();

            var application = new ApplicationBuilder()
                              .WithName("Test12345")
                              .Build();

            saveApplication.Execute(application);
            application = getApplicationByName.Execute(application.Name);

            var feature = new FeatureBuilder()
                          .WithName("MyTestFeature")
                          .WithApplication(application).Build();

            saveFeature.Execute(feature);
            feature      = getFeatureByNameAndApplication.Execute(feature.Name, application.Name);
            feature.Name = "Ponies";
            updateFeature.Execute(feature);

            feature = getFeatureByNameAndApplication.Execute(feature.Name, application.Name);

            Assert.That(feature.Name, Is.EqualTo("Ponies"));
        }
Ejemplo n.º 2
0
        public object Put(UpdateFeature request)
        {
            WebFeature result = null;

            var context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/feature PUT Id='{0}'", request.Id));

                Terradue.Portal.Feature feat = Terradue.Portal.Feature.FromId(context, request.Id);
                feat = request.ToEntity(context, feat);
                feat.Store();
                result = new WebFeature(feat);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }