Esempio n. 1
0
 public FeatureHasBeenCreated(int featureId, int applicationId, string name, bool isEnabled)
 {
     FeatureId = featureId;
     ApplicationId = applicationId;
     Name = name;
     IsEnabled = isEnabled;
     FeatureOverrides = new FeatureOverride[0];
 }
        public void WhenISaveAFeatureOverride_ThenTheFeatureOverrideIsSaved()
        {
            var application = new Application { Name = "Test" };
            new CreateApplicationFake().Execute(application);

            var feature = new Feature { Name = "Test", ApplicationId = application.ApplicationId };
            new CreateFeatureFake().Execute(feature);

            var featureOverride = new FeatureOverride { IsEnabled = true, FeatureId = feature.FeatureId, Hostname = "Test" };
            new CreateFeatureOverrideFake().Execute(featureOverride);

            var features = new GetAllFeaturesByApplicationId().Execute(application.ApplicationId);

            Assert.That(features[0].FeatureOverrides[0].Hostname, Is.EqualTo("Test"));
            Assert.That(features[0].FeatureOverrides[0].IsEnabled, Is.True);
        }
Esempio n. 3
0
 public void Execute(FeatureOverride featureOverride)
 {
     using (var cnn = CreateConnection())
     {
         try
         {
             featureOverride.FeatureOverrideId =
                 cnn.Query<int>(@"INSERT INTO FeatureOverride (FeatureId, Hostname, IsEnabled)
                                  VALUES (@FeatureId, @Hostname, @IsEnabled);
                                  SELECT SCOPE_IDENTITY();", new
                 {
                     featureOverride.FeatureId,
                     featureOverride.Hostname,
                     featureOverride.IsEnabled
                 }).First();
         }
         catch (DbException exception)
         {
             throw new CreateFeatureOverrideException(exception);
         }
     }
 }