public void AddNew()
        {
            //Arrange
            AddNewCarRequest addNewCarRequest = new AddNewCarRequest("BMW", 1999);
            string           json             = JsonSerializer.Serialize(addNewCarRequest);
            StringContent    content          = new StringContent(json, Encoding.UTF8, "application/json");

            var step = HttpStep.Create("addNew", ctx =>
                                       Task.FromResult(Http.CreateRequest("POST", endpoint)
                                                       .WithBody(content)
                                                       ));

            var scenario = ScenarioBuilder.CreateScenario("Add", step)
                           .WithoutWarmUp()
                           .WithLoadSimulations(Simulation.KeepConstant(2, TimeSpan.FromSeconds(30)));

            //Act
            NodeStats nodeStats = NBomberRunner.RegisterScenarios(scenario).Run();

            //Assert
            nodeStats.OkCount.Should().Be(nodeStats.RequestCount);
            StepStats stepStats = nodeStats.ScenarioStats[0].StepStats[0];

            stepStats.RPS.Should().BeGreaterOrEqualTo(1500);
        }
Beispiel #2
0
        public async void AddNew_WhenIncorrectRequest_ShouldReturn422UnprocessableEntity(string brandName, int yearOfProduction)
        {
            AddNewCarRequest requestIncorrect = new AddNewCarRequest(brandName, yearOfProduction);

            var result = await testee.AddNew(requestIncorrect);

            (result as ObjectResult) !.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
        }
Beispiel #3
0
        protected async Task AddCar(string brandName, int yearOfProduction)
        {
            AddNewCarRequest addNewCarRequest = new AddNewCarRequest(brandName, yearOfProduction);
            string           json             = JsonSerializer.Serialize(addNewCarRequest);
            StringContent    content          = new StringContent(json, Encoding.UTF8, "application/json");
            var httpResponseMessage           = await client.PostAsync(ApiUrl, content);

            httpResponseMessage.EnsureSuccessStatusCode();
        }
        public async Task <IActionResult> AddNew([FromBody] AddNewCarRequest newCar)
        {
            long newCarId = await commandDispatcher.Send(new AddNewCarCommand(newCar.Brand, newCar.YearOfProduction));

            return(CreatedAtAction(nameof(Get), new { carId = newCarId }, newCarId));
        }
Beispiel #5
0
 public AddNewTests()
 {
     requestOK = new AddNewCarRequest("BMW", 2020);
 }