예제 #1
0
            public when_executing_the_plugin()
            {
                MockSharePointService.Setup(x => x.GetDocumentAsStream(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
                .ReturnsAsync(() => new MemoryStream());

                MockSharePointService.Setup(x => x.AddFileToSharePoint(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <byte[]>()))
                .Returns(Task.CompletedTask);

                MockSharePointService.Setup(x => x.GenerateDocumentFromTemplate(It.IsAny <Stream>(), It.IsAny <string>()))
                .Returns(() => new byte[] { });
            }
예제 #2
0
            public void it_should_add_the_document_to_sharepoint()
            {
                // Arrange
                var context       = new XrmFakedContext();
                var pluginContext = context.GetDefaultPluginContext();

                pluginContext.InputParameters = inputs;
                pluginContext.MessageName     = PluginMessage.GenerateDocumentFromTemplate;

                // Act
                context.ExecutePluginWith(pluginContext, PluginInstance);

                // Assert
                MockSharePointService.Verify(x => x.AddFileToSharePoint(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <byte[]>()), Times.Once());
            }
예제 #3
0
            public void it_should_throw_an_InvalidPluginExecutionException_if_there_is_an_exception_when_sending_the_file_to_sharepoint()
            {
                // Arrange
                var context       = new XrmFakedContext();
                var pluginContext = context.GetDefaultPluginContext();

                pluginContext.InputParameters = inputs;
                pluginContext.MessageName     = PluginMessage.GenerateDocumentFromTemplate;

                MockSharePointService.Setup(x => x.AddFileToSharePoint(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <byte[]>()))
                .ThrowsAsync(new Exception());

                // Act
                Action executePluginWith = () => context.ExecutePluginWith(pluginContext, PluginInstance);

                // Assert
                executePluginWith.Should().Throw <InvalidPluginExecutionException>();
            }
예제 #4
0
            public void it_should_send_a_trace_log_if_there_is_an_exception_when_generating_the_document()
            {
                // Arrange
                var context       = new XrmFakedContext();
                var pluginContext = context.GetDefaultPluginContext();

                pluginContext.InputParameters = inputs;
                pluginContext.MessageName     = PluginMessage.GenerateDocumentFromTemplate;

                MockSharePointService.Setup(x => x.GenerateDocumentFromTemplate(It.IsAny <Stream>(), It.IsAny <string>()))
                .Throws(new Exception());

                // Act
                Action executePluginWith = () => context.ExecutePluginWith(pluginContext, PluginInstance);

                // Assert
                executePluginWith.Should().Throw <InvalidPluginExecutionException>();
                context.GetFakeTracingService().DumpTrace().Should().ContainAll("Exception", "Inner Exception", "Stack Trace");
            }