コード例 #1
0
        public void CopyNote_Copy_To_Same_Record()
        {
            //Arrange
            XrmFakedWorkflowContext workflowContext = new XrmFakedWorkflowContext();

            Entity note = new Entity("annotation")
            {
                Id           = Guid.NewGuid(),
                ["objectid"] = new EntityReference("account", new Guid("ba166c72-5f7b-e611-80db-fc15b4282d80"))
            };

            var inputs = new Dictionary <string, object>
            {
                { "NoteToCopy", note.ToEntityReference() },
                { "RecordUrl", "https://test.crm.dynamics.com:443/main.aspx?etc=1&id=ba166c72-5f7b-e611-80db-fc15b4282d80&histKey=694632068&newWindow=true&pagetype=entityrecord" },
                { "CopyAttachment", true }
            };

            XrmFakedContext xrmFakedContext = new XrmFakedContext();

            xrmFakedContext.Initialize(new List <Entity> {
                note
            });
            var fakeRetrieveMetadataChangesRequest = new FakeRetrieveMetadataChangesRequestExecutor();

            xrmFakedContext.AddFakeMessageExecutor <RetrieveMetadataChangesRequest>(fakeRetrieveMetadataChangesRequest);

            const bool expected = false;

            //Act
            var result = xrmFakedContext.ExecuteCodeActivity <CopyNote>(workflowContext, inputs);

            //Assert
            Assert.AreEqual(expected, result["WasNoteCopied"]);
        }
コード例 #2
0
        public void CreateTemplate_Create()
        {
            //Arrange
            XrmFakedWorkflowContext workflowContext = new XrmFakedWorkflowContext();

            var inputs = new Dictionary <string, object>
            {
                { "Template", new EntityReference("template", Guid.NewGuid()) },
                { "RecordUrl", "https://test.crm.dynamics.com:443/main.aspx?etc=1&id=76ff58d2-ae20-e811-a97e-000d3a367d35&histKey=208282481&newWindow=true&pagetype=entityrecord" }
            };

            XrmFakedContext xrmFakedContext = new XrmFakedContext();            var fakeRetrieveMetadataChangesRequest = new FakeRetrieveMetadataChangesRequestExecutor();

            xrmFakedContext.AddFakeMessageExecutor <RetrieveMetadataChangesRequest>(fakeRetrieveMetadataChangesRequest);
            var fakeInstantiateTemplateRequestExecutor = new FakeInstantiateTemplateRequestExecutor();

            xrmFakedContext.AddFakeMessageExecutor <InstantiateTemplateRequest>(fakeInstantiateTemplateRequestExecutor);

            const string expectedTemplateSubject     = "Test Subject";
            const string expectedTemplateDescription = "Test Description";

            //Act
            var result = xrmFakedContext.ExecuteCodeActivity <CreateTemplate>(workflowContext, inputs);

            //Assert
            Assert.AreEqual(expectedTemplateSubject, result["TemplateSubject"]);
            Assert.AreEqual(expectedTemplateDescription, result["TemplateDescription"]);
        }
