예제 #1
0
        public void GivenTwoPercentageFeatureSwitches_ReturnsTrue_IfAllPropertyValuesAreIdentical()
        {
            //Arrange
            const string validFeatureType = "Femah.Core.FeatureSwitchTypes.SimpleFeatureSwitch, Femah.Core, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null";
            var customAttributes1 = new Dictionary<string, string> { { "percentage", "50" } };
            var customAttributes2 = new Dictionary<string, string> { { "percentage", "50" } };

            var featureSwitch1 = new PercentageFeatureSwitch
            {
                Name = "TestFeatureSwitch1",
                FeatureType = validFeatureType,
                IsEnabled = true
            };
            featureSwitch1.SetCustomAttributes(customAttributes1);

            var featureSwitch2 = new PercentageFeatureSwitch
            {
                Name = "TestFeatureSwitch1",
                FeatureType = validFeatureType,
                IsEnabled = true
            };
            featureSwitch2.SetCustomAttributes(customAttributes2);

            var providerMock = new Mock<IFeatureSwitchProvider>();
            providerMock.Setup(p => p.Get("TestFeatureSwitch1"))
                .Returns(featureSwitch1);

            Femah.Configure()
                .FeatureSwitchEnum(typeof(FeatureSwitches))
                .Provider(providerMock.Object)
                .Initialise();

            //Act
            var equal = featureSwitch1.Equals(featureSwitch2);

            //Assert
            Assert.IsTrue(equal);
        }
예제 #2
0
        public void TwoFeatureSwitchesAreNotEqualIfCustomAttributesAreDifferent()
        {
            //Arrange
            const string validFeatureType = "Femah.Core.FeatureSwitchTypes.PercentageFeatureSwitch, Femah.Core, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null";

            var featureSwitch1 = new PercentageFeatureSwitch
            {
                Name = "TestFeatureSwitch1",
                FeatureType = validFeatureType,
                IsEnabled = true,
                PercentageOn = 50
            };

            var featureSwitch2 = new PercentageFeatureSwitch
            {
                Name = "TestFeatureSwitch1",
                FeatureType = validFeatureType,
                IsEnabled = true,
                PercentageOn = 75
            };

            var providerMock = new Mock<IFeatureSwitchProvider>();
            providerMock.Setup(p => p.Get("TestFeatureSwitch1"))
                .Returns(featureSwitch1);
            providerMock.Setup(p => p.Get("TestFeatureSwitch1"))
                .Returns(featureSwitch2);

            Femah.Configure()
                .FeatureSwitchEnum(typeof(FeatureSwitches))
                .Provider(providerMock.Object)
                .Initialise();

            //Act
            var equal = featureSwitch1.Equals(featureSwitch2);

            //Assert
            Assert.IsFalse(equal);
        }