示例#1
0
        public void When_AccountCreated_Expect_CreatedBy()
        {
            var testOptions = new MockOptions <AccountTests>("Samples.Plugin.Tests.Mocks.TestCases.Account.Create.Relationships.context.json");

            IMock pluginMock = new PluginMock <SampleEntityPipelinePlugin, AccountTests, DefaultSettingsProvider>(() => testOptions)
            {
                SetupMockServices = SetupMockWebServices
            };

            pluginMock.Test((resultContext, services) =>
            {
                IOrganizationService organizationService = services.Get <IOrganizationService>();
                Entity accountEntity = organizationService.Retrieve("account", new Guid("A4766A71-1D2E-4374-8B6D-354476D1C1EC"), new ColumnSet(true));

                Assert.IsTrue(accountEntity.Contains("createdby"));
                Assert.IsInstanceOf(typeof(EntityReference), accountEntity["createdby"]);

                EntityReference createdByEntityReference = accountEntity.GetAttributeValue <EntityReference>("createdby");
                Assert.IsTrue(createdByEntityReference.Id.Equals(new Guid("419308E5-001F-4896-8AD2-ABBB76E2E66B")));

                Entity createEntity = organizationService.Retrieve(createdByEntityReference.LogicalName, createdByEntityReference.Id, new ColumnSet(true));
                Assert.IsTrue(createEntity.Contains("domainname"));
                Assert.IsTrue(createEntity.GetAttributeValue <string>("domainname") == "DEVELOPMENT\\user1");
            });
        }
示例#2
0
        public void When_AccountCreated_Expect_ErrorHandled()
        {
            var testOptions = new MockOptions <AccountTests>("Samples.Plugin.Tests.Mocks.TestCases.Account.Create.Relationships.context.json");

            IMock pluginMock = new PluginMock <SampleErrorHandlingPlugin, AccountTests, DefaultSettingsProvider>(() => testOptions);

            pluginMock.Test((resultContext, services) =>
            {
                IOrganizationService organizationService = services.Get <IOrganizationService>();
                Entity accountEntity = organizationService.Retrieve("account", new Guid("A4766A71-1D2E-4374-8B6D-354476D1C1EC"), new ColumnSet(true));
            });
        }
示例#3
0
        public void When_AccountCreated_Expect_AccountAutonumberToBePopulated()
        {
            var testOptions = new MockOptions <AccountTests>("Samples.Plugin.Tests.Mocks.TestCases.Account.Create.AutoNumber.context.json");

            IMock pluginMock = new PluginMock <SampleEntityPipelinePlugin, AccountTests, DefaultSettingsProvider>(() => testOptions)
            {
                SetupMockServices = SetupMockWebServices
            };

            pluginMock.Test((resultContext, services) =>
            {
                IOrganizationService organizationService = services.Get <IOrganizationService>();
                Entity accountEntity = organizationService.Retrieve("account", new Guid("A4766A71-1D2E-4374-8B6D-354476D1C1EC"), new ColumnSet(true));

                Assert.IsTrue(accountEntity.Contains("qubit_autonumber"));
                Assert.IsTrue(accountEntity.GetAttributeValue <string>("qubit_autonumber") == "12345");
            });
        }