예제 #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"));
        }
        public void SetUp()
        {
            Configuration.ResourceResolver = new HttpResourceResolver();
            Runner.SqlCompact("Lemonade").Down();
            Runner.SqlCompact("Lemonade").Up();

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

            var locale = new Locale { Description = "English", IsoCode = "en-GB" };

            new CreateApplicationFake().Execute(application);
            new CreateLocaleFake().Execute(locale);

            var resource = new ResourceBuilder()
                .WithLocale(locale)
                .WithResourceKey("HelloWorld")
                .WithResourceSet("MyTestResources")
                .WithValue("Hello World")
                .WithApplication(application).Build();

            new CreateResourceFake().Execute(resource);

            _nancyHost = new NancyHost(new Uri("http://localhost:12345"), new LemonadeBootstrapper());
            _nancyHost.Start();
        }
예제 #3
0
        public void WhenITryToSaveAResource_ThenTheResourceIsSaved()
        {
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            var locale = new Locale() { Description = "English", IsoCode = "en-GB" };

            new CreateApplicationFake().Execute(application);
            new CreateLocaleFake().Execute(locale);

            var resource = new ResourceBuilder()
                .WithLocale(locale)
                .WithResourceKey("HelloWorld")
                .WithResourceSet("MyTestResources")
                .WithValue("Hello World")
                .WithApplication(application).Build();

            new CreateResourceFake().Execute(resource);

            var resources = new GetAllResourcesByApplicationId().Execute(application.ApplicationId);

            Assert.That(resources[0].Locale.IsoCode, Is.EqualTo("en-GB"));
            Assert.That(resources[0].ResourceKey, Is.EqualTo("HelloWorld"));
            Assert.That(resources[0].ResourceSet, Is.EqualTo("MyTestResources"));
            Assert.That(resources[0].Value, Is.EqualTo("Hello World"));
        }
예제 #4
0
        public void SetUp()
        {
            var application = new ApplicationBuilder().WithName("Test Application").Build();

            Configuration.FeatureResolver = new HttpFeatureResolver("http://localhost:12345");
            Runner.SqlCompact("Lemonade").Down();
            Runner.SqlCompact("Lemonade").Up();
            _getFeature = new GetFeatureByNameAndApplication();
            _createFeature = new CreateFeatureFake();
            _createApplication = new CreateApplicationFake();
            _getApplicationByName = new GetApplicationByName();
            _createApplication.Execute(application);
            application = _getApplicationByName.Execute(application.Name);

            var feature1 = new FeatureBuilder().WithName("MySuperDuperFeature")
                .WithApplication(application)
                .WithIsEnabled(true)
                .Build();

            var feature2 = new FeatureBuilder().WithName("Ponies")
                .WithApplication(application)
                .WithIsEnabled(true)
                .Build();

            _createFeature.Execute(feature1);
            _createFeature.Execute(feature2);

            new CreateFeatureOverrideFake().Execute(new Data.Entities.FeatureOverride { FeatureId = feature2.FeatureId, Hostname = Dns.GetHostName(), IsEnabled = true });
            _nancyHost = new NancyHost(new Uri("http://localhost:12345"), new LemonadeBootstrapper());
            _nancyHost.Start();
        }
예제 #5
0
        public void WhenITryToSaveADuplicateApplication_ThenSaveApplicationExceptionIsThrown()
        {
            var saveApplication = new CreateApplicationFake();
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            saveApplication.Execute(application);

            Assert.Throws<CreateApplicationException>(() => saveApplication.Execute(application));
        }
예제 #6
0
        public void WhenIDeleteAnApplication_ThenItIsNoLongerAvailable()
        {
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            _createApplication.Execute(application);
            application = _getApplicationByName.Execute(application.Name);
            _deleteApplication.Execute(application.ApplicationId);
            application = _getApplicationByName.Execute(application.Name);

            Assert.That(application, Is.Null);
        }
        public void SetUp()
        {
            var application = new ApplicationBuilder().WithName("Test Application").Build();

            Configuration.ConfigurationResolver = new HttpConfigurationResolver("http://localhost:12345");
            Runner.SqlCompact("Lemonade").Down();
            Runner.SqlCompact("Lemonade").Up();

            new CreateApplicationFake().Execute(application);
            _application = new GetApplicationByName().Execute(application.Name);

            _nancyHost = new NancyHost(new Uri("http://localhost:12345"), new LemonadeBootstrapper());
            _nancyHost.Start();
        }
예제 #8
0
        public void WhenIDeleteAnApplication_ThenItIsNoLongerAvailable()
        {
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            _createApplication.Execute(application);

            var configuration = new Configuration { ApplicationId = application.ApplicationId, Name = "Test12345", Value = "TEST" };
            _createConfiguration.Execute(configuration);

            configuration = _getConfigurationByNameAndApplication.Execute("Test12345", application.Name);

            _deleteConfiguration.Execute(configuration.ConfigurationId);

            configuration = _getConfigurationByNameAndApplication.Execute("Test12345", application.Name);

            Assert.That(configuration, Is.Null);
        }
예제 #9
0
        public void WhenIDeleteAnApplicationWithAssociatedFeatures_ThenItIsNoLongerAvailable()
        {
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            _createApplication.Execute(application);
            application = _getApplicationByName.Execute(application.Name);

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

            _createFeature.Execute(feature);
            _deleteApplication.Execute(application.ApplicationId);
            application = _getApplicationByName.Execute(application.Name);

            Assert.That(application, Is.Null);
        }
예제 #10
0
        public void WhenITryToSaveADuplicateFeature_ThenSaveFeatureExceptionIsThrown()
        {
            var saveFeature = new CreateFeatureFake();
            var saveApplication = new CreateApplicationFake();
            var getApplicationByName = new GetApplicationByName();

            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);

            Assert.Throws<CreateFeatureException>(() => saveFeature.Execute(feature));
        }
예제 #11
0
        public void WhenITryToSaveADuplicateConfiguration_ThenSaveConfigurationExceptionIsThrown()
        {
            var saveConfiguration = new CreateConfigurationFake();
            var saveApplication = new CreateApplicationFake();
            var getApplicationByName = new GetApplicationByName();

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

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

            var configuration = new ConfigurationBuilder()
                .WithName("MyTestFeature")
                .WithValue("Hello World")
                .WithApplication(application).Build();

            saveConfiguration.Execute(configuration);

            Assert.Throws<CreateConfigurationException>(() => saveConfiguration.Execute(configuration));
        }
예제 #12
0
        public void WhenIDeleteAResource_ThenItIsNoLongerAvailable()
        {
            var application = new ApplicationBuilder()
                .WithName("Test12345")
                .Build();

            var locale = new Locale { Description = "English", IsoCode = "en-GB" };

            new CreateApplicationFake().Execute(application);
            new CreateLocaleFake().Execute(locale);

            var resource = new ResourceBuilder()
                .WithLocale(locale)
                .WithResourceKey("HelloWorld")
                .WithResourceSet("MyTestResources")
                .WithValue("Hello World")
                .WithApplication(application).Build();

            _createResource.Execute(resource);
            _deleteFeature.Execute(resource.ResourceId);
            resource = _getResource.Execute(application.Name, resource.ResourceSet, resource.ResourceKey, resource.Locale.IsoCode);

            Assert.That(resource, Is.Null);
        }