Beispiel #1
0
        public void Perf11CreatePostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP

                var service      = new CreateService <Post, DetailPostDto>(db);
                var setupService = new CreateSetupService <Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = setupService.GetDto();
                dto.Title   = Guid.NewGuid().ToString();
                dto.Content = "something to fill it as can't be empty";
                dto.Bloggers.SelectedValue        = db.Blogs.First().BlogId.ToString("D");
                dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray();
                var status = service.Create(dto);
                dto.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                foreach (var log in dto.LogOfCalls)
                {
                    Console.WriteLine(log);
                }
            }
        }
Beispiel #2
0
        public async Task CreateAsync_VerifyNewMovieIdEvenWithNoGenres()
        {
            var          mockTMDBapi    = new Mock <ITMDBapi>();
            var          title          = "Avenger's Endgame";
            SearchMovies searchmovies   = new SearchMovies();
            Movie        Movie          = CommonTestFunctions.GetSampleMovie();
            var          expectedResult = 1;
            int          result;

            mockTMDBapi.Setup(y => y.FetchMovieAsync(title)).ReturnsAsync(searchmovies);

            var service = new CreateService(DbAccess, mockTMDBapi.Object);

            result = await service.CreateAsync(Movie);

            using (var newcontext = new MarksMoviesContext(Options))
            {
                Assert.AreEqual(result, expectedResult);

                Movie movie = newcontext.Movie.Include(m => m.Genres).SingleAsync <Movie>().Result;
                Assert.IsNotNull(movie);
                Assert.AreEqual(1, movie.ID);
                Assert.AreEqual("Avenger's Endgame", movie.Title);
                Assert.AreEqual(2019, movie.Year);
                Assert.AreEqual(Rating.PG13, movie.Rating);
                Assert.AreEqual(DiscType.UHD_Bluray, movie.MediaType);
                Assert.AreEqual(299534, movie.TMDB_ID);
                Assert.IsNotNull(movie.Genres);
                Assert.AreEqual(0, movie.Genres.Count);
            }
        }
Beispiel #3
0
        public async Task CreateAsync_VerifyNewTVShowIdEvenWithNoGenres()
        {
            var      mockTMDBapi    = new Mock <ITMDBapi>();
            var      title          = "House";
            SearchTV searchTV       = new SearchTV();
            Movie    Movie          = CommonTestFunctions.GetSampleTVShow();
            var      expectedResult = 1;
            int      result;

            mockTMDBapi.Setup(y => y.FetchTVShowsAsync(title)).ReturnsAsync(searchTV);

            var service = new CreateService(DbAccess, mockTMDBapi.Object);

            result = await service.CreateAsync(Movie);

            using (var newcontext = new MarksMoviesContext(Options))
            {
                Assert.AreEqual(result, expectedResult);

                Movie movie = newcontext.Movie.Include(m => m.Genres).SingleAsync <Movie>().Result;
                Assert.IsNotNull(movie);
                Assert.AreEqual(1, movie.ID);
                Assert.AreEqual("House", movie.Title);
                Assert.AreEqual(2004, movie.Year);
                Assert.AreEqual(Rating.TV_14, movie.Rating);
                Assert.AreEqual(DiscType.DVD, movie.MediaType);
                Assert.AreEqual(1408, movie.TMDB_ID);
                Assert.IsNotNull(movie.Genres);
                Assert.AreEqual(0, movie.Genres.Count);
            }
        }
