Exemple #1
0
        public void CorrectDeletePilots()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var pilot      = new RallyPilotsServices(repository);
            var runways    = new RunwaysServices(repository);
            var creat      = new CreateServices(repository);

            var service = new DeleteServices(repository, runways, pilot);

            var input = new PilotViewModels
            {
                Id        = 1,
                FirstName = "Pesho",
                LastName  = "Ivanov",
                Age       = 30,
            };

            creat.CreatePilotAsync(input);
            var result     = service.DeletePilots(1).Result;
            var resultPiot = pilot.GetPilot(1);

            var resultIsDeleted = resultPiot.IsDeleted;


            Assert.Equal(true, resultIsDeleted);
            Assert.Equal("Пилота, е изтрит успешно.", result);
        }
Exemple #2
0
        public void CorrectCreatePilot()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var service    = new CreateServices(repository);
            var pilot      = new RallyPilotsServices(repository);

            var input = new PilotViewModels
            {
                FirstName = "Pesho",
                LastName  = "Ivanov",
                Age       = 30,
            };

            var result     = service.CreatePilotAsync(input);
            var resultPiot = pilot.GetPilot(1);

            var resultId        = resultPiot.Id;
            var resultFirstName = resultPiot.FirstName;
            var resultLastName  = resultPiot.LastName;
            var resultAge       = resultPiot.Age;


            Assert.Equal("Pesho", resultFirstName);
            Assert.Equal("Ivanov", resultLastName);
            Assert.Equal(1, resultId);
            Assert.Equal(30, resultAge);
            Assert.Equal("Пилота е успешно създадено.", result);
        }
Exemple #3
0
        public void CorrectGetNewAerodynamics()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var pilots     = new RallyPilotsServices(repository);

            pilots.CreateRallyPilotsAsync();

            var pilot = pilots.GetPilot(1);

            var resultAge = pilot.Age;

            Assert.Equal(18, resultAge);
        }
Exemple #4
0
        public void CorrectEditPilot()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository  = new ApplicationDbContext(options.Options);
            var pilot       = new RallyPilotsServices(repository);
            var competition = new CompetitionsServices(repository);
            var runways     = new RunwaysServices(repository);
            var creat       = new CreateServices(repository);

            var service = new EditServices(repository, runways, pilot, competition);

            var input = new PilotViewModels
            {
                FirstName = "ffdzf",
                LastName  = "dzsf",
                Age       = 18,
            };

            var input1 = new PilotViewModels
            {
                Id        = 1,
                FirstName = "Pesho",
                LastName  = "Ivanov",
                Age       = 30,
            };

            creat.CreatePilotAsync(input);
            var result     = service.EditPilot(input1).Result;
            var resultPiot = pilot.GetPilot(1);

            var resultId        = resultPiot.Id;
            var resultFirstName = resultPiot.FirstName;
            var resultLastName  = resultPiot.LastName;
            var resultAge       = resultPiot.Age;


            Assert.Equal("Pesho", resultFirstName);
            Assert.Equal("Ivanov", resultLastName);
            Assert.Equal(1, resultId);
            Assert.Equal(30, resultAge);
            Assert.Equal("Пилота, е променен успешно.", result);
        }