Пример #1
0
        protected override void beforeEach()
        {
            _theCase = new Case();
            MockFor <IValidator>().Stub(x => x.Validate(_theCase)).Return(Notification.Valid());

            var editCaseViewModel = new EditCaseViewModel(_theCase);

            _input  = new CreationRequest <EditCaseViewModel>(editCaseViewModel);
            _output = ClassUnderTest.Create(_input);
        }
Пример #2
0
        public IActionResult CreateToken([FromBody] CreationRequest request)
        {
            _logger.LogInformation($"Entered Method to create a Token", "Token Creation");

            var newToken = new Token
            {
                ID      = Token.GenerateID(),
                Expires = DateTimeOffset.Now.AddHours(1),
                Content = request.Content
            };

            _logger.LogInformation($"Created a new Token with ID {newToken.ID}", "Token Creation");

            _repository.Add(newToken.ID, newToken);

            return(Ok(
                       new TokenResponse
            {
                ID = newToken.ID,
                Expires = newToken.Expires
            }
                       ));
        }
Пример #3
0
        /// <summary>
        /// Runs the Unit-Tests for <see cref="Patchization"/>.
        /// </summary>
        /// <param name="args">The specified arguments.</param>
        internal static void Main(string[] args)
        {
            /*====================
             * 1. Connecting to the Project-Database.
             *====================
             */
            APIConnection connection;

            {
                string username;
                string password = "";

                Console.Write("Username: "******"Password: "******"\b \b");
                    }
                }
                Console.WriteLine();

                connection = new APIConnection
                {
                    DataSource = new Uri("https://rhrpatcher.romresources.net/"),
                    Username   = username,
                    Password   = password
                };
            }

            try
            {
                Console.WriteLine(connection.CurrentUser.Name);
                Console.WriteLine(connection.CurrentUser.Name);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            connection.GetAccessRequest <Project>().StartAsync().RunSync();
            Console.ReadLine();

            /*====================
             * 2. Downloading projects from the Project-Database.
             *====================
             */
            List <Project> projects = connection.GetAccessRequest <Project>().Start();

            /*====================
             * 3. Downloading a specified project from the Project-Database.
             *====================
             */
            {
                AccessRequest <List <Project> > request = connection.GetAccessRequest <Project>();
                request.Parameters = new Dictionary <string, object> {
                    { "ID", 1 }
                };
                Project project = request.Start()[0];
            }

            /*====================
             * 4. Modifying a project.
             *====================
             */
            {
                projects[0].Name += " - Test";

                /*--------------------
                 * 4.1 Method 1: Creating the request at first, setting the input data and starting the request.
                 *--------------------
                 */
                UpdateRequest <Project> request = connection.GetUpdateRequest <Project>();
                request.Data = projects[0];
                request.Start();

                /*--------------------
                 * 4.2 Method 2: Creating and starting the request at once.
                 *--------------------
                 */
                connection.GetUpdateRequest(projects[0]).Start();
            }

            /*====================
             * 5. Creating a project.
             *====================
             */
            {
                Project project = new Project
                {
                    Name   = "Chrono Trigger",
                    Author = new User {
                        ID = 1
                    }
                };

                /*--------------------
                 * 5.1 Method 1: Creating the request at first, setting the input data and starting the request.
                 *--------------------
                 */
                {
                    CreationRequest <Project> request = connection.GetCreationRequest <Project>();
                    request.Data = project;
                    request.Start();
                }

                /*--------------------
                 * 5.2 Method 2: Doing everything at once.
                 *--------------------
                 */
                {
                    connection.GetCreationRequest(project).Start();
                }
            }

            /*====================
             * 6. Removing a project.
             *====================
             */
            {
                Project project = projects.First(p => p.Name.Contains("Sovereign"));
                connection.GetDeletionRequest(project).Start();
            }

            /*=====================
             * 7. Async execution
             *====================
             */
            {
                /*--------------------
                 * 7.1 Penetration-Test
                 *--------------------
                 */
                {
                    int taskCount = 32;

                    List <Task> tasks = new List <Task>();

                    for (int i = 0; i < taskCount; i++)
                    {
                        tasks.Add(connection.GetDeletionRequest <Project>().StartAsync());
                    }

                    foreach (Task task in tasks)
                    {
                        task.Start();
                    }
                }
            }
        }