-
Notifications
You must be signed in to change notification settings - Fork 291
/
Copy pathCreateOpportunity.cs
70 lines (51 loc) · 2.47 KB
/
CreateOpportunity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Dynamics365.UIAutomation.Api.UCI;
using Microsoft.Dynamics365.UIAutomation.Browser;
using System;
using System.Security;
namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI
{
[TestClass]
public class CreateOpportunityUCI
{
private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString();
private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString();
private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]);
[TestMethod]
public void UCITestCreateOpportunity()
{
var client = new WebClient(TestSettings.Options);
using (var xrmApp = new XrmApp(client))
{
xrmApp.OnlineLogin.Login(_xrmUri, _username, _password);
xrmApp.Navigation.OpenApp(UCIAppName.Sales);
xrmApp.Navigation.OpenSubArea("Sales", "Opportunities");
xrmApp.CommandBar.ClickCommand("New");
xrmApp.ThinkTime(5000);
xrmApp.Entity.SetValue("name", TestSettings.GetRandomString(5,10));
xrmApp.Entity.Save();
}
}
[TestMethod]
public void UCITestCreateOpportunity_SetHeaderDate()
{
var client = new WebClient(TestSettings.Options);
using (var xrmApp = new XrmApp(client))
{
xrmApp.OnlineLogin.Login(_xrmUri, _username, _password);
xrmApp.Navigation.OpenApp(UCIAppName.Sales);
xrmApp.Navigation.OpenSubArea("Sales", "Opportunities");
xrmApp.CommandBar.ClickCommand("New");
xrmApp.ThinkTime(5000);
xrmApp.Entity.SetValue("name", "Opporunity " + TestSettings.GetRandomString(5,10));
DateTime expectedDate = DateTime.Today.AddDays(10);
xrmApp.Entity.SetHeaderValue("estimatedclosedate", expectedDate);
var commandResult = xrmApp.Entity.GetHeaderValue(new DateTimeControl("estimatedclosedate"));
DateTime? date = commandResult;
Assert.AreEqual(expectedDate, date);
}
}
}
}