Ejemplo n.º 1
0
        public void PackState_WithDocument_CreatesDictionaryEntry()
        {
            StoredState expected = new StoredState {
                State = "yo"
            };
            var actual = MongoBotStateStore.PackState("a", expected);

            Assert.Same(expected.State, actual["a"]);
        }
Ejemplo n.º 2
0
        public StoredState ShelveBegin()
        {
            var state = new StoredState
            {
                SourceWriter  = _sourceWriter,
                StringBuilder = _stringBuilder,
                CurrentLine   = _currentLine,
                Indent        = Indent
            };

            _stringBuilder = new StringBuilder();
            _sourceWriter  = new StringWriter(_stringBuilder);
            return(state);
        }
Ejemplo n.º 3
0
        public InsertedBlock ShelveEnd(StoredState state)
        {
            _sourceWriter.Flush();
            _sourceWriter.Dispose();
            var block = new InsertedBlock
            {
                Content         = _stringBuilder.ToString(),
                IndentDiff      = Indent - state.Indent,
                AddedLinesCount = _currentLine - state.CurrentLine
            };

            _sourceWriter  = state.SourceWriter;
            _stringBuilder = state.StringBuilder;
            Indent         = state.Indent;
            _currentLine   = state.CurrentLine;
            return(block);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StateCreator"/> class.
 /// </summary>
 /// <param name="stateFile">The state file.</param>
 public StateCreator(string stateFile)
 {
     this.stateDefinition = XmlHelper.Deserialize <StoredState>(stateFile);
 }