Beispiel #4
0
        public void Test05AddressCreateViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var setupService = new CreateSetupService(db);
                var service      = new CreateService(db);
                var lastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses).OrderByDescending(x => x.CustomerID).First();

                //ATTEMPT
                var dto =
                    setupService.GetDto <CrudCustomerAddressDto>()
                    .SetCustomerIdWhenCreatingNewEntry(lastCustomer.CustomerID);
                dto.AddressType           = "Unit Test";
                dto.Address.AddressLine1  = "Some street";
                dto.Address.AddressLine2  = Guid.NewGuid().ToString("D");
                dto.Address.City          = "some town";
                dto.Address.StateProvince = "a state";
                dto.Address.CountryRegion = "the world";
                dto.Address.PostalCode    = "XXX 111";
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                var newLastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses.Select(y => y.Address)).OrderByDescending(x => x.CustomerID).First();
                newLastCustomer.CustomerAddresses.Count.ShouldEqual(lastCustomer.CustomerAddresses.Count + 1);
                newLastCustomer.CustomerAddresses.OrderByDescending(x => x.AddressID).First().Address.AddressLine2.ShouldEqual(dto.Address.AddressLine2);
            }
        }
        public void Check11CreatePostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap         = new DbSnapShot(db);
                var service      = new CreateService <Post, DetailPostDto>(db);
                var setupService = new CreateSetupService <Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = setupService.GetDto();
                dto.Title   = Guid.NewGuid().ToString();
                dto.Content = "something to fill it as can't be empty";
                dto.Bloggers.SelectedValue        = db.Blogs.First().BlogId.ToString("D");
                dto.UserChosenTags.FinalSelection = db.Tags.OrderBy(x => x.TagId).Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray();
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                snap.CheckSnapShot(db, 1, 2);
                var post = db.Posts.Include(x => x.Tags).OrderByDescending(x => x.PostId).First();
                post.Title.ShouldEqual(dto.Title);
                post.BlogId.ShouldEqual(db.Blogs.First().BlogId);
                CollectionAssert.AreEqual(db.Tags.OrderBy(x => x.TagId).Take(2).Select(x => x.TagId), post.Tags.Select(x => x.TagId));
            }
        }
