示例#1
0
        public void Execute()
        {
            var worldSheetCsv = _initialState.GetSheetCsv <WorldSheet>();
            var worldSheet    = new WorldSheet();

            worldSheet.Set(worldSheetCsv);
            var worldSheetRowCount = worldSheet.Count;

            var worldSheetCsvColumnLine = worldSheetCsv.Split('\n').FirstOrDefault();

            Assert.NotNull(worldSheetCsvColumnLine);

            var patchTableSheetAction = new PatchTableSheet
            {
                TableName = nameof(WorldSheet),
                TableCsv  = worldSheetCsvColumnLine,
            };
            var nextState = patchTableSheetAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Rehearsal      = false,
            });

            var nextWorldSheetCsv = nextState.GetSheetCsv <WorldSheet>();

            Assert.Single(nextWorldSheetCsv.Split('\n'));

            var nextWorldSheet = new WorldSheet();

            nextWorldSheet.Set(nextWorldSheetCsv);
            Assert.Empty(nextWorldSheet);

            patchTableSheetAction = new PatchTableSheet
            {
                TableName = nameof(WorldSheet),
                TableCsv  = worldSheetCsv,
            };
            nextState = patchTableSheetAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Rehearsal      = false,
            });

            nextWorldSheet = nextState.GetSheet <WorldSheet>();
            Assert.Equal(worldSheetRowCount, nextWorldSheet.Count);
        }