Esempio n. 1
0
        public void ThrowsCustomExceptionIfKeyNotFound()
        {
            const string ThisKeyDoesNotExist = "this_key_does_not_exist";

            var emptyDictionary = new Dictionary <string, IStateDefinition <string, int> >();
            var testee          = new StateDefinitionDictionary <string, int>(emptyDictionary);

            testee.Invoking(t => t[ThisKeyDoesNotExist])
            .Should().Throw <InvalidOperationException>()
            .WithMessage($"Cannot find StateDefinition for state {ThisKeyDoesNotExist}. Are you sure you have configured this state via myStateDefinitionBuilder.In(..) or myStateDefinitionBuilder.DefineHierarchyOn(..)?");
        }
Esempio n. 2
0
        public void ReturnsStateDefinitionIfKeyFound()
        {
            var stateDefinition  = new StateDefinition <string, int>("someState");
            var stateDefinitions = new Dictionary <string, IStateDefinition <string, int> >
            {
                { stateDefinition.Id, stateDefinition }
            };
            var testee = new StateDefinitionDictionary <string, int>(stateDefinitions);

            var definition = testee[stateDefinition.Id];

            definition.Should().Be(stateDefinition);
        }
Esempio n. 3
0
        public void ValuesReturnsStateDefinitions()
        {
            var stateDefinitionA          = new StateDefinition <string, int>("someState");
            var stateDefinitionB          = new StateDefinition <string, int>("someOtherState");
            var stateDefinitionDictionary = new Dictionary <string, IStateDefinition <string, int> >
            {
                { stateDefinitionA.Id, stateDefinitionA },
                { stateDefinitionB.Id, stateDefinitionB }
            };
            var testee = new StateDefinitionDictionary <string, int>(stateDefinitionDictionary);

            var stateDefinitions = testee.Values;

            stateDefinitions
            .Should()
            .HaveCount(2)
            .And.Contain(stateDefinitionA)
            .And.Contain(stateDefinitionB);
        }