Beispiel #6
0
        public void CreateService_Action_Fails()
        {
            // Arrange
            var serviceDto = TestHelper.ServiceDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.ServiceService.CreateService(serviceDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateService <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(serviceDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
        public void Test05AddressCreateViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var setupService = new CreateSetupService(db);
                var service = new CreateService(db);
                var lastCustomer = db.Customers.AsNoTracking().Include(x => x.CustomerAddresses).OrderByDescending(x => x.CustomerID).First();

                //ATTEMPT
                var dto =
                    setupService.GetDto<CrudCustomerAddressDto>()
                        .SetCustomerIdWhenCreatingNewEntry(lastCustomer.CustomerID);
                dto.AddressType = "Unit Test";
                dto.Address.AddressLine1 = "Some street";
                dto.Address.AddressLine2 = Guid.NewGuid().ToString("D");
                dto.Address.City = "some town";
                dto.Address.StateProvince = "a state";
                dto.Address.CountryRegion = "the world";
                dto.Address.PostalCode = "XXX 111";
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                var newLastCustomer = db.Customers.AsNoTracking().Include( x => x.CustomerAddresses.Select( y => y.Address)).OrderByDescending(x => x.CustomerID).First();
                newLastCustomer.CustomerAddresses.Count.ShouldEqual(lastCustomer.CustomerAddresses.Count+1);
                newLastCustomer.CustomerAddresses.OrderByDescending(x => x.AddressID).First().Address.AddressLine2.ShouldEqual(dto.Address.AddressLine2);
            }
        }
 public HomeController(ConcreteOperationDb operationDb, IReCaptchaService reCaptcha, IOptions <AppOptions> options, CreateService createAdvert)
 {
     _operationDb          = operationDb;
     _reCaptcha            = reCaptcha;
     _countAdvertsByPage   = options.Value.IndexOptions.CountAdvertsByPage;
     _countAdvertsByAuftor = options.Value.IndexOptions.CountAdvertsByAuftor;
     _createAdvert         = createAdvert;
 }
Beispiel #9
0
 public StatUnitsController(NSCRegDbContext context, StatUnitAnalysisRules statUnitAnalysisRules,
                            DbMandatoryFields mandatoryFields, ValidationSettings validationSettings)
 {
     _searchService  = new SearchService(context);
     _viewService    = new ViewService(context, mandatoryFields);
     _createService  = new CreateService(context, statUnitAnalysisRules, mandatoryFields, validationSettings, StatUnitTypeOfSave.WebApplication);
     _editService    = new EditService(context, statUnitAnalysisRules, mandatoryFields, validationSettings);
     _deleteService  = new DeleteService(context);
     _historyService = new HistoryService(context);
 }
Beispiel #10
0
        public async Task <IActionResult> Post([FromBody] CreateService service)
        {
            if (null == service)
            {
                throw new ArgumentNullException(nameof(service));
            }
            await _servicesProxy.CreateAsync(service);

            return(CreatedAtAction("GetByName", new { name = service.Name }, null));
        }
Beispiel #11
0
        // public void Post([FromBody] string value)
        public ActionResult AddService([FromBody] CreateService createService)
        {
            if (_createServicesValidator.ServiesValidator(createService))
            {
                return(BadRequest(new { error = "all of the required information isn't available" }));
            }

            var newService = _servicesRepository.AddService(createService.Name, createService.Description, createService.Price);

            return(Created($"api/Services/{newService.ServiceId}", newService));
        }
Beispiel #12
0
        public async Task <IActionResult> CreateService([FromBody] CreateService command)
        {
            var response = await mediator.Send(command).ConfigureAwait(false);

            if (response.Errors.Any())
            {
                return(BadRequest(response.Errors));
            }

            return(Ok(response.Result));
        }
Beispiel #13
0
        public static DataSourcesQueueService CreateEmptyConfiguredDataSourceQueueService(NSCRegDbContext ctx)
        {
            var analysisRules      = new StatUnitAnalysisRules();
            var dbMandatoryFields  = new DbMandatoryFields();
            var validationSettings = new ValidationSettings();
            var createSvc          = new CreateService(ctx, analysisRules, dbMandatoryFields, validationSettings, StatUnitTypeOfSave.WebApplication);
            var editSvc            = new EditService(ctx, analysisRules, dbMandatoryFields, validationSettings);
            var servicesConfig     = new ServicesSettings();

            return(new DataSourcesQueueService(ctx, createSvc, editSvc, servicesConfig, dbMandatoryFields));
        }
Beispiel #14
0
        public BasicBLL()
        {
            this.db           = new TageerEntities();
            this.UserService  = new UserService();
            this.AdService    = new AdsService();
            this.UserLoggadId = AccessToken.GetUserId();
            this.LangIsEn     = LanguageService.IsEn;

            this.CheckedService = new CheckedService(db);
            this.UpdateS        = new UpdateService(db);
            this.CreateS        = new CreateService(db);
        }
Beispiel #15
0
        private void AddScopedServices()
        {
            var dbContextHelper = new DbContextHelper();
            var ctx             = dbContextHelper.CreateDbContext(new string[] { });

            _queueSvc    = new QueueService(ctx);
            _analysisSvc = new AnalyzeService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings);
            var createSvc = new CreateService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings, StatUnitTypeOfSave.Service);
            var editSvc   = new EditService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings);

            _saveManager = new SaveManager(ctx, _queueSvc, createSvc, editSvc);
        }
Beispiel #16
0
        public async Task CreateAsync(CreateService dto)
        {
            if (null == dto)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            var request = new RequestData("/services", dto);

            var response = await _servicesApiClient.PostAsync(request);

            await response.AssertSuccessfulAsync();
        }
Beispiel #17
0
        public void Check01ReferenceOk()
        {
            //SETUP

            //ATTEMPT
            ICreateService <Post, SimplePostDto> createService = new CreateService <Post, SimplePostDto>(null);
            IDetailService <Post, SimplePostDto> detailService = new DetailService <Post, SimplePostDto>(null);
            IListService <Post, SimplePostDto>   listService   = new ListService <Post, SimplePostDto>(null);
            IUpdateService <Post, SimplePostDto> updateService = new UpdateService <Post, SimplePostDto>(null);

            //VERIFY
            (listService is IListService <Post, SimplePostDto>).ShouldEqual(true);
        }
