public void throw_exception_when_2_state_value_are_same_state_value_key()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            Check.ThatCode(() =>
                           stateValueManager.AddStateValue(
                               new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int)))
            .Throws <StateValueNotUniqueException>();
        }
        public void return_1_when_adding_and_then_remove_one_subscription()
        {
            var stateManager = new StateValueManagement();

            stateManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            stateManager.AddStateValue(new StateValue("sentinel1", "package2", "statename", 3, TypeOfValue.Int));

            var subscriptionManager = new SubscriptionStateValueManagement(stateManager);
            var subscription1Id     = subscriptionManager.AddSubscription(new SentinelKey("sentinel.package"), "sentinel1", "package1", "statename");
            var subscription2Id     = subscriptionManager.AddSubscription(new SentinelKey("sentinel.package"), "sentinel1", "package2", "statename");

            subscriptionManager.RemoveSubscription(new SentinelKey("sentinel.package"), subscription1Id);

            Check.That(subscriptionManager.GetAllSubscriptions()[new SentinelKey("sentinel.package")].Count).IsEqualTo(1);
        }
        public void return_3_when_get_state_value()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            Check.That(stateValueManager.GetStateValueByKey("sentinel1", "package1", "statename").Value).IsEqualTo(3);
        }
        public void return_at_least_1_when_adding_a_new_state_value()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 2, TypeOfValue.Int));
            Check.That(stateValueManager.GetAllStateValues().Count).IsStrictlyGreaterThan(0);
        }
        public void throw_no_state_value_found_exception_when_adding_and_then_remove_state_value_doesnt_exist()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            Check.ThatCode(() => stateValueManager.RemoveStateValueByKey("sentinel2", "package1", "statename"))
            .Throws <NoStateValueFoundException>();
        }
        public void return_0_when_adding_and_then_remove_state_value()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            stateValueManager.RemoveStateValueByKey("sentinel1", "package1", "statename");
            Check.That(stateValueManager.GetAllStateValues().Count).IsEqualTo(0);
        }
        public void return_false_when_state_value_doesnt_exist()
        {
            var stateValueManager = new StateValueManagement();
            var stateValueToAdd   = new StateValue("sentinel1", "package1", "statename", 2, TypeOfValue.Int);

            stateValueManager.AddStateValue(stateValueToAdd);
            Check.That(stateValueManager.Exist(stateValueManager.GetStateValueKey("sentinel1", "package2", "statename"))).IsEqualTo(false);
        }
        public void throw_exception_when_trying_to_update_a_state_value_which_doesnt_exist()
        {
            var stateValueManager = new StateValueManagement();

            stateValueManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));
            Check.ThatCode(() =>
                           stateValueManager.UpdateStateValue(
                               new StateValue("sentinel1", "package2", "statename", 3, TypeOfValue.Int)))
            .Throws <StateValueNotExistException>();
        }
        public void return_at_least_1_when_adding_a_new_subscription()
        {
            var stateManager = new StateValueManagement();

            stateManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));

            var subscriptionManager = new SubscriptionStateValueManagement(stateManager);

            subscriptionManager.AddSubscription(new SentinelKey("sentinel.package"), "sentinel1", "package1", "statename");
            Check.That(subscriptionManager.GetAllSubscriptions().Count).IsStrictlyGreaterThan(0);
        }
        public void throw_no_subscription_found_exception_when_adding_a_subscription()
        {
            var stateManager = new StateValueManagement();

            stateManager.AddStateValue(new StateValue("sentinel1", "package1", "statename", 3, TypeOfValue.Int));

            var subscriptionManager = new SubscriptionStateValueManagement(stateManager);
            var subscriptionId      = subscriptionManager.AddSubscription(new SentinelKey("sentinel.package"), "sentinel1", "package1",
                                                                          "statename");

            Check.ThatCode(() => subscriptionManager.RemoveSubscription(new SentinelKey("sentinel.package1"), subscriptionId)
                           ).Throws <NoSubscriptionFoundException>();
        }