コード例 #3
0
        public void EmailConnection_1_SystemUser_Disabled_0_Existing()
        {
            //Arrange
            XrmFakedWorkflowContext workflowContext = new XrmFakedWorkflowContext {
                PrimaryEntityId = Guid.NewGuid()
            };

            Guid   id    = Guid.NewGuid();
            Entity email = new Entity("email")
            {
                Id             = id,
                ["activityid"] = id,
                ["to"]         = new EntityCollection()
            };

            Entity systemUser = new Entity("systemuser")
            {
                Id = Guid.NewGuid(),
                ["internalemailaddress"] = "*****@*****.**",
                ["isdisabled"]           = true
            };

            Entity connectionRole = new Entity("connectionrole")
            {
                Id = Guid.NewGuid()
            };

            Entity connection = new Entity("connection")
            {
                Id                        = Guid.NewGuid(),
                ["record1id"]             = new EntityReference("systemuser", workflowContext.PrimaryEntityId),
                ["record1objecttypecode"] = new OptionSetValue(8),
                ["record2id"]             = systemUser.ToEntityReference(),
                ["record2objecttypecode"] = new OptionSetValue(8),
                ["record2roleid"]         = connectionRole.Id
            };

            var inputs = new Dictionary <string, object>
            {
                { "EmailToSend", email.ToEntityReference() },
                { "ConnectionRole", connectionRole.ToEntityReference() },
                { "IncludeOppositeConnection", false },
                { "SendEmail", false }
            };

            XrmFakedContext xrmFakedContext = new XrmFakedContext();

            xrmFakedContext.Initialize(new List <Entity> {
                email, systemUser, connectionRole, connection
            });
            var fakeRetrieveMetadataChangesRequest = new FakeRetrieveMetadataChangesRequestExecutor("systemuser");

            xrmFakedContext.AddFakeMessageExecutor <RetrieveMetadataChangesRequest>(fakeRetrieveMetadataChangesRequest);

            const int expected = 0;

            //Act
            var result = xrmFakedContext.ExecuteCodeActivity <EmailConnection>(workflowContext, inputs);

            //Assert
            Assert.AreEqual(expected, result["UsersAdded"]);
        }
コード例 #4
0
        public void EmailConnection_1_Account_1_Existing()
        {
            //Arrange
            XrmFakedWorkflowContext workflowContext = new XrmFakedWorkflowContext {
                PrimaryEntityId = Guid.NewGuid()
            };

            Guid   id    = Guid.NewGuid();
            Entity email = new Entity("email")
            {
                Id             = id,
                ["activityid"] = id
            };

            Guid   id2           = Guid.NewGuid();
            Entity activityParty = new Entity("activityparty")
            {
                Id = id2,
                ["activitypartyid"]       = id2,
                ["activityid"]            = email.ToEntityReference(),
                ["partyid"]               = new EntityReference("contact", Guid.NewGuid()),
                ["participationtypemask"] = new OptionSetValue(2)
            };

            EntityCollection to = new EntityCollection();

            to.Entities.Add(activityParty);
            email["to"] = to;

            Entity account = new Entity("account")
            {
                Id = Guid.NewGuid(),
                ["emailaddress1"] = "*****@*****.**",
                ["statecode"]     = new OptionSetValue(0)
            };

            Entity connectionRole = new Entity("connectionrole")
            {
                Id = Guid.NewGuid()
            };

            Entity connection = new Entity("connection")
            {
                Id                        = Guid.NewGuid(),
                ["record1id"]             = new EntityReference("systemuser", workflowContext.PrimaryEntityId),
                ["record1objecttypecode"] = new OptionSetValue(8),
                ["record2id"]             = account.ToEntityReference(),
                ["record2objecttypecode"] = new OptionSetValue(1),
                ["record2roleid"]         = connectionRole.Id
            };

            var inputs = new Dictionary <string, object>
            {
                { "EmailToSend", email.ToEntityReference() },
                { "ConnectionRole", connectionRole.ToEntityReference() },
                { "IncludeOppositeConnection", false },
                { "SendEmail", false }
            };

            XrmFakedContext xrmFakedContext = new XrmFakedContext();

            xrmFakedContext.Initialize(new List <Entity> {
                email, account, connectionRole, connection, activityParty
            });
            var fakeRetrieveMetadataChangesRequest = new FakeRetrieveMetadataChangesRequestExecutor("account");

            xrmFakedContext.AddFakeMessageExecutor <RetrieveMetadataChangesRequest>(fakeRetrieveMetadataChangesRequest);

            const int expected = 2;

            //Act
            var result = xrmFakedContext.ExecuteCodeActivity <EmailConnection>(workflowContext, inputs);

            //Assert
            Assert.AreEqual(expected, result["UsersAdded"]);
        }