Exemple #1
0
        // GET: JsonToggler
        public virtual ActionResult Index()
        {
            var feature1 = new DateFeature();
            var feature2 = new BasicFeature();
            var feature3 = new Filter_Feature();
            var feature4 = new SQLFeature();

            var isEnabled = feature2.IsEnabled();

            var listOfGuids = new List <Guid>();

            listOfGuids.Add(new Guid("00000000-0000-0000-0000-000000000001"));
            listOfGuids.Add(new Guid("00000000-0000-0000-0000-000000000002"));
            listOfGuids.Add(new Guid("00000000-0000-0000-0000-000000000003"));
            listOfGuids.Add(new Guid("00000000-0000-0000-0000-000000000004"));
            listOfGuids.Add(new Guid("00000000-0000-0000-0000-000000000005"));

            var result = feature3.FilterCollection <Guid, Guid>(listOfGuids, "").ToList();

            var listOfObjects = GetListOfSomeObject();
            var result2       = feature3.FilterCollection <SomeObject, Guid>(listOfObjects, "Id").ToList();

            //This will do the opposite of the original filter... This will filter only if the feature is enabled.
            var result3 = feature3.FilterCollection <SomeObject, Guid>(listOfObjects, "Id", true).ToList();

            var vm = new JsonTogglerFeatureViewModel()
            {
                BasicFeature = feature2, SQLFeature = feature4, DateFeature = feature1, Filter_Feature = feature3, OriginalCollection = listOfGuids, UpdatedCollection = result
            };

            return(View(vm));
        }
        public static BasicFeature CreateBasicFeature(int ID)
        {
            BasicFeature basicFeature = new BasicFeature();

            basicFeature.id = ID;
            return(basicFeature);
        }
Exemple #3
0
        public void SubFeature2_iOSPlatformDEVIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.DEV, PlatformEnum.iOS);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_2(jsonSettings).IsEnabled());
        }
Exemple #4
0
        public void SubFeature3_WinPhonePlatformLocalIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.LOCAL, PlatformEnum.WinPhone);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_3(jsonSettings).IsEnabled());
        }
Exemple #5
0
        public void SubFeature3_WebPlatformQASIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.QAS, PlatformEnum.Web);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_3(jsonSettings).IsEnabled());
        }
Exemple #6
0
        public void SubFeature3_DEVIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.DEV);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_3(jsonSettings).IsEnabled());
        }
Exemple #7
0
        public void Feature_PRODWebPlatformIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.PROD, PlatformEnum.Web);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.IsEnabled());
        }
Exemple #8
0
        public void SubFeature3_AndroidPlatformSTAGEIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.STAGE, PlatformEnum.Android);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_3(jsonSettings).IsEnabled());
        }
Exemple #9
0
        public void SubFeature2_DesktopPlatformPRODIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.PROD, PlatformEnum.Desktop);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_2(jsonSettings).IsEnabled());
        }
Exemple #10
0
        public void SubFeature3_iOSPlatformPRODIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.PROD, PlatformEnum.iOS);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.SubFeature_3(jsonSettings).IsEnabled());
        }
Exemple #11
0
        public void Feature_DEVWebPlatformIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.LOCAL, PlatformEnum.Web);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.IsEnabled());
        }
Exemple #12
0
        public void Feature_STAGEIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.STAGE);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.IsEnabled());
        }
Exemple #13
0
        public void SubFeature2_AndroidPlatformQASIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.QAS, PlatformEnum.Android);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.SubFeature_2(jsonSettings).IsEnabled());
        }
Exemple #14
0
        public void SubFeature2_LocalIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.LOCAL);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.SubFeature_2(jsonSettings).IsEnabled());
        }
Exemple #15
0
        public void SubFeature1_WebPlatformSTAGEIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.STAGE, PlatformEnum.Web);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.SubFeature_1().IsEnabled());
        }
Exemple #16
0
        public void SubFeature1_PRODIsEnabled_ReturnsTrue()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.PROD);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsTrue(feature.SubFeature_1().IsEnabled());
        }
Exemple #17
0
        public void Feature_DEVAndroidPlatformIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.LOCAL, PlatformEnum.Android);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.IsEnabled());
        }
Exemple #18
0
        public void SubFeature2_WinPhonePlatformSTAGEIsEnabled_ReturnsFalse()
        {
            var jsonSettings = GetJsonSettings(EnvironmentEnum.STAGE, PlatformEnum.WinPhone);

            var feature = new BasicFeature(jsonSettings);

            Assert.IsFalse(feature.SubFeature_2(jsonSettings).IsEnabled());
        }
        public void DelegatesMessageProcessingToUnderlyingProcessor()
        {
            var underlying = new Mock <IMessageProcessor>();

            underlying.Setup(x => x.ProcessMessage(It.IsAny <Message>())).Returns(new Response("", ""));
            var feature = new BasicFeature("test", "test feature please ignore", "this is a test feature", underlying.Object);

            var commandParser = new Mock <ICommandParser>();
            var processor     = new FeatureMessageProcessor(commandParser.Object, feature);

            var message = new Message("a-channel", "a-user", "some random message text");
            var result  = processor.ProcessMessage(message).Responses.Single();

            underlying.Verify(x => x.ProcessMessage(message));
        }
        public void ReturnsErrorIfSpecificHelpNotFound()
        {
            var underlying    = new Mock <IMessageProcessor>();
            var feature1      = new BasicFeature("test", "test feature please ignore", "this is a test feature", underlying.Object);
            var feature2      = new BasicFeature("test2", "test feature please ignore", "this is another test feature", underlying.Object);
            var commandParser = new Mock <ICommandParser>();

            commandParser.SetupTryGetCommand("help test3");

            var processor = new FeatureMessageProcessor(commandParser.Object, feature1, feature2);

            var message = new Message("a-channel", "a-user", "help test3");
            var result  = processor.ProcessMessage(message);

            Assert.AreEqual("Sorry, I don't know about 'test3'.", result.Responses.Single().Message);
            underlying.Verify(x => x.ProcessMessage(message), Times.Never);
        }
        public void ReturnsHelpTextForHelpCommand()
        {
            var underlying    = new Mock <IMessageProcessor>();
            var feature1      = new BasicFeature("test", "test feature please ignore", "this is a test feature", underlying.Object);
            var feature2      = new BasicFeature("test2", "test feature please ignore", "this is another test feature", underlying.Object);
            var commandParser = new Mock <ICommandParser>();

            commandParser.SetupTryGetCommand("help");

            var processor = new FeatureMessageProcessor(commandParser.Object, feature1, feature2);

            var message = new Message("a-channel", "a-user", "help");
            var result  = processor.ProcessMessage(message);

            Assert.AreEqual("*test*: test feature please ignore\n*test2*: test feature please ignore\n\nuse `help <feature>` for help on a specific feature",
                            result.Responses.Single().Message);
            underlying.Verify(x => x.ProcessMessage(message), Times.Never);
        }
 public void AddToBasicFeatures(BasicFeature basicFeature)
 {
     base.AddObject("BasicFeatures", basicFeature);
 }