Beispiel #18
0
        public void Check01DirectReferenceOk()
        {
            //SETUP

            //ATTEMPT
            ICreateService <Post> createService = new CreateService <Post>(null);
            IDetailService <Post> detailService = new DetailService <Post>(null);
            IListService <Post>   listService   = new ListService <Post>(null);
            IUpdateService <Post> updateService = new UpdateService <Post>(null);

            //VERIFY
            (listService is IListService <Post>).ShouldEqual(true);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="expService"></param>
 /// <param name="editService"></param>
 /// <param name="deleteService"></param>
 /// <param name="createService"></param>
 /// <param name="detailService"></param>
 /// <param name="rankMoviesService"></param>
 public MediaController(ExportService expService,
                        EditService editService,
                        DeleteService deleteService,
                        CreateService createService,
                        DetailsService detailService,
                        RankMoviesService rankMoviesService)
 {
     _expService        = expService;
     _editService       = editService;
     _deleteService     = deleteService;
     _createService     = createService;
     _detailService     = detailService;
     _rankMoviesService = rankMoviesService;
 }
        public void Test01DirectReferenceOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post> createService = new CreateService<Post>(null);
            IDetailService<Post> detailService = new DetailService<Post>(null);
            IListService<Post> listService = new ListService<Post>(null);
            IUpdateService<Post> updateService = new UpdateService<Post>(null);

            //VERIFY
            (listService is IListService<Post>).ShouldEqual(true);
        }
Beispiel #21
0
        public async Task CreateServiceRoute()
        {
            var comand = new CreateService("Service test 01");

            var result = await _handler.Handle(comand, GetCancelationToken(TimeSpan.FromSeconds(1)).Token);

            Assert.NotNull(result);

            var objectResult = result as Response;

            Assert.NotNull(objectResult);

            Assert.Equal("Serviço criado com sucesso!", objectResult.Result);
        }
        public void Check01ReferencesOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post, DetailPostDto> createService = new CreateService<Post, DetailPostDto>(null);
            IDetailService<Post, DetailPostDto> detailService = new DetailService<Post, DetailPostDto>(null);
            IListService<Post, DetailPostDto> listService = new ListService<Post, DetailPostDto>(null);
            IUpdateService<Post, DetailPostDto> updateService = new UpdateService<Post, DetailPostDto>(null);

            //VERIFY
            (listService is ListService<Post, DetailPostDto>).ShouldEqual(true);
        }
Beispiel #23
0
 public DataSourcesQueueService(NSCRegDbContext ctx,
                                CreateService createSvc,
                                EditService editSvc,
                                ServicesSettings config,
                                DbMandatoryFields dbMandatoryFields)
 {
     _dbContext             = ctx;
     _createSvc             = createSvc;
     _editSvc               = editSvc;
     _rootPath              = config.RootPath;
     _uploadDir             = config.UploadDir;
     _dbMandatoryFields     = dbMandatoryFields;
     _statUnitDeleteService = new DeleteService(ctx);
     _elasticService        = new ElasticService(ctx);
 }
        public void Check13CreateServiceResetWorksOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService <Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = new DetailPostDto();
                service.ResetDto(dto);

                //VERIFY
                dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1);
                dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count());
            }
        }
Beispiel #25
0
        public void Check12CreateResetDtoOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService(db);
                var dto     = new DetailPostDto();

                //ATTEMPT
                service.ResetDto(dto);

                //VERIFY
                dto.Bloggers.ShouldNotEqualNull();
                dto.Bloggers.KeyValueList.Count.ShouldNotEqual(0);
            }
        }
        public void CreateService_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.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();

                CreateService task = new CreateService();
                task.CFServiceName  = "testService";
                task.CFServicePlan  = "myPlan";
                task.CFServiceType  = "myType";
                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.IsNotNull(task.CFServiceGuid);
            }
        }
        public void CreateService_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.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();

                CreateService task = new CreateService();
                task.CFServiceName = "testService";
                task.CFServicePlan = "myPlan";
                task.CFServiceType = "myType";
                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.IsNotNull(task.CFServiceGuid);
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     var command = new CreateService(
         txtId.Text.Trim(),
         txtName.Text.Trim(),
         int.Parse(txtSort.Text.Trim()),
         txtUrl.Text.Trim());
     try
     {
         commandService.Send(command);
         PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference("subwin_close"));
     }
     catch (Exception ex)
     {
         Alert.Show(ex.Message);
     }
 }
