Git Product home page Git Product logo

fake-xrm-easy-samples's Introduction

FakeXrmEasy Samples

Sample repo you can use to experiment with the different versions of FakeXrmEasy

This is the supporting code for a the following scenario :

Prerequisites

In order to build and debug the solution you will need:

Overview

This sample repo shows how to combine FakeXrmEasy versions 2 and 3 to dev and test both a plugin project that uses the CoreAssemblies sdk (.net 4.6.2), and an azure functions project that uses the DataverseClient nuget package (.net6.0).

By using a shared project (or a git submodule, or a nuget package with source files), we can dev, test, and even debug server side code (plugins) from client apps right from the same debugging session.

Scenario : Azure function (v4) + Dataverse + Plugin

You'll find an overview of why / how this project is structured in the docs here How to migrate a v3 Azure function to v4 Azure function

    1. We receive some contactdata into an Azure Function
    1. The Azure function creates a Contact using DataverseClient nuget package in .net core
    1. A plugin that fires on create of that contact record and creates a follow up Task.

In the demo we approached unit testing such scenario as follows:

    1. A unit test to validate that the contact data is sent to Dataverse correcly (the contact is created)
    1. A unit test to verify the plugin creates a follow up task given a Create message with an OutputParameter (the resulting from the Create operation) was received
    1. A pipeline simulation scenario that wires everything together In-Memory, to check that both the contact and the task are created (this is experimental stuff, because really, the target versions of the client (.net core 3.1) and the server (net462) are different in production, but eventually....)

Building and testing

The Azure function project targets net3.1, but the plugins project targets net462 so bear in mind you'll need a Windows machine to build the whole solution

From the command line:

dotnet restore
dotnet build
dotnet test

Alternatively from VS and Test Explorer

Scenario : Automatic Registration of Plugin Steps with Spkl

You'll find the sample code for automatic registration with Spkl under the /spkl directory.

Also please make sure to check out the relevant documentation

Custom Apis

The FakeXrmEasy.Samples.sln also has a running example of a custom api.

Please check the docs for high level overview of Messages, Custom Actions, and Custom Apis.

Release notes

Check out the latest release notes of FakeXrmEasy you don't miss any impotant updates!

License

This repo is available under the FakeXrmEasy's LICENSE.

Basically, you can use FakeXrmEasy free of charge:

  • In Open Source Projects and/or
  • For a Non-Commercial use and/or
  • As part of a Non-Commercial Organization

You'll need a commercial license for propietary and commercial use.

Please, have a look at our licensing FAQ for more details.

Pricing: https://dynamicsvalue.com/pricing

fake-xrm-easy-samples's People

Contributors

dependabot[bot] avatar jordimontana82 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fake-xrm-easy-samples's Issues

get_Logger does not have an implementation, when trying to Unit Test the plugin with Plugin Telemetry

Method 'get_Logger' in type 'FakeXrmEasy.Plugins.XrmFakedPluginContextProperties' from assembly 'FakeXrmEasy.Plugins, Version=2.1.1.0, Culture=neutral, PublicKeyToken=d91a65dda907a34f' does not have an implementation.'

I am using FakeXrmEasy.v9 Version 2.1.2

My Middle ware as below

using System;
using System.Reflection;
using Microsoft.Xrm.Sdk;
using FakeXrmEasy.Abstractions;
using FakeXrmEasy.Abstractions.Enums;
using FakeXrmEasy.FakeMessageExecutors;
using FakeXrmEasy.Middleware;
using FakeXrmEasy.Middleware.Crud;
using FakeXrmEasy.Middleware.Messages;
using Castle.Core.Logging;
using Moq;

namespace UnitTests
{
public class FakeXrmEasyTestBase
{
protected readonly IOrganizationService _service;
protected readonly IXrmFakedContext _context;
protected readonly Mock _serviceProviderMock;
protected readonly Mock _loggerMock;

    public FakeXrmEasyTestBase()
    {
        _context = MiddlewareBuilder
        .New()
        .AddCrud()
        .AddFakeMessageExecutors(Assembly.GetAssembly(typeof(AddListMembersListRequestExecutor)))
        .UseCrud()
        .UseMessages()
        .SetLicense(FakeXrmEasyLicense.NonCommercial)
        .Build();
        _service = _context.GetOrganizationService();
    }
}

}

UT as below

public class PluginWithTelemetryTest : FakeXrmEasyTestBase
{
[TestMethod]
public void TestTelemetryPlugin()
{
_context.ExecutePluginWithTarget();
}
}

Plugin as below

public class LoggerPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var logger = serviceProvider.Get();
logger.LogInformation("Test");
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.