Esempio n. 1
0
        private static void Main(string[] args)
        {
            iaso_v001Context context = new iaso_v001Context();

            ICommandRepository <Guid, Board> boardCommandRepo = new CommandRepository <Guid, Board>(context);

            IQueryRepository <Guid, Board> boardQueryRepo = new QueryRepository <Guid, Board>(context);

            IParameterisedQuery <int, Board> pQuery = new PQ();

            var b = pQuery.GetParameter();

            var boardList = boardQueryRepo.Items.ToList();

            foreach (var t in boardList.ToList())
            {
                Console.WriteLine(string.Format("{0} >>>> {1}", t.Id, t.Name));
            }

            var board = new Board
            {
                Id          = 1,
                Name        = "No Base 21/03",
                BoardTypeId = 1,
                CreateDate  = DateTime.Now,
                CreatedById = 1
            };


            ISaveCommand <Board> createCom = new CreateCommand <Guid, Board>()
            {
                Entity     = board,
                Repository = new CommandRepository <Guid, Board>(context)
            };

            var task = Task.Run(() => createCom.ExecuteAsync());

            task.Wait();

            try
            {
                IDeleteCommand <int> deleteCommand = new DeleteCommand <int, Board>()
                {
                    Repository = new CommandRepository <int, Board>(context)
                };

                deleteCommand.Id = 1;

                var tk = Task.Run(() => deleteCommand.ExecuteAsync());

                tk.Wait();
            }
            catch (Exception ex)
            {
            }
            Console.ReadKey();
        }
Esempio n. 2
0
        public async Task ExecuteAsync_WithNoBasePath_VerifyError()
        {
            ArrangeInputs(commandText: "DELETE",
                          baseAddress: null,
                          path: null,
                          urlsWithResponse: null,
                          out MockedShellState shellState,
                          out HttpState httpState,
                          out ICoreParseResult parseResult,
                          out MockedFileSystem fileSystem,
                          out IPreferences preferences);

            string expectedErrorMessage = Strings.Error_NoBasePath.SetColor(httpState.ErrorColor);

            DeleteCommand deleteCommand = new DeleteCommand(fileSystem, preferences, new NullTelemetry());
            await deleteCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None);

            Assert.Equal(expectedErrorMessage, shellState.ErrorMessage);
        }
Esempio n. 3
0
        public async Task ExecuteAsync_WithOnlyBaseAddress_VerifyOutput()
        {
            ArrangeInputs(commandText: "DELETE",
                          baseAddress: _baseAddress,
                          path: null,
                          urlsWithResponse: _urlsWithResponse,
                          out MockedShellState shellState,
                          out HttpState httpState,
                          out ICoreParseResult parseResult,
                          out MockedFileSystem fileSystem,
                          out IPreferences preferences);

            DeleteCommand deleteCommand = new DeleteCommand(fileSystem, preferences, new NullTelemetry());
            await deleteCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None);

            string        expectedResponse = "Root delete received successfully.";
            List <string> result           = shellState.Output;

            Assert.Equal(2, result.Count);
            Assert.Contains("HTTP/1.1 200 OK", result);
            Assert.Contains(expectedResponse, result);
        }