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

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

            var input = new NavigatorViewModels
            {
                FirstName = "Pesho",
                LastName  = "Ivanov",
                Energy    = 100,
            };

            var result     = service.CreateNavigatorAsync(input);
            var resultPiot = pilot.GetNavigator(1);

            var resultId        = resultPiot.Id;
            var resultFirstName = resultPiot.FirstName;
            var resultLastName  = resultPiot.LastName;
            var resultEnergy    = resultPiot.Energy;


            Assert.Equal("Pesho", resultFirstName);
            Assert.Equal("Ivanov", resultLastName);
            Assert.Equal(1, resultId);
            Assert.Equal(100, resultEnergy);
            Assert.Equal("Навигатора е успешно създадено.", result);
        }
Exemple #2
0
        public void CorrectDeleteRunways()
        {
            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 RunwayViewModels
            {
                NameRunway  = "Test",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest",
                TrackLength = 123,
                ImagName    = "test",
            };

            creat.CreateRunwayAsync(input);
            var result = service.DeleteRunways(1).Result;

            Assert.Equal("Пистата, е изтрита успешно.", result);
        }
Exemple #3
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 #4
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 #5
0
        public void CorrectCreateRunway()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var service    = new CreateServices(repository);
            var runway     = new RunwaysServices(repository);
            var date       = DateTime.Now;

            var input = new RunwayViewModels
            {
                NameRunway  = "Test",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest",
                TrackLength = 123,
                ImagName    = "test",
            };

            var result       = service.CreateRunwayAsync(input);
            var resultRunway = runway.GetRunwayAsync(1).Result;

            var resultId          = resultRunway.Id;
            var resultImagName    = resultRunway.ImagName;
            var resultTrackLength = resultRunway.TrackLength;
            var resultDescription = resultRunway.Description;


            Assert.Equal("TestTest", resultDescription);
            Assert.Equal(null, resultImagName);
            Assert.Equal(1, resultId);
            Assert.Equal(123, resultTrackLength);
            Assert.Equal("Пистата е успешно създадено.", result);
        }