Beispiel #29
0
        //--------

        public static void CreatePostGSelectDirect(this SampleWebAppDb db, int id)
        {
            var guidString = Guid.NewGuid().ToString("N");
            var postClass  = new Post
            {
                Title   = guidString,
                Content = guidString,
                Blogger = db.Blogs.First(),
                Tags    = new Collection <Tag> {
                    db.Tags.First()
                }
            };

            var service = new CreateService(db);
            var status  = service.Create(postClass);

            status.IsValid.ShouldEqual(true, status.Errors);
        }
Beispiel #30
0
        public void Check08CreateWithListDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService <Post, SimplePostDto>(db);

                //ATTEMPT
                var dto    = new SimplePostDto();
                var status = service.Create(dto);
                dto.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("Create of a new Post is not supported in this mode.");
            }
        }
        //----------------------------------

        private CreateLineItemDto AddLineItem(AdventureWorksLt2012 db, short quantity = 1)
        {
            var service  = new CreateService(db);
            var newOrder = new CreateLineItemDto
            {
                SalesOrderID = _salesOrderId,
                CustomerID   = _customerId,
                ProductID    = _productToUse.ProductID,
                OrderQty     = quantity
            };

            //ATTEMPT
            var status = service.Create(newOrder);

            //VERIFY
            status.ShouldBeValid();
            return(newOrder);
        }
Beispiel #32
0
        public async Task CreateAsync_VerifyNullMovieReturnsZero()
        {
            var   mockTMDBapi    = new Mock <ITMDBapi>();
            Movie Movie          = null;
            var   expectedResult = 0;
            int   result;

            var service = new CreateService(DbAccess, mockTMDBapi.Object);

            var localresult = await service.CreateAsync(Movie);

            result = localresult;

            using (var newcontext = new MarksMoviesContext(Options))
            {
                Assert.AreEqual(0, await newcontext.Movie.CountAsync <Movie>());
                Assert.AreEqual(result, expectedResult);
            }
        }
Beispiel #33
0
        public void Check02CreateFailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService <Tag, SimpleTagDto>(db);
                var dto     = new SimpleTagDto();
                dto.SetSupportedFunctions(CrudFunctions.None);

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEndWith("is not supported in this mode.");
                dto.FunctionsCalledCommaDelimited.ShouldEqual("");
            }
        }
        public void Check02CreateFailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Tag, SimpleTagDto>(db);
                var dto = new SimpleTagDto();
                dto.SetSupportedFunctions( CrudFunctions.None);

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEndWith("is not supported in this mode.");
                dto.FunctionsCalledCommaDelimited.ShouldEqual("");
            }
        }
