コード例 #1
0
        public void ShouldSearchAllRefrencedAsseblies()
        {
            var list  = TypeHelper.FindListOf <IRoleList>();
            var list2 = TypeHelper.FindListOf <IPremissionList>();

            var exampleOfInjected = AppObjectFactory.GetContainer().GetInstance <IIdentityManager>();
        }
コード例 #2
0
        public void ShouldCreateConcreteClassesWithDefaultConvetion()
        {
            var c       = AppObjectFactory.GetContainer();
            var someObj = c.GetInstance <TelegramErrorLoggerFilterAttribute>();

            Assert.IsNotNull(someObj);
        }
コード例 #3
0
        public async Task PageServiceAddWithParentTest()
        {
            //arrange

            var userManager = AppObjectFactory.GetContainer().GetInstance <IAppUserManager>();
            var identity    = new ClaimsIdentity();

            identity.AddClaim(new Claim(CustomClaimTypes.Premission, PagePremision.CanManage));
            identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, (await userManager.FindByNameAsync("mohammadali")).Id.ToString()));
            var principal = new ClaimsPrincipal(identity);

            var pageAddRequest = new PageAddRequest()
            {
                RequestOwner = principal,
                ViewModel    = new PageAddUpdateViewModel()
                {
                    Handle       = "contactus",
                    UrlSegment   = "/contactus",
                    Title        = "تماس با ما",
                    LanguageName = "fa-IR",
                    Description  = "test",
                    HtmlContent  = "<h1>hello</h1>",
                    ParentId     = Guid.Parse("5040e22d-739f-404a-9762-9da3f4ca7e22")
                }
            };

            AutomapperConfiguration.Cofigure(AppObjectFactory.GetContainer());
            var service = AppObjectFactory.GetContainer().GetInstance <IPageService>();
            var res     = service.Add(pageAddRequest);

            Assert.AreEqual((await res).Access, ResponseAccess.Granted);
        }
コード例 #4
0
        public async Task ShouldCreateNewSchemeTest()
        {
            var schemeCreator    = AppObjectFactory.GetContainer().GetInstance <IEntitySchemeFacade>();
            var serializeSetting = new JsonSerializer()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            await schemeCreator.AddNewSchemeToSystemAsync(new EntitySchemeViewModel()
            {
                Handle           = "hey i have spaces ",
                Description      = "some dec",
                Title            = "good title",
                Url              = "good url",
                FieldDefenitions = new List <FieldDefenitionViewModel>()
                {
                    new FieldDefenitionViewModel()
                    {
                        Handle       = "name",
                        Title        = "نام",
                        IsRequired   = true,
                        Type         = "text",
                        DefaultValue = JObject.FromObject(new TextTemplate()
                        {
                            Text = "myname"
                        }, serializeSetting),
                        Order = 1,
                    }
                }
            });
        }
コード例 #5
0
        public void SholuldValidateAvalibleSelectedDropOption()
        {
            var factory = AppObjectFactory.GetContainer().GetInstance <CustomFieldFactoryProvider <JObject> >()
                          .GetFieldFactory("dropdown");

            Assert.IsInstanceOfType(factory, typeof(DropDownListFieldFactory));

            var selectedOption = new DropDownListFieldTemplate()
            {
                Name = "طبع گرم", Value = "red"
            };
            var notValidSelectedOption = new DropDownListFieldTemplate()
            {
                Value = "blue", Name = "طبع گرم و سرد"
            };
            var dropDownFieldMetaData = new DropDownFieldMetaData()
            {
                AvalibleOptions = new List <DropDownListFieldTemplate>()
                {
                    selectedOption,
                    new DropDownListFieldTemplate()
                    {
                        Name = "طبع سرد", Value = "green"
                    }
                }
            };

            Assert.IsTrue(factory.IsValidForField(JObject.FromObject(selectedOption), JObject.FromObject(dropDownFieldMetaData)));
            Assert.IsTrue(factory.IsValidForField(selectedOption.Value, JObject.FromObject(dropDownFieldMetaData)));

            Assert.IsFalse(factory.IsValidForField(JObject.FromObject(notValidSelectedOption), JObject.FromObject(dropDownFieldMetaData)));
            Assert.IsFalse(factory.IsValidForField(notValidSelectedOption.Value, JObject.FromObject(dropDownFieldMetaData)));
        }
コード例 #6
0
        public void ShouldFillDependenciesOfAConstructedObj()
        {
            var c       = AppObjectFactory.GetContainer();
            var someObj = new MvcEnableEntityValidationAttribute();

            c.BuildUp(someObj);
            Assert.IsNotNull(someObj.EntitySchemesDataService);
        }
