Esempio n. 1
0
            static IntegratedScenariosTests()
            {
                var config = PowerAppsConfigurationReader.GetConfiguration();

                serviceProvider =
                    new ServiceCollection()
                    .AddPowerAppsWebApiConfiguration(config)
                    .BuildServiceProvider();
            }
        static GenericRepositoryTests()
        {
            var config = PowerAppsConfigurationReader.GetConfiguration();

            serviceProvider =
                new ServiceCollection()
                .AddPowerAppsWebApiConfiguration(config)
                .BuildServiceProvider();
        }
            static QueryToFirstOrDefaultExecutionTests()
            {
                var config = PowerAppsConfigurationReader.GetConfiguration();

                serviceProvider =
                    new ServiceCollection()
                    .AddPowerAppsWebApiConfiguration(config)
                    .BuildServiceProvider();
            }
        public async Task GetcustomerAddressesTest()
        {
            var config = PowerAppsConfigurationReader.GetConfiguration();

            using (var tokenProvider = new AuthenticationMessageHandler(config))
                using (var repo = serviceProvider.GetService <GenericRepository <Account> >())
                {
                    var addresses = await repo.GetList();
                }
        }
        public async Task CreateAccountTest()
        {
            var config = PowerAppsConfigurationReader.GetConfiguration();

            using (var tokenProvider = new AuthenticationMessageHandler(config))
                using (var repo = serviceProvider.GetService <GenericRepository <Account> >())
                {
                    repo.MSCRMCallerID = Guid.Parse("BFC5064F-C69E-42B4-884D-83E3A9900945");

                    var account = new Account
                    {
                        Name = Guid.NewGuid().ToString(),
                        AccountCategoryCode       = account_accountcategorycode.Standard,
                        AccountClassificationCode = account_accountclassificationcode.DefaultValue,
                        AccountRatingCode         = account_accountratingcode.DefaultValue,
                        AccountNumber             = "11111111",
                        Address1_AddressTypeCode  = account_address1_addresstypecode.Primary,
                        Address1_City             = "Montreal",
                        Address1_Country          = "Canada",
                        Address1_PostalCode       = "H1H 1H1",
                        Address1_StateOrProvince  = "QC",
                        DoNotEMail     = true,
                        DoNotPhone     = false,
                        CreditLimit    = 500000.99m,
                        EMailAddress1  = string.Empty,
                        Telephone1     = "Telephone1",
                        Fax            = "Fax",
                        WebSiteURL     = "WebSiteURL",
                        LastOnHoldTime = new DateTime(2019, 1, 1, 0, 0, 0)
                    };

                    var accountid = await repo.Create(account);

                    Assert.NotEqual(Guid.Empty, accountid);
                    account =
                        await repo.GetById(
                            accountid,
                            p =>
                            new
                    {
                        Id              = p.Id,
                        StateCode       = p.StateCode,
                        StatusCode      = p.StatusCode,
                        LastOnHoldTime  = p.LastOnHoldTime,
                        ModifiedOn      = p.ModifiedOn,
                        CreatedOn       = p.CreatedOn,
                        CreatedBy       = p.CreatedBy,
                        OwnerId         = p.OwnerId,
                        ParentAccountId = p.ParentAccountId,
                        Telephone1      = p.Telephone1,
                    });

                    var owner = account.OwnerId;
                }
        }
        public async Task GetMultipleTest()
        {
            var config = PowerAppsConfigurationReader.GetConfiguration();

            using (var tokenProvider = new AuthenticationMessageHandler(config))
                using (var repo = serviceProvider.GetService <GenericRepository <Account> >())
                {
                    var accounts = await repo.GetList();

                    Assert.NotNull(accounts);
                }
        }
        public async Task GetOneTest()
        {
            var config          = PowerAppsConfigurationReader.GetConfiguration();
            var serviceProvider =
                new ServiceCollection()
                .AddPowerAppsWebApiConfiguration(config)
                .BuildServiceProvider();

            var repo = serviceProvider.GetService <GenericRepository <Account> >();
            var list = await repo.GetList();

            if (list.Count == 0)
            {
                return;
            }

            var entityId = list[0].Id;
            var account  =
                await repo.GetById(entityId,
                                   p =>
                                   new
            {
                Id                 = p.Id,
                StateCode          = p.StateCode,
                StatusCode         = p.StatusCode,
                LastOnHoldTime     = p.LastOnHoldTime,
                ModifiedOn         = p.ModifiedOn,
                CreatedOn          = p.CreatedOn,
                CreatedBy          = p.CreatedBy,
                OwnerId            = p.OwnerId,
                ParentAccountId    = p.ParentAccountId,
                Telephone1         = p.Telephone1,
                Address1_Composite = p.Address1_Composite,
                Name               = p.Name,
            });

            Assert.NotNull(account);
            Assert.NotNull(account.Name);
            Assert.NotNull(account.CreatedBy);
            Assert.NotNull(account.OwnerId);
            Assert.Equal(entityId, account.Id);
            Assert.Equal <account_statecode?>(account_statecode.Active, account.StateCode);
            Assert.Equal <account_statuscode?>(account_statuscode.Active, account.StatusCode);
            //Assert.NotNull(account.Address1_Composite);
            //Assert.NotNull(account.LastOnHoldTime);
            Assert.NotNull(account.ModifiedOn);
            Assert.NotNull(account.CreatedOn);

            var json = JObject.FromObject(account, new JsonSerializer {
                ContractResolver = new NavigationPropertyContractResolver()
            });
        }
        static void Main(string[] args)
        {
            var config = PowerAppsConfigurationReader.GetConfiguration();

            new CodeGenProcess().Execute(config);
        }