-
Notifications
You must be signed in to change notification settings - Fork 15
Tutorial 2
PhuocLe edited this page Aug 24, 2018
·
13 revisions
Create Unit Test project for plugin: Paz.LuckeyMonkey.Plugin.Lead
- Finish Tutorial 0
- Finish Tutorial 1
- Add
New Project
9. C# ProxyTypes Project
to your solution- A popup form
Add new Proxy Types Project
opened - Click button
><
to create/select a Dynamics 365 connection - After connected, click
OK
-
PL.DynamicsCrm.DevKit
created project name:Paz.LuckeyMonkey.ProxyTypes
- A popup form
- Rebuild solution to restore
NuGet
packages -
Execute File
run.bat
ofPaz.LuckeyMonkey.ProxyTypes
project, waitingCrmSvcUtil
generate code toGeneratedCode.cs
file. - Rebuild solution without errors
- Add
New Project
6. C# Test Project
to your solution- A popup form
Add new Test Project
opened - Dropdown list all available projects test
- Select
Paz.LuckeyMonkey.Plugin.Lead
- Click
OK
-
PL.DynamicsCrm.DevKit
created test project name:Paz.LuckeyMonkey.Plugin.Lead.Test
- A popup form
- Rebuild solution to restore
NuGet
packages - Add
New Item
5. C# Test Class
toPaz.LuckeyMonkey.Plugin.Lead.Test
project- A popup form
Add new Test CLass
opened - Dropdown list all available test class
- Select
PreLeadCreateSynchronous
- Click
OK
-
PL.DynamicsCrm.DevKit
created test class:PreLeadCreateSynchronousTest
- A popup form
- Rebuild solution without errors
- Open
Test Explorer
window andRun All
tests.- 4 passed tests.
- 1 failed test.
- Edit failed test
[TestMethod]
public void PreLeadCreate_LeadSubjectAlwaysUppercase()
{
//setup
Context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(ProxyTypesAssembly));
Context.Data.Clear();
var subject = "lowcase subject";
var target = new Entity("lead")
{
["leadid"] = Guid.NewGuid(),
["subject"] = subject
};
PluginContext.InputParameters["Target"] = target;
//run
Context.ExecutePluginWithConfigurations<PreLeadCreateSynchronous>(PluginContext, null, null);
//result
var resultTarget = (Entity)PluginContext.InputParameters["Target"];
var lead = new Shared.Entities.Lead(resultTarget);
Assert.AreEqual(subject.ToUpper(), lead.Subject, false);
}
-
Run All
tests again- 5 passed tests
- Check-in all files to your source control
- You finished this tutorial
This tutorial, you know howto