コード例 #7
0
        public async Task ShouldHandleNewItem()
        {
            var helper = new ShoppingCartHelper();

            var unitOfWork = AppObjectFactory.GetContainer().GetInstance <IUnitOfWork>();
            await helper.AddToCartAsync(unitOfWork.Set <Product>().First(), 2, unitOfWork.Set <User>().First(),
                                        unitOfWork);
        }
コード例 #8
0
        public void ShouldGetInfrustructureLogics()
        {
            var c    = AppObjectFactory.GetContainer();
            var list = c.GetInstance <List <IBaseBeforeAddingEntityLogic> >();

            foreach (var item in list)
            {
                Console.WriteLine(item);
                Assert.IsNotNull(item.Container);
            }
        }
コード例 #9
0
        public async Task SendEmailTest()
        {
            var service = AppObjectFactory.GetContainer().GetInstance <IEmailSecuriyService>();

            await service.SendAsync(new IdentityMessage()
            {
                Destination = "*****@*****.**",
                Body        = "hello",
                Subject     = "testmessage"
            });
        }
コード例 #10
0
        public async Task LoadTimeByOptionsTest()
        {
            var productDataService = AppObjectFactory.GetContainer().GetInstance <IProductDataService>();

            AutomapperConfiguration.Cofigure(AppObjectFactory.GetContainer());

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var product = productDataService.Query.IncludeNecessaryData()
                          .FirstOrDefault();
            await product.LoadDataByOptionsAsync(AppObjectFactory.GetContainer().GetInstance <IUnitOfWork>());

            stopWatch.Stop();
            Console.Write(stopWatch.Elapsed + " elapsed");
        }
コード例 #11
0
        public async Task ShouldNotifyAdminstrators()
        {
            HttpContext.Current = new HttpContext(
                new HttpRequest("", "http://tempuri.org", ""),
                new HttpResponse(new StringWriter())
                );

            var identity = new ClaimsIdentity();

            identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString()));
            HttpContext.Current.User = new GenericPrincipal(identity, null);

            await AppObjectFactory.GetContainer().GetInstance <WebSiteOwnerOrderNotifier>()
            .OrderPaid(new Order()
            {
                Id = Guid.NewGuid()
            });
        }
コード例 #12
0
        public async Task LoadTimeTest()
        {
            var productDataService = AppObjectFactory.GetContainer().GetInstance <IProductDataService>();

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var product = productDataService.Query.IncludeNecessaryData().Include(x => x.PrimaryCategory)
                          .Include(x => x.PrimaryCategory.FieldDefenitions)
                          .Include(x => x.PrimaryCategory.FieldDefenitionGroups)
                          .Include(x => x.PrimaryCategory.FieldDefenitionGroups.Select(fdg => fdg.FieldDefenitions))
                          .Include(x => x.Scheme)
                          .Include(x => x.Scheme.FieldDefenitions)
                          .Include(x => x.Scheme.FieldDefenitionGroups)
                          .Include(x => x.Scheme.FieldDefenitionGroups.Select(fdg => fdg.FieldDefenitions)).FirstOrDefault();

            stopWatch.Stop();
            Console.Write(stopWatch.Elapsed + "elapsed");
        }
コード例 #13
0
        public void ShouldWireUpDefaultConcereteTypes()
        {
            var c = AppObjectFactory.GetContainer();

            Assert.IsTrue(c.GetInstance <IFileService>() is FileServiceSubject);
        }
コード例 #14
0
 public void ShouldSendEmail()
 {
     InjectibleJob.Container = AppObjectFactory.GetContainer();
     new UserMessageNotifier("*****@*****.**", "test", "test").Execute();
 }
コード例 #15
0
 public UnitTest1()
 {
     AutomapperConfiguration.Cofigure(AppObjectFactory.GetContainer());
 }
コード例 #16
0
 public EntitySchemeFacadeTests()
 {
     AutomapperConfiguration.Cofigure(AppObjectFactory.GetContainer());
 }
コード例 #17
0
 public MenuServiceTests()
 {
     AutomapperConfiguration.Cofigure(AppObjectFactory.GetContainer());
 }
コード例 #18
0
 public void ShouldFindExcutingCodeAssemblyRegistries()
 {
     AppObjectFactory.FindRegistries().ForEach(Console.WriteLine);
 }
コード例 #19
0
 public CustomFieldToLiquidTest()
 {
     _factroyProvider = AppObjectFactory.GetContainer().GetInstance <CustomFieldFactoryProvider <JObject> >();
 }