Example #1
0
        public void Should_Override_Execution_Mock()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("Contact")
            {
                Id = Guid.NewGuid()
            };

            context.Initialize(new[] { e });
            context.AddExecutionMock <RetrieveEntityRequest>(RetrieveEntityMock);
            context.AddExecutionMock <RetrieveEntityRequest>(AnotherRetrieveEntityMock);

            var inputs = new ParameterCollection
            {
                { "Target", e }
            };

            context.ExecutePluginWith <CustomMockPlugin>(inputs, new ParameterCollection(), new EntityImageCollection(), new EntityImageCollection());

            Assert.Equal("Another", (string)e["response"]);
            var ex = Record.Exception(() => context.RemoveExecutionMock <RetrieveEntityRequest>());

            Assert.Null(ex);
        }
        public void Should_Execute_Mock_For_OrganizationRequests()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("Contact") { Id = Guid.NewGuid() };
            context.Initialize(new[] { e });
            context.AddExecutionMock<RetrieveEntityRequest>(RetrieveEntityMock);

            var inputs = new ParameterCollection
            {
                {"Target", e }
            };

            context.ExecutePluginWith<CustomMockPlugin>(inputs, new ParameterCollection(), new EntityImageCollection(), new EntityImageCollection());

            Assert.Equal("Successful", (string)e["response"]);
            Assert.DoesNotThrow(() => context.RemoveExecutionMock<RetrieveEntityRequest>());
        }
        public void Should_Execute_Mock_For_OrganizationRequests()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("Contact")
            {
                Id = Guid.NewGuid()
            };

            context.Initialize(new[] { e });
            context.AddExecutionMock <RetrieveEntityRequest>(RetrieveEntityMock);

            var inputs = new ParameterCollection
            {
                { "Target", e }
            };

            context.ExecutePluginWith <CustomMockPlugin>(inputs, new ParameterCollection(), new EntityImageCollection(), new EntityImageCollection());

            Assert.Equal("Successful", (string)e["response"]);
            Assert.DoesNotThrow(() => context.RemoveExecutionMock <RetrieveEntityRequest>());
        }