Exemple #6
0
        public void CorrectCreateCompetitions()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository  = new ApplicationDbContext(options.Options);
            var service     = new CreateServices(repository);
            var competition = new CompetitionsServices(repository);
            var date        = DateTime.Now;

            var input = new CompetitionsViewModels
            {
                Name          = "Test",
                PrizeFund     = 150000,
                StartRaceDate = date,
            };

            var result = service.CreateCompetitionsAsync(input);

            var resultName      = competition.GetCompetitionName().Result;
            var resultId        = competition.GetCompetitionId();
            var resultStartDate = competition.GetStartDate().Result;
            var resultPrize     = competition.GetCompetitionPrizeFund();


            Assert.Equal(date, resultStartDate);
            Assert.Equal("Test", resultName);
            Assert.Equal(1, resultId);
            Assert.Equal(150000, resultPrize);
            Assert.Equal("Състезянието е успешно създадено.", result);
        }
        public OperationResult Create(CreateServices command)
        {
            var operation = new OperationResult();

            var service = new Services(command.ServiceName, command.ServiceLogo, command.ServiceDescription);

            _servicesRepository.Create(service);
            _servicesRepository.SaveChanges();

            return(operation.Succedded());
        }
        public void CorrectGetAllRunways()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var creat      = new CreateServices(repository);

            var service = new RunwaysServices(repository);

            var input = new RunwayViewModels
            {
                NameRunway  = "Test1111",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest1111",
                TrackLength = 123,
                ImagName    = "test1111",
            };

            var input1 = new RunwayViewModels
            {
                Id          = 1,
                NameRunway  = "Test",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest",
                TrackLength = 123,
                ImagName    = "test",
            };

            creat.CreateRunwayAsync(input);
            creat.CreateRunwayAsync(input1);
            var resultRunway = service.GetAllRunwaysAsync();

            var resultId           = resultRunway[0].Id;
            var resultImagName     = resultRunway[0].ImagName;
            var resultTrackLength  = resultRunway[0].TrackLength;
            var resultDescription  = resultRunway[0].Description;
            var resultId1          = resultRunway[1].Id;
            var resultImagName1    = resultRunway[1].ImagName;
            var resultTrackLength1 = resultRunway[1].TrackLength;
            var resultDescription1 = resultRunway[1].Description;
            var count = resultRunway.Count;

            Assert.Equal("TestTest1111", resultDescription);
            Assert.Equal(null, resultImagName);
            Assert.Equal(1, resultId);
            Assert.Equal(123, resultTrackLength);
            Assert.Equal("TestTest", resultDescription1);
            Assert.Equal(null, resultImagName1);
            Assert.Equal(2, resultId1);
            Assert.Equal(123, resultTrackLength1);
            Assert.Equal(2, count);
        }
        public void CreateServices_Test()
        {
            using (ShimsContext.Create())
            {
                CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesResponse> .AllInstances.ResourcesGet = TestUtils.CustomGetPaged;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServicesEndpoint.AllInstances.ListAllServicesRequestOptions = TestUtils.CustomListAllServices;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllServicesResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllServicesResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServicesEndpoint.AllInstances.ListAllServicePlansForServiceNullableOfGuid = TestUtils.CustomListServicePlans;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllServicePlansForServiceResponse> .AllInstances.ResourcesGet = TestUtils.CustomListServicePlansResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.CreateServiceInstanceCreateServiceInstanceRequest = TestUtils.CustomCreateServiceInstance;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.ListAllServiceInstances = TestUtils.CustomListAllServiceInstancesPlain;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllServiceInstancesResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllServiceInstancesPlainResponse;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllOrganizationsResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesForOrganizationResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization;


                TestUtils.InitTestMetadata();

                CreateServices task = new CreateServices();
                task.CFServices = @"service1,mysql,free;service2,mssql2012,free;";

                task.CFSpace        = "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFUser         = Settings.Default.User;
                task.CFPassword     = Settings.Default.Password;
                task.CFServerUri    = Settings.Default.ServerUri;
                task.BuildEngine    = new FakeBuildEngine();

                task.Execute();

                Assert.AreEqual(2, task.CFServicesGuids.Length);
            }
        }
        public void CreateServices_Test()
        {
            using (ShimsContext.Create())
            {
                CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetPaged;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServicesEndpoint.AllInstances.ListAllServicesRequestOptions = TestUtils.CustomListAllServices;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllServicesResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllServicesResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServicesEndpoint.AllInstances.ListAllServicePlansForServiceNullableOfGuid = TestUtils.CustomListServicePlans;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllServicePlansForServiceResponse>.AllInstances.ResourcesGet = TestUtils.CustomListServicePlansResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.CreateServiceInstanceCreateServiceInstanceRequest = TestUtils.CustomCreateServiceInstance;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.ListAllServiceInstances = TestUtils.CustomListAllServiceInstancesPlain;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllServiceInstancesResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllServiceInstancesPlainResponse;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllOrganizationsResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesForOrganizationResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization;

                TestUtils.InitTestMetadata();

                CreateServices task = new CreateServices();
                task.CFServices = @"service1,mysql,free;service2,mssql2012,free;";

                task.CFSpace = "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFUser = Settings.Default.User;
                task.CFPassword = Settings.Default.Password;
                task.CFServerUri = Settings.Default.ServerUri;
                task.BuildEngine = new FakeBuildEngine();

                task.Execute();

                Assert.AreEqual(2, task.CFServicesGuids.Length);
            }
        }
        public JsonResult SaveWarehouse(tblWarehouse model)
        {
            var service = new CreateServices();
            var res     = service.SaveWarehouse(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
        public JsonResult SaveClient(tblClient model)
        {
            var service = new CreateServices();
            var res     = service.SaveClient(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
        public JsonResult SaveProduct(ProductViewModel model)
        {
            var service = new CreateServices();
            var res     = service.SaveProduct(model);

            if (res)
            {
                return(Json(new { success = true }));
            }

            else
            {
                return(Json(new { success = false }));
            }
        }
Exemple #14
0
        public void CorrectEditRunways()
        {
            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 RunwayViewModels
            {
                NameRunway  = "Test1111",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest1111",
                TrackLength = 123,
                ImagName    = "test1111",
            };

            var input1 = new RunwayViewModels
            {
                Id          = 1,
                NameRunway  = "Test",
                Difficulty  = DifficultyType.Average,
                Description = "TestTest",
                TrackLength = 123,
                ImagName    = "test",
            };

            creat.CreateRunwayAsync(input);
            var result       = service.EditRunways(input1).Result;
            var resultRunway = runways.GetRunwayAsync(1).Result;

            var resultId          = resultRunway.Id;
            var resultImagName    = resultRunway.ImagName;
            var resultTrackLength = resultRunway.TrackLength;
            var resultDescription = resultRunway.Description;


            Assert.Equal("TestTest", resultDescription);
            Assert.Equal("test", resultImagName);
            Assert.Equal(1, resultId);
            Assert.Equal(123, resultTrackLength);
            Assert.Equal("Пистата, е променена успешно.", result);
        }
Exemple #15
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);
        }
Exemple #16
0
        public void CorrectCreateParts()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new ApplicationDbContext(options.Options);
            var service    = new CreateServices(repository);
            var car        = new CarServices(repository);

            var input = new PartsViewModels
            {
                Type     = PartsCarsType.Aerodynamics,
                Name     = "Aerodynamics",
                Price    = 1000,
                Strength = 100,
                Speed    = 10,
            };

            var result = service.CreateParts(input);

            Assert.Equal("Часта е успешно създадено.", result);
        }
Exemple #17
0
        public IActionResult OnGetCreate()
        {
            var command = new CreateServices();

            return(Partial("./Create", command));
        }
Exemple #18
0
        public JsonResult OnPostCreate(CreateServices command)
        {
            var result = _servicesApplication.Create(command);

            return(new JsonResult(result));
        }