public void DefaultGroupValue_Get_NotExisting() { string pointerName = "grouppointername"; DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DeclaredValuePointer <G> groupPointer = new DeclaredValuePointer <G>("group", valueProvider.Null) { Identifier = pointerName }; List <DeclaredValuePointer <G> > groupPointers = new List <DeclaredValuePointer <G> >() { new DeclaredValuePointer <G>("group"), groupPointer, new DeclaredValuePointer <G>("group") }; Dictionary <string, int> pointerMap = new Dictionary <string, int> { { pointerName, 1 } }; G groupState = Mock.Of <G>(m => m.GroupPointers == groupPointers && m.PointerMap == pointerMap); DefaultStringValue <G> key = new DefaultStringValue <G>("otherpointer"); DefaultGroupValue <G> sut = new DefaultGroupValue <G>(groupState); EngineRuntimeException ex = Assert.Throws <EngineRuntimeException>(() => { sut.Get(key, true, valueProvider); }); Assert.Equal("Cannot create group pointer using accessor", ex.Message); }
public void DefaultGroupValue_Get_Existing() { string pointerName = "grouppointername"; DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DeclaredValuePointer <G> groupPointer = new DeclaredValuePointer <G>("group", valueProvider.Null) { Identifier = pointerName }; List <DeclaredValuePointer <G> > groupPointers = new List <DeclaredValuePointer <G> >() { new DeclaredValuePointer <G>("group"), groupPointer, new DeclaredValuePointer <G>("group") }; Dictionary <string, int> pointerMap = new Dictionary <string, int> { { pointerName, 1 } }; G groupState = Mock.Of <G>(m => m.GroupPointers == groupPointers && m.PointerMap == pointerMap); DefaultStringValue <G> key = new DefaultStringValue <G>(pointerName); DefaultGroupValue <G> sut = new DefaultGroupValue <G>(groupState); ValuePointer <G> result = sut.Get(key, false, valueProvider) as ValuePointer <G>; Assert.Equal(groupPointer, result); }