Beispiel #35
0
        public void Check02CreateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService <Tag, SimpleTagDto>(db);
                var dto     = new SimpleTagDto(errorFlag)
                {
                    Name = "Test Name",
                    Slug = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }
      public ActionResult Create(CreateService newService)
      {
          var service = new Service
          {
              Name        = newService.Name,
              Description = newService.Description,
              Minutes     = newService.Minutes,
              Price       = newService.Price //,
                                             //Stylist = db.Stylists.Find(newService.StylistID)
          };

          if (ModelState.IsValid)
          {
              db.Services.Add(service);
              db.SaveChanges();
              return(RedirectToAction("Index"));
          }

          return(View(newService));
      }
        public void FixtureSetup()
        {
            GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;

            //we create a SaleOrderHeader to use in these tests
            using (var db = new AdventureWorksLt2012())
            {
                _customerId = db.Customers.OrderBy(x => x.CustomerID).First().CustomerID;
                _productToUse = db.Products.OrderByDescending(x => x.ListPrice).First();
                var dto = new CreateSetupService(db).GetDto<NewOrderDto>();
                dto.CustomerID = _customerId;
                dto.ShipMethod = "Unit Test";
                dto.PurchaseOrderNumber = "Unit Test";
                dto.AccountNumber = "Unit Test";

                var service = new CreateService(db);
                var status = service.Create(dto);
                status.ShouldBeValid();
                _salesOrderId = dto.SalesOrderID;
            }
        }
        public void Check10CreateWithListDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Post, SimplePostDto>(db);

                //ATTEMPT
                var dto = new SimplePostDto();
                var status = service.Create(dto);
                dto.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("Create of a new Post is not supported in this mode.");

            }
        }
        public async Task<ActionResult> Index()
        {
            serviceId = "AC";
            serviceSort = 10000;
            if (serviceDao.Entities.Where(m => m.Id == serviceId).Count() > 0)
            {
                return Content("数据库中已经存在数据库,不需要重新生成。");
            }
            //部门
            CreateDepartment();

            var service = new CreateService(serviceId, "统一授权中心", 1, "http://int.zhongyi-itl.com/");
            await this.commandService.Execute(service);

            var user = new CreateUser("sysadmin", "系统管理员", "Sysadmin", "*****@*****.**", "15817439909", "系统管理员");
            await this.commandService.Execute(user);

            var role = new CreateRole("系统管理员", 0);
            await this.commandService.Execute(role);
            await this.commandService.Execute(new SetUserRoles(user.AggregateRootId, new string[] { role.AggregateRootId }));


            var menu = new CreateMenu("统一授权中心", (int)MenuType.Web, "", "", serviceSort);
            await this.commandService.Execute(menu);
            var menuRoot = menu.AggregateRootId;

            var module = new CreateModule(serviceId, "System", "系统管理", serviceSort);
            await this.commandService.Execute(module);
            var moduleId = module.AggregateRootId;

            menu = new CreateMenu("系统管理", (int)MenuType.Web, "", "", serviceSort + 10, menuRoot);
            await this.commandService.Execute(menu);
            var menuId = menu.AggregateRootId;

            string moduleId2 = await QuickModule("Sys", "Department", "部门信息", moduleId, menuId, 11);

            var permission = new CreatePermission("DepartmentUser", "设置用户", moduleId2);
            await this.commandService.Execute(permission);

            //角色管理
            module = new CreateModule(serviceId, "Role", "角色管理", serviceSort + 16, moduleId);
            await this.commandService.Execute(module);
            permission = new CreatePermission("ViewRole", "查看", module.AggregateRootId);
            await this.commandService.Execute(permission);
            var viewRolePermissionId = permission.AggregateRootId;
            menu = new CreateMenu("角色管理", (int)MenuType.Web, "Sys/RoleList.aspx", "", serviceSort + 16, menuId, permission.AggregateRootId);
            await this.commandService.Execute(menu);
            permission = new CreatePermission("NewRole", "新增", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ModifyRole", "编辑", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("DeleteRole", "删除", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("PermissionRole", "分配权限", module.AggregateRootId);
            await this.commandService.Execute(permission);
            await this.commandService.Execute(new SetRolePermissions(role.AggregateRootId, new string[] { viewRolePermissionId, permission.AggregateRootId }));

            //用户管理
            moduleId2 = await QuickModule("Sys", "User", "用户管理", moduleId, menuId, 21);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ChangePwdUser", "修改密码", moduleId2);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("RoleUser", "分配角色", moduleId2);
            await this.commandService.Execute(permission);
            await QuickModule("Sys", "Service", "服务管理", moduleId, menuId, 26);
            await QuickModule("Sys", "Module", "模块管理", moduleId, menuId, 31);
            await QuickModule("Sys", "Menu", "菜单管理", moduleId, menuId, 36);
            await QuickModule("Sys", "Authority", "权限管理", moduleId, menuId, 41);

            CreateRole();
            return Content("");
        }
        public void Check02CreateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Tag, SimpleTagDto>(db);
                var dto = new SimpleTagDto(errorFlag)
                {
                    Name = "Test Name",
                    Slug = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }  
        public void Flow_IntegrationTest()
        {
            string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string appPath = Path.Combine(assemblyDirectory, "TestApp");

            LoginTask login = new LoginTask();
            login.BuildEngine = new FakeBuildEngine();
            login.CFUser = Settings.Default.User;
            login.CFPassword = Settings.Default.Password;
            login.CFServerUri = Settings.Default.ServerUri;
            login.CFSkipSslValidation = true;

            login.Execute();

            CreateApp task = new CreateApp();

            task.CFRefreshToken = login.CFRefreshToken;
            task.CFServerUri = Settings.Default.ServerUri;
            task.CFSkipSslValidation = true;
            task.CFAppName = Guid.NewGuid().ToString("N");
            task.CFAppMemory = 256;
            task.CFAppInstances = 1;
            task.CFSpace = Settings.Default.Space;
            task.CFOrganization = Settings.Default.Organization;
            task.CFStack = Settings.Default.Stack;
            task.CFEnvironmentJson = "{\"mykey\":\"abcd\",\"secondkey\":\"efgh\"}";

            task.BuildEngine = new FakeBuildEngine();
            task.Execute();

            PushApp pushTask = new PushApp();
            pushTask.CFUser = Settings.Default.User;
            pushTask.CFPassword = Settings.Default.Password;
            pushTask.CFServerUri = Settings.Default.ServerUri;
            pushTask.CFSkipSslValidation = true;
            pushTask.CFAppGuid = task.CFAppGuid;
            pushTask.CFAppPath = appPath;
            pushTask.CFStart = true;

            pushTask.BuildEngine = new FakeBuildEngine();

            pushTask.Execute();

            CreateRoutes routeTask = new CreateRoutes();
            routeTask.CFUser = Settings.Default.User;
            routeTask.CFPassword = Settings.Default.Password;
            routeTask.CFServerUri = Settings.Default.ServerUri;
            routeTask.CFSkipSslValidation = true;
            routeTask.CFRoutes = new string[1] {
                string.Format(Settings.Default.Route, task.CFAppName)
            };
            routeTask.CFSpace = Settings.Default.Space;
            routeTask.CFOrganization = Settings.Default.Organization;

            routeTask.BuildEngine = new FakeBuildEngine();

            routeTask.Execute();

            BindRoutes bindTask = new BindRoutes();
            bindTask.CFUser = Settings.Default.User;
            bindTask.CFPassword = Settings.Default.Password;
            bindTask.CFServerUri = Settings.Default.ServerUri;
            bindTask.BuildEngine = new FakeBuildEngine();
            bindTask.CFSkipSslValidation = true;

            bindTask.CFAppGuid = task.CFAppGuid;
            bindTask.CFRouteGuids = routeTask.CFRouteGuids;

            bindTask.Execute();

            CreateService serviceTask = new CreateService();
            serviceTask.CFUser = Settings.Default.User;
            serviceTask.CFPassword = Settings.Default.Password;
            serviceTask.CFServerUri = Settings.Default.ServerUri;
            serviceTask.BuildEngine = new FakeBuildEngine();
            serviceTask.CFSkipSslValidation = true;
            serviceTask.CFServiceName = Guid.NewGuid().ToString("N");
            serviceTask.CFServicePlan = Settings.Default.ServicePlan;
            serviceTask.CFServiceType = Settings.Default.ServiceType;
            serviceTask.CFSpace = Settings.Default.Space;
            serviceTask.CFOrganization = Settings.Default.Organization;
            serviceTask.Execute();

            BindServices bindServiceTask = new BindServices();
            bindServiceTask.CFUser = Settings.Default.User;
            bindServiceTask.CFPassword = Settings.Default.Password;
            bindServiceTask.CFServerUri = Settings.Default.ServerUri;
            bindServiceTask.BuildEngine = new FakeBuildEngine();
            bindServiceTask.CFSkipSslValidation = true;
            bindServiceTask.CFAppGuid = task.CFAppGuid;
            bindServiceTask.CFServicesGuids = new string[1] { serviceTask.CFServiceGuid };
            bindServiceTask.Execute();

            if (CheckIfAppIsWorking(routeTask.CFRoutes[0], 60) == true)
            {

                DeleteApp delTask = new DeleteApp();
                delTask.CFUser = Settings.Default.User;
                delTask.CFPassword = Settings.Default.Password;
                delTask.CFServerUri = Settings.Default.ServerUri;
                delTask.CFSkipSslValidation = true;
                delTask.CFSpace = Settings.Default.Space;
                delTask.CFOrganization = Settings.Default.Organization;
                delTask.CFAppName = task.CFAppName;
                delTask.CFDeleteServices = true;
                delTask.CFDeleteRoutes = true;
                delTask.BuildEngine = new FakeBuildEngine();

                Assert.IsTrue(delTask.Execute());
            }
            else
            {
                Assert.Fail("Application is not working");
            }
        }
        public void Perf11CreatePostOk()
        {

            using (var db = new SampleWebAppDb())
            {
                //SETUP

                var service = new CreateService<Post, DetailPostDto>(db);
                var setupService = new CreateSetupService<Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = setupService.GetDto();
                dto.Title = Guid.NewGuid().ToString();
                dto.Content = "something to fill it as can't be empty";
                dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D");
                dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray();
                var status = service.Create(dto);
                dto.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                foreach (var log in dto.LogOfCalls) { Console.WriteLine(log); }
            }
        }
        public void Check12CreatePostCopyBackKeyOk()
        {

            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Post, DetailPostDto>(db);
                var setupService = new CreateSetupService<Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = setupService.GetDto();
                dto.Title = Guid.NewGuid().ToString();
                dto.Content = "something to fill it as can't be empty";
                dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D");
                dto.UserChosenTags.FinalSelection = db.Tags.OrderBy(x => x.TagId).Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray();
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                var post = db.Posts.OrderByDescending(x => x.PostId).First();
                dto.PostId.ShouldEqual(post.PostId);
            }
        }
        public void Check13CreateFailRunsSetupSecondaryDataAgainOk()
        {

            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Post, DetailPostDto>(db);
                var setupService = new CreateSetupService<Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = setupService.GetDto();
                dto.Title = Guid.NewGuid().ToString();
                dto.Content = null;                                 //this will fail 
                dto.Bloggers.SelectedValue = db.Blogs.First().BlogId.ToString("D");
                dto.UserChosenTags.FinalSelection = db.Tags.Take(2).ToList().Select(x => x.TagId.ToString("D")).ToArray();
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1);
                dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count());
            }
        }
        public void Check11CreateDirectOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var snap = new DbSnapShot(db);
                var service = new CreateService(db);
                var firstPostUntracked = db.Posts.Include(x => x.Tags).AsNoTracking().First();
                var tagsTracked = db.Tags.ToList().Where(x => firstPostUntracked.Tags.Any(y => y.TagId == x.TagId)).ToList();

                //ATTEMPT
                firstPostUntracked.Title = Guid.NewGuid().ToString();
                firstPostUntracked.Tags = tagsTracked;
                var status = service.Create(firstPostUntracked);

                //VERIFY
                status.IsValid.ShouldEqual(true);
                snap.CheckSnapShot(db, 1, 2);
                var updatedPost = db.Posts.OrderByDescending(x => x.PostId).Include(x => x.Tags).First();
                updatedPost.Title.ShouldEqual(firstPostUntracked.Title);
                updatedPost.BlogId.ShouldEqual(firstPostUntracked.BlogId);
                CollectionAssert.AreEqual(firstPostUntracked.Tags.Select(x => x.TagId), updatedPost.Tags.Select(x => x.TagId));
            }
        }
        public void Check13CreateServiceResetWorksOk()
        {

            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Post, DetailPostDto>(db);

                //ATTEMPT
                var dto = new DetailPostDto();
                service.ResetDto(dto);

                //VERIFY
                dto.Bloggers.KeyValueList.Count.ShouldEqual(db.Blogs.Count() + 1);
                dto.UserChosenTags.AllPossibleOptions.Count.ShouldEqual(db.Tags.Count());
            }
        }
        //----------------------------------
        private CreateLineItemDto AddLineItem(AdventureWorksLt2012 db, short quantity = 1)
        {
            var service = new CreateService(db);
            var newOrder = new CreateLineItemDto
            {
                SalesOrderID = _salesOrderId,
                CustomerID = _customerId,
                ProductID = _productToUse.ProductID,
                OrderQty = quantity
            };

            //ATTEMPT
            var status = service.Create(newOrder);

            //VERIFY
            status.ShouldBeValid();
            return newOrder;
        }
        public void Check12CreateResetDtoOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService(db);
                var dto = new DetailPostDto();

                //ATTEMPT
                service.ResetDto(dto);

                //VERIFY
                dto.Bloggers.ShouldNotEqualNull();
                dto.Bloggers.KeyValueList.Count.ShouldNotEqual(0